Code
Explorer
You are a developer and looking for Shopware projects?
Apply Now!
stateChanged example
$toStateEntity
=
new
StateMachineStateEntity
(
)
;
$toStateEntity
->
setTechnicalName
(
OrderStates::STATE_CANCELLED
)
;
$event
=
new
StateMachineTransitionEvent
(
OrderDefinition::ENTITY_NAME,
$this
->ids->
get
(
'order1'
)
,
$fromStateEntity
,
$toStateEntity
,
Context::
createDefaultContext
(
)
)
;
$stockUpdater
->
stateChanged
(
$event
)
;
}
/** * @param string[] $ids * * @return MockObject&AbstractStockUpdateFilter */
public
function
getStockUpdateFilterMock
(
array
$ids
)
: MockObject
{
$filter
=
$this
->
createMock
(
TestStockUpdateFilter::
class
)
;
$filter
->
expects
(
static
::
once
(
)
)
->
method
(
'filter'
)
->
with
(
$ids
)
->
willReturn
(
$ids
)
;
$stockStorage
=
$this
->
createMock
(
StockStorage::
class
)
;
$stockStorage
->
expects
(
static
::
never
(
)
)
->
method
(
'alter'
)
;
$stockSubscriber
=
new
OrderStockSubscriber
(
$this
->
createMock
(
Connection::
class
)
,
$stockStorage
,
false
)
;
$stockSubscriber
->
stateChanged
(
$event
)
;
}
public
function
testStateChangeOnlyReactsToLiveVersions
(
)
: void
{
$context
= Context::
createDefaultContext
(
)
->
createWithVersionId
(
$this
->ids->
create
(
'version'
)
)
;
$fromState
=
new
StateMachineStateEntity
(
)
;
$fromState
->
setTechnicalName
(
OrderStates::STATE_OPEN
)
;
$toState
=
new
StateMachineStateEntity
(
)
;
$toState
->
setTechnicalName
(
OrderStates::STATE_CANCELLED
)
;