Code
Explorer
You are a developer and looking for Shopware projects?
Apply Now!
CustomerGroupCollection example
array
$options
,
false|array
$fetchDataResult
,
false|string
$fetchParentLanguageResult
,
array
$entitySearchResult
,
?string
$exceptionMessage
= null
)
: void
{
if
(
$exceptionMessage
!== null
)
{
static
::
expectExceptionMessage
(
$exceptionMessage
)
;
}
$currencyRepository
=
new
StaticEntityRepository
(
[
new
CurrencyCollection
(
$entitySearchResult
[
CurrencyDefinition::ENTITY_NAME
]
??
[
]
)
]
)
;
$customerGroupRepository
=
new
StaticEntityRepository
(
[
new
CustomerGroupCollection
(
$entitySearchResult
[
CustomerGroupDefinition::ENTITY_NAME
]
??
[
]
)
]
)
;
$countryRepository
=
new
StaticEntityRepository
(
[
new
CountryCollection
(
$entitySearchResult
[
CountryDefinition::ENTITY_NAME
]
??
[
]
)
]
)
;
$taxRepository
=
new
StaticEntityRepository
(
[
new
TaxCollection
(
$entitySearchResult
[
TaxDefinition::ENTITY_NAME
]
??
[
]
)
]
)
;
$paymentMethodRepository
=
new
StaticEntityRepository
(
[
new
PaymentMethodCollection
(
$entitySearchResult
[
PaymentMethodDefinition::ENTITY_NAME
]
??
[
]
)
]
)
;
$shippingMethodRepository
=
new
StaticEntityRepository
(
[
new
ShippingMethodCollection
(
$entitySearchResult
[
ShippingMethodDefinition::ENTITY_NAME
]
??
[
]
)
]
)
;
$salesChannelRepository
=
new
StaticEntityRepository
(
[
new
SalesChannelCollection
(
$entitySearchResult
[
SalesChannelDefinition::ENTITY_NAME
]
??
[
]
)
]
)
;
$countryStateRepository
=
new
StaticEntityRepository
(
[
new
CountryStateCollection
(
$entitySearchResult
[
CountryStateDefinition::ENTITY_NAME
]
??
[
]
)
]
)
;
$currencyCountryRepository
=
new
StaticEntityRepository
(
[
new
CurrencyCountryRoundingCollection
(
$entitySearchResult
[
CurrencyCountryRoundingDefinition::ENTITY_NAME
]
??
[
]
)
]
)
;
$connection
=
$this
->
createMock
(
Connection::
class
)
;
$connection
->
expects
(
static
::
once
(
)
)
->
method
(
'fetchAssociative'
)
->
willReturn
(
$fetchDataResult
)
;
null,
$criteria
,
$context
)
,
)
;
}
private
function
setCustomerGroupSearchReturn
(
Context
$context
)
: void
{
$customerGroup
=
new
CustomerGroupEntity
(
)
;
$customerGroup
->
setId
(
Uuid::
class
)
;
$collection
=
new
CustomerGroupCollection
(
[
$customerGroup
]
)
;
$this
->customerGroupRepositoryMock->
method
(
'search'
)
->
willReturn
(
new
EntitySearchResult
(
CustomerGroupDefinition::ENTITY_NAME,
$collection
->
count
(
)
,
$collection
,
null,
new
Criteria
(
)
,
$context
,
)
)
;
}
return
$this
->
fmap
(
fn
(
CustomerEntity
$customer
)
=>
$customer
->
getDefaultShippingAddressId
(
)
)
;
}
public
function
filterByDefaultShippingAddressId
(
string
$id
)
: self
{
return
$this
->
filter
(
fn
(
CustomerEntity
$customer
)
=>
$customer
->
getDefaultShippingAddressId
(
)
===
$id
)
;
}
public
function
getGroups
(
)
: CustomerGroupCollection
{
return
new
CustomerGroupCollection
(
$this
->
fmap
(
fn
(
CustomerEntity
$customer
)
=>
$customer
->
getGroup
(
)
)
)
;
}
public
function
getDefaultPaymentMethods
(
)
: PaymentMethodCollection
{
return
new
PaymentMethodCollection
(
$this
->
fmap
(
fn
(
CustomerEntity
$customer
)
=>
$customer
->
getDefaultPaymentMethod
(
)
)
)
;
}