Code
Explorer
You are a developer and looking for Shopware projects?
Apply Now!
setFieldConfig example
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'
]
;
static
::
assertInstanceOf
(
Criteria::
class
,
$criteria
)
;
static
::
assertCount
(
1,
$criteria
->
getFilters
(
)
)
;
/** @var OrFilter $orFilter */
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
{
$resolverContext
=
new
ResolverContext
(
$this
->
createMock
(
SalesChannelContext::
class
)
,
new
Request
(
)
)
;
$fieldConfig
=
new
FieldConfigCollection
(
)
;
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
{
$resolverContext
=
new
ResolverContext
(
$this
->
createMock
(
SalesChannelContext::
class
)
,
new
Request
(
)
)
;
$fieldConfig
=
new
FieldConfigCollection
(
)
;
null,
new
Criteria
(
)
,
$resolverContext
->
getSalesChannelContext
(
)
->
getContext
(
)
)
)
;
$fieldConfig
=
new
FieldConfigCollection
(
)
;
$fieldConfig
->
add
(
new
FieldConfig
(
'media', FieldConfig::SOURCE_STATIC, 'media_01'
)
)
;
$slot
=
new
CmsSlotEntity
(
)
;
$slot
->
setUniqueIdentifier
(
'id'
)
;
$slot
->
setType
(
'manufacturer-logo'
)
;
$slot
->
setFieldConfig
(
$fieldConfig
)
;
$this
->manufacturerLogoCmsElementResolver->
enrich
(
$slot
,
$resolverContext
,
$result
)
;
/** @var ManufacturerLogoStruct|null $manufacturerLogoStruct */
$manufacturerLogoStruct
=
$slot
->
getData
(
)
;
static
::
assertInstanceOf
(
ManufacturerLogoStruct::
class
,
$manufacturerLogoStruct
)
;
static
::
assertNotEmpty
(
$manufacturerLogoStruct
->
getManufacturer
(
)
)
;
static
::
assertEquals
(
'manufacturer_01',
$manufacturerLogoStruct
->
getManufacturer
(
)
->
getId
(
)
)
;
static
::
assertEquals
(
'media_01',
$manufacturerLogoStruct
->
getMediaId
(
)
)
;
}
}
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
{
$resolverContext
=
new
ResolverContext
(
$this
->
createMock
(
SalesChannelContext::
class
)
,
new
Request
(
)
)
;
$fieldConfig
=
new
FieldConfigCollection
(
)
;
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
{
$resolverContext
=
new
ResolverContext
(
$this
->
createMock
(
SalesChannelContext::
class
)
,
new
Request
(
)
)
;
$result
=
new
ElementDataCollection
(
)
;
$product
=
new
SalesChannelProductEntity
(
)
;
$product
->
setId
(
'product_01'
)
;
$product
->
setName
(
'Product 01'
)
;
$resolverContext
=
new
EntityResolverContext
(
$this
->
createMock
(
SalesChannelContext::
class
)
,
new
Request
(
)
,
$this
->
getContainer
(
)
->
get
(
SalesChannelProductDefinition::
class
)
,
$product
)
;
$result
=
new
ElementDataCollection
(
)
;
$slot
=
new
CmsSlotEntity
(
)
;
$slot
->
setUniqueIdentifier
(
'id'
)
;
$slot
->
setType
(
'product-name'
)
;
$slot
->
setFieldConfig
(
new
FieldConfigCollection
(
[
new
FieldConfig
(
'content', FieldConfig::SOURCE_MAPPED, 'product.name'
)
]
)
)
;
$this
->productNameCmsElementResolver->
enrich
(
$slot
,
$resolverContext
,
$result
)
;
/** @var TextStruct|null $textStruct */
$textStruct
=
$slot
->
getData
(
)
;
static
::
assertInstanceOf
(
TextStruct::
class
,
$textStruct
)
;
static
::
assertNotEmpty
(
$textStruct
->
getContent
(
)
)
;
static
::
assertEquals
(
'Product 01',
$textStruct
->
getContent
(
)
)
;
}
public
function
testWithStaticContentAndMappedVariable
(
)
: 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
{
$resolverContext
=
new
ResolverContext
(
$this
->
createMock
(
SalesChannelContext::
class
)
,
new
Request
(
)
)
;
$fieldConfig
=
new
FieldConfigCollection
(
)
;
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
{
$resolverContext
=
new
ResolverContext
(
$this
->
createMock
(
SalesChannelContext::
class
)
,
new
Request
(
)
)
;
$fieldConfig
=
new
FieldConfigCollection
(
)
;
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
{
$resolverContext
=
new
ResolverContext
(
$this
->
createMock
(
SalesChannelContext::
class
)
,
new
Request
(
)
)
;
$fieldConfig
=
new
FieldConfigCollection
(
)
;
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
{
$resolverContext
=
new
ResolverContext
(
$this
->
createMock
(
SalesChannelContext::
class
)
,
new
Request
(
)
)
;
$fieldConfig
=
new
FieldConfigCollection
(
)
;