Code
Explorer
You are a developer and looking for Shopware projects?
Apply Now!
StateMachineTransitionEvent example
$connection
,
$this
->dispatcher,
new
StockUpdateFilterProvider
(
[
$filter
]
)
,
)
;
$fromStateEntity
=
new
StateMachineStateEntity
(
)
;
$fromStateEntity
->
setTechnicalName
(
OrderStates::STATE_OPEN
)
;
$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 */
else
{
$stateMachineHistoryEntity
[
'entityId'
]
=
[
'id' =>
$transition
->
getEntityId
(
)
, 'version_id' =>
$context
->
getVersionId
(
)
]
;
}
$this
->stateMachineHistoryRepository->
create
(
[
$stateMachineHistoryEntity
]
,
$context
)
;
$data
=
[
[
'id' =>
$transition
->
getEntityId
(
)
,
$transition
->
getStateFieldName
(
)
=>
$toPlace
->
getId
(
)
]
]
;
$repository
->
upsert
(
$data
,
$context
)
;
$this
->eventDispatcher->
dispatch
(
new
StateMachineTransitionEvent
(
$transition
->
getEntityName
(
)
,
$transition
->
getEntityId
(
)
,
$fromPlace
,
$toPlace
,
$context
)
)
;
$leaveEvent
=
new
StateMachineStateChangeEvent
(
$context
,
StateMachineStateChangeEvent::STATE_MACHINE_TRANSITION_SIDE_LEAVE,
public
function
testStateChangeCanBeDisabled
(
)
: 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
)
;
$event
=
new
StateMachineTransitionEvent
(
OrderDefinition::ENTITY_NAME,
$this
->ids->
get
(
'order-1'
)
,
$fromState
,
$toState
,
$context
)
;
$stockStorage
=
$this
->
createMock
(
StockStorage::
class
)
;
$stockStorage
->
expects
(
static
::
never
(
)
)
->
method
(
'alter'
)
;
$stockSubscriber
=
new
OrderStockSubscriber
(