Code
Explorer
You are a developer and looking for Shopware projects?
Apply Now!
setAvailableStock example
public
function
testEnrichWithStaticConfig
(
bool
$closeout
, bool
$hidden
, int
$availableStock
)
: void
{
if
(
$hidden
)
{
$this
->systemConfig->
method
(
'get'
)
->
willReturn
(
true
)
;
}
$salesChannelId
= 'f3489c46df62422abdea4aa1bb03511c';
$product
=
new
SalesChannelProductEntity
(
)
;
$product
->
setId
(
'product123'
)
;
$product
->
setAvailableStock
(
$availableStock
)
;
$product
->
setIsCloseout
(
$closeout
)
;
$salesChannel
=
new
SalesChannelEntity
(
)
;
$salesChannel
->
setId
(
$salesChannelId
)
;
$salesChannelContext
=
$this
->
createMock
(
SalesChannelContext::
class
)
;
$salesChannelContext
->
method
(
'getSalesChannelId'
)
->
willReturn
(
$salesChannelId
)
;
$salesChannelContext
->
method
(
'getSalesChannel'
)
->
willReturn
(
$salesChannel
)
;
$resolverContext
=
new
ResolverContext
(
$salesChannelContext
,
new
Request
(
)
)
;
$result
=
new
ElementDataCollection
(
)
;
public
function
testEnrich
(
bool
$closeout
, bool
$hidden
, int
$availableStock
)
: void
{
if
(
$hidden
)
{
$this
->systemConfig->
method
(
'get'
)
->
willReturn
(
true
)
;
}
$salesChannelId
= 'f3489c46df62422abdea4aa1bb03511c';
$product
=
new
SalesChannelProductEntity
(
)
;
$product
->
setId
(
'product123'
)
;
$product
->
setAvailableStock
(
$availableStock
)
;
$product
->
setIsCloseout
(
$closeout
)
;
$salesChannel
=
new
SalesChannelEntity
(
)
;
$salesChannel
->
setId
(
$salesChannelId
)
;
$salesChannelContext
=
$this
->
createMock
(
SalesChannelContext::
class
)
;
$salesChannelContext
->
method
(
'getSalesChannelId'
)
->
willReturn
(
$salesChannelId
)
;
$salesChannelContext
->
method
(
'getSalesChannel'
)
->
willReturn
(
$salesChannel
)
;
$productSliderResolver
=
new
ProductSliderCmsElementResolver
(
$this
->
createMock
(
ProductStreamBuilder::
class
)
,
$this
->systemConfig
)
;
$resolverContext
=
new
ResolverContext
(
$salesChannelContext
,
new
Request
(
)
)
;
public
function
testEnrich
(
bool
$closeout
, bool
$hidden
, int
$availableStock
)
: void
{
if
(
$hidden
)
{
$this
->systemConfig->
method
(
'get'
)
->
willReturn
(
true
)
;
}
$salesChannelId
= 'f3489c46df62422abdea4aa1bb03511c';
$productId
= Uuid::
randomHex
(
)
;
$product
=
new
SalesChannelProductEntity
(
)
;
$product
->
setId
(
$productId
)
;
$product
->
setAvailableStock
(
$availableStock
)
;
$product
->
setIsCloseout
(
$closeout
)
;
$salesChannel
=
new
SalesChannelEntity
(
)
;
$salesChannel
->
setId
(
$salesChannelId
)
;
$salesChannelContext
=
$this
->
createMock
(
SalesChannelContext::
class
)
;
$salesChannelContext
->
method
(
'getSalesChannelId'
)
->
willReturn
(
$salesChannelId
)
;
$salesChannelContext
->
method
(
'getSalesChannel'
)
->
willReturn
(
$salesChannel
)
;
$resolverContext
=
new
ResolverContext
(
$salesChannelContext
,
new
Request
(
)
)
;
$result
=
new
ElementDataCollection
(
)
;