Code
Explorer
You are a developer and looking for Shopware projects?
Apply Now!
CmsSlotEntity example
public
function
testType
(
)
: void
{
static
::
assertSame
(
'image-slider',
$this
->imageSliderResolver->
getType
(
)
)
;
}
public
function
testCollectWithEmptyConfig
(
)
: void
{
$resolverContext
=
new
ResolverContext
(
$this
->
createMock
(
SalesChannelContext::
class
)
,
new
Request
(
)
)
;
$slot
=
new
CmsSlotEntity
(
)
;
$slot
->
setUniqueIdentifier
(
'id'
)
;
$slot
->
setType
(
'image-slider'
)
;
$slot
->
setConfig
(
[
]
)
;
$slot
->
setFieldConfig
(
new
FieldConfigCollection
(
)
)
;
$criteriaCollection
=
$this
->imageSliderResolver->
collect
(
$slot
,
$resolverContext
)
;
static
::
assertNull
(
$criteriaCollection
)
;
}
public
function
testCollectWithStaticConfig
(
)
: void
{
public
function
testType
(
)
: void
{
static
::
assertSame
(
'product-box',
$this
->productBoxResolver->
getType
(
)
)
;
}
public
function
testCollectWithEmptyConfig
(
)
: void
{
$resolverContext
=
new
ResolverContext
(
$this
->
createMock
(
SalesChannelContext::
class
)
,
new
Request
(
)
)
;
$slot
=
new
CmsSlotEntity
(
)
;
$slot
->
setUniqueIdentifier
(
'id'
)
;
$slot
->
setType
(
'product-box'
)
;
$slot
->
setConfig
(
[
]
)
;
$slot
->
setFieldConfig
(
new
FieldConfigCollection
(
)
)
;
$criteriaCollection
=
$this
->productBoxResolver->
collect
(
$slot
,
$resolverContext
)
;
static
::
assertNull
(
$criteriaCollection
)
;
}
public
function
testCollectWithStaticConfig
(
)
: void
{
/** @var SalutationCollection $enrichedCollection */
$enrichedCollection
=
$formElement
->
getData
(
)
;
$sortedKeys
=
array_values
(
$enrichedCollection
->
map
(
static
fn
(
SalutationEntity
$salutation
)
=>
$salutation
->
getSalutationKey
(
)
)
)
;
static
::
assertEquals
(
[
'd', 'c', 'b', 'a'
]
,
$sortedKeys
)
;
}
private
function
getCmsFormElement
(
)
: CmsSlotEntity
{
$slot
=
new
CmsSlotEntity
(
)
;
$slot
->
setType
(
'form'
)
;
$slot
->
setUniqueIdentifier
(
'id'
)
;
return
$slot
;
}
private
function
getSalutationCollection
(
)
: SalutationCollection
{
return
new
SalutationCollection
(
[
$this
->
createSalutationWithSalutationKey
(
'c'
)
,
$this
->
createSalutationWithSalutationKey
(
'a'
)
,
$this
->
getSlot
(
)
,
$this
->
getSlot
(
)
,
$this
->
getSlot
(
)
,
$this
->
getSlot
(
)
,
]
)
)
;
return
$block
;
}
private
function
getSlot
(
)
: CmsSlotEntity
{
$slot
=
new
CmsSlotEntity
(
)
;
$slot
->
setType
(
'slot'
)
;
$slot
->
setConfig
(
[
]
)
;
$slot
->
setSlot
(
uniqid
(
'', true
)
)
;
$slot
->
setUniqueIdentifier
(
Uuid::
randomHex
(
)
)
;
return
$slot
;
}
}
public
function
testType
(
)
: void
{
static
::
assertSame
(
'image',
$this
->imageResolver->
getType
(
)
)
;
}
public
function
testCollectWithEmptyConfig
(
)
: void
{
$resolverContext
=
new
ResolverContext
(
$this
->
createMock
(
SalesChannelContext::
class
)
,
new
Request
(
)
)
;
$slot
=
new
CmsSlotEntity
(
)
;
$slot
->
setUniqueIdentifier
(
'id'
)
;
$slot
->
setType
(
'image'
)
;
$slot
->
setConfig
(
[
]
)
;
$slot
->
setFieldConfig
(
new
FieldConfigCollection
(
)
)
;
$criteriaCollection
=
$this
->imageResolver->
collect
(
$slot
,
$resolverContext
)
;
static
::
assertNull
(
$criteriaCollection
)
;
}
public
function
testCollectWithMediaId
(
)
: void
{
static
::
assertEquals
(
'bottom',
$collection
->
getSlot
(
'bottom'
)
->
getSlot
(
)
)
;
static
::
assertNull
(
$collection
->
getSlot
(
'left'
)
)
;
$collection
->
add
(
$leftSlot
)
;
static
::
assertNotNull
(
$collection
->
getSlot
(
'left'
)
)
;
static
::
assertEquals
(
'left',
$collection
->
getSlot
(
'left'
)
->
getSlot
(
)
)
;
}
private
function
getSlot
(
string
$slotName
)
: CmsSlotEntity
{
$slot
=
new
CmsSlotEntity
(
)
;
$slot
->
setUniqueIdentifier
(
Uuid::
randomHex
(
)
)
;
$slot
->
setSlot
(
$slotName
)
;
return
$slot
;
}
}
public
function
testType
(
)
: void
{
static
::
assertSame
(
'cross-selling',
$this
->crossSellingResolver->
getType
(
)
)
;
}
public
function
testCollectWithEmptyConfig
(
)
: void
{
$resolverContext
=
new
ResolverContext
(
$this
->
createMock
(
SalesChannelContext::
class
)
,
new
Request
(
)
)
;
$slot
=
new
CmsSlotEntity
(
)
;
$slot
->
setUniqueIdentifier
(
'id'
)
;
$slot
->
setType
(
'cross-selling'
)
;
$slot
->
setConfig
(
[
]
)
;
$slot
->
setFieldConfig
(
new
FieldConfigCollection
(
)
)
;
$criteriaCollection
=
$this
->crossSellingResolver->
collect
(
$slot
,
$resolverContext
)
;
static
::
assertNull
(
$criteriaCollection
)
;
}
public
function
testCollectWithConfig
(
)
: void
{
public
function
testType
(
)
: void
{
static
::
assertSame
(
'manufacturer-logo',
$this
->manufacturerLogoCmsElementResolver->
getType
(
)
)
;
}
public
function
testCollect
(
)
: void
{
$resolverContext
=
new
ResolverContext
(
$this
->
createMock
(
SalesChannelContext::
class
)
,
new
Request
(
)
)
;
$slot
=
new
CmsSlotEntity
(
)
;
$slot
->
setUniqueIdentifier
(
'id'
)
;
$slot
->
setType
(
'manufacturer-logo'
)
;
$collection
=
$this
->manufacturerLogoCmsElementResolver->
collect
(
$slot
,
$resolverContext
)
;
static
::
assertNull
(
$collection
)
;
}
public
function
testEnrichWithoutContext
(
)
: void
{
$resolverContext
=
new
ResolverContext
(
$this
->
createMock
(
SalesChannelContext::
class
)
,
new
Request
(
)
)
;
private
function
getCmsPage
(
SalesChannelProductEntity
$productEntity
)
: CmsPageEntity
{
$cmsPageEntity
=
new
CmsPageEntity
(
)
;
$cmsSectionEntity
=
new
CmsSectionEntity
(
)
;
$cmsSectionEntity
->
setId
(
Uuid::
randomHex
(
)
)
;
$cmsBlockEntity
=
new
CmsBlockEntity
(
)
;
$cmsBlockEntity
->
setId
(
Uuid::
randomHex
(
)
)
;
$cmsSlotEntity
=
new
CmsSlotEntity
(
)
;
$cmsSlotEntity
->
setId
(
Uuid::
randomHex
(
)
)
;
$cmsSlotEntity
->
setSlot
(
json_encode
(
$productEntity
->
getTranslated
(
)
, \JSON_THROW_ON_ERROR
)
)
;
$cmsBlockEntity
->
setSlots
(
new
CmsSlotCollection
(
[
$cmsSlotEntity
]
)
)
;
$cmsSectionEntity
->
setBlocks
(
new
CmsBlockCollection
(
[
$cmsBlockEntity
]
)
)
;
$cmsPageEntity
->
setSections
(
new
CmsSectionCollection
(
[
$cmsSectionEntity
]
)
)
;
return
$cmsPageEntity
;
}
/** * @return array<string, array<string, array<string, array<string, array<string, string>>>>> */
public
function
testGetType
(
)
: void
{
static
::
assertSame
(
'product-slider',
$this
->sliderResolver->
getType
(
)
)
;
}
public
function
testCollectWithEmptyConfig
(
)
: void
{
$resolverContext
=
new
ResolverContext
(
$this
->
createMock
(
SalesChannelContext::
class
)
,
new
Request
(
)
)
;
$slot
=
new
CmsSlotEntity
(
)
;
$slot
->
setUniqueIdentifier
(
'id'
)
;
$slot
->
setType
(
'product-slider'
)
;
$slot
->
setFieldConfig
(
new
FieldConfigCollection
(
)
)
;
$collection
=
$this
->sliderResolver->
collect
(
$slot
,
$resolverContext
)
;
static
::
assertNull
(
$collection
)
;
}
public
function
testCollectWithEmptyStaticConfig
(
)
: void
{
public
function
testGetType
(
)
: void
{
static
::
assertSame
(
'buy-box',
$this
->buyBoxResolver->
getType
(
)
)
;
}
public
function
testCollectWithEmptyConfig
(
)
: void
{
$resolverContext
=
new
ResolverContext
(
$this
->
createMock
(
SalesChannelContext::
class
)
,
new
Request
(
)
)
;
$slot
=
new
CmsSlotEntity
(
)
;
$slot
->
setUniqueIdentifier
(
'id'
)
;
$slot
->
setType
(
'buy-box'
)
;
$slot
->
setConfig
(
[
]
)
;
$slot
->
setFieldConfig
(
new
FieldConfigCollection
(
)
)
;
$criteriaCollection
=
$this
->buyBoxResolver->
collect
(
$slot
,
$resolverContext
)
;
static
::
assertNull
(
$criteriaCollection
)
;
}
public
function
testCollectWithStaticConfig
(
)
: void
{
public
function
testType
(
)
: void
{
static
::
assertSame
(
'text',
$this
->textResolver->
getType
(
)
)
;
}
public
function
testCollectWithEmptyConfig
(
)
: void
{
$resolverContext
=
new
ResolverContext
(
$this
->
createMock
(
SalesChannelContext::
class
)
,
new
Request
(
)
)
;
$slot
=
new
CmsSlotEntity
(
)
;
$slot
->
setUniqueIdentifier
(
'id'
)
;
$slot
->
setType
(
'text'
)
;
$slot
->
setConfig
(
[
]
)
;
$slot
->
setFieldConfig
(
new
FieldConfigCollection
(
)
)
;
$criteriaCollection
=
$this
->textResolver->
collect
(
$slot
,
$resolverContext
)
;
static
::
assertNull
(
$criteriaCollection
)
;
}
public
function
testEnrichWithEmptyConfig
(
)
: void
{
public
function
testGetType
(
)
: void
{
static
::
assertSame
(
'product-box',
$this
->boxCmsElementResolver->
getType
(
)
)
;
}
public
function
testCollectWithEmptyConfig
(
)
: void
{
$resolverContext
=
new
ResolverContext
(
$this
->
createMock
(
SalesChannelContext::
class
)
,
new
Request
(
)
)
;
$slot
=
new
CmsSlotEntity
(
)
;
$slot
->
setUniqueIdentifier
(
'id'
)
;
$slot
->
setType
(
'product-box'
)
;
$slot
->
setFieldConfig
(
new
FieldConfigCollection
(
)
)
;
$collection
=
$this
->boxCmsElementResolver->
collect
(
$slot
,
$resolverContext
)
;
static
::
assertNull
(
$collection
)
;
}
public
function
testCollectWithEmptyStaticConfig
(
)
: void
{
$availableSortings
=
$slotConfig
[
'availableSortings'
]
[
'value'
]
;
$result
=
new
ElementDataCollection
(
)
;
$resolverContext
=
new
ResolverContext
(
$this
->salesChannelContext,
new
Request
(
[
]
,
[
'order' => 'name-asc'
]
)
)
;
$slot
=
new
CmsSlotEntity
(
)
;
$slot
->
setUniqueIdentifier
(
'id'
)
;
$slot
->
setType
(
'product-listing'
)
;
$slot
->
addTranslated
(
'config',
$slotConfig
)
;
$this
->productListingCMSElementResolver->
enrich
(
$slot
,
$resolverContext
,
$result
)
;
/** @var ProductListingStruct $data */
$data
=
$slot
->
getData
(
)
;
/** @var ProductListingResult $listing */
$listing
=
$data
->
getListing
(
)
;
$resolverMock
->
method
(
'getType'
)
->
willReturn
(
'dummy-type'
)
;
$this
->dummyResolver =
$resolverMock
;
}
public
function
testCollectWithStaticConfig
(
)
: void
{
$resolverContext
=
new
ResolverContext
(
$this
->
createMock
(
SalesChannelContext::
class
)
,
new
Request
(
)
)
;
$fieldConfig
=
new
FieldConfigCollection
(
)
;
$fieldConfig
->
add
(
new
FieldConfig
(
'product', FieldConfig::SOURCE_STATIC, 'product123'
)
)
;
$slot
=
new
CmsSlotEntity
(
)
;
$slot
->
setUniqueIdentifier
(
'id'
)
;
$slot
->
setType
(
'dummy-type'
)
;
$slot
->
setFieldConfig
(
$fieldConfig
)
;
$criteriaCollection
=
$this
->dummyResolver->
collect
(
$slot
,
$resolverContext
)
;
static
::
assertNotNull
(
$criteriaCollection
)
;
static
::
assertCount
(
1,
$criteriaCollection
->
all
(
)
)
;
/** @var Criteria $criteria */
$criteria
=
$criteriaCollection
->
all
(
)
[
SalesChannelProductDefinition::
class
]
[
'product_id'
]
;