Code
Explorer
You are a developer and looking for Shopware projects?
Apply Now!
SetOrderStateAction example
private
MockObject&StorableFlow
$flow
;
private
SetOrderStateAction
$action
;
protected
function
setUp
(
)
: void
{
$this
->connection =
$this
->
createMock
(
Connection::
class
)
;
$log
=
$this
->
createMock
(
LoggerInterface::
class
)
;
$this
->orderService =
$this
->
createMock
(
OrderService::
class
)
;
$this
->action =
new
SetOrderStateAction
(
$this
->connection,
$log
,
$this
->orderService
)
;
$this
->flow =
$this
->
createMock
(
StorableFlow::
class
)
;
}
public
function
testRequirements
(
)
: void
{
static
::
assertSame
(
[
OrderAware::
class
]
,
$this
->action->
requirements
(
)
)
;
}
public
function
testSetOrderStatus
(
array
$config
, array
$expects
)
: void
{
$orderId
= Uuid::
randomHex
(
)
;
$context
= Context::
createDefaultContext
(
)
;
$this
->orderRepository->
create
(
$this
->
getOrderData
(
$orderId
,
$context
)
,
$context
)
;
$order
=
$this
->orderRepository->
search
(
new
Criteria
(
[
$orderId
]
)
,
$context
)
->
first
(
)
;
$event
=
new
CheckoutOrderPlacedEvent
(
$context
,
$order
, TestDefaults::SALES_CHANNEL
)
;
$subscriber
=
new
SetOrderStateAction
(
$this
->
getContainer
(
)
->
get
(
Connection::
class
)
,
$this
->
getContainer
(
)
->
get
(
'logger'
)
,
$this
->
getContainer
(
)
->
get
(
OrderService::
class
)
)
;
/** @var FlowFactory $flowFactory */
$flowFactory
=
$this
->
getContainer
(
)
->
get
(
FlowFactory::
class
)
;
$flow
=
$flowFactory
->
create
(
$event
)
;
$flow
->
setConfig
(
$config
)
;
$subscriber
->
handleFlow
(
$flow
)
;