Code
Explorer
You are a developer and looking for Shopware projects?
Apply Now!
StockUpdateFilterProvider example
$commands
=
[
new
UpdateCommand
(
$definition
,
[
'referenced_id' => 'new_referenced_id'
]
,
$primaryKey
,
$existence
,
$path
)
]
;
$stockSubscriber
=
new
StockUpdater
(
$this
->
getConnectionMock
(
)
,
$this
->dispatcher,
new
StockUpdateFilterProvider
(
[
]
)
,
)
;
$writeContextMock
=
$this
->
getMockBuilder
(
WriteContext::
class
)
->
disableOriginalConstructor
(
)
->
getMock
(
)
;
$event
=
new
PreWriteValidationEvent
(
$writeContextMock
,
$commands
)
;
$stockSubscriber
->
triggerChangeSet
(
$event
)
;
static
::
assertFalse
(
$commands
[
0
]
->
requiresChangeSet
(
)
)
;
}
class
StockUpdateFilterProviderTest
extends
TestCase
{
public
function
testHandlesFilter
(
)
: void
{
$ids
=
[
'id1', 'id2', 'id3'
]
;
$filter
=
new
TestStockUpdateFilter
(
[
'id1', 'id2'
]
)
;
$provider
=
new
StockUpdateFilterProvider
(
[
$filter
]
)
;
static
::
assertEquals
(
[
'id3'
]
,
$provider
->
filterProductIdsForStockUpdates
(
$ids
, Context::
createDefaultContext
(
)
)
)
;
}
}