Code
Explorer
You are a developer and looking for Shopware projects?
Apply Now!
fillCart example
$this
->salesChannelContext->
getContext
(
)
)
;
$dispatcher
->
removeListener
(
MailSentEvent::
class
,
$listenerClosure
)
;
static
::
assertFalse
(
$eventDidRun
, 'The mail.sent Event did not run'
)
;
}
public
function
testCreateOrder
(
)
: void
{
$data
=
new
RequestDataBag
(
[
'tos' => true
]
)
;
$this
->
fillCart
(
$this
->salesChannelContext->
getToken
(
)
)
;
$orderId
=
$this
->orderService->
createOrder
(
$data
,
$this
->salesChannelContext
)
;
$criteria
=
new
Criteria
(
[
$orderId
]
)
;
$criteria
->
addAssociation
(
'stateMachineState'
)
;
/** @var OrderEntity $newlyCreatedOrder */
$newlyCreatedOrder
=
$this
->orderRepository->
search
(
$criteria
,
$this
->salesChannelContext->
getContext
(
)
)
->
first
(
)
;
static
::
assertInstanceOf
(
OrderEntity::
class
,
$newlyCreatedOrder
)
;
$this
->
expectException
(
PaymentMethodNotAvailableException::
class
)
;
$this
->
performOrder
(
'', true
)
;
}
public
function
testOrderWithFailedPaymentMethod
(
)
: void
{
$this
->
createFailedPaymentMethodData
(
)
;
$contextToken
= Uuid::
randomHex
(
)
;
$this
->
fillCart
(
$contextToken
, false, true
)
;
$requestDataBag
=
$this
->
createRequestDataBag
(
''
)
;
$salesChannelContext
=
$this
->
createSalesChannelContext
(
$contextToken
, true
)
;
$request
=
$this
->
createRequest
(
)
;
/** @var RedirectResponse|Response $response */
$response
=
$this
->
getContainer
(
)
->
get
(
CheckoutController::
class
)
->
order
(
$requestDataBag
,
$salesChannelContext
,
$request
)
;
static
::
assertInstanceOf
(
RedirectResponse::
class
,
$response
)
;
static
::
assertStringContainsString
(
'/account/order/edit',
$response
->
getTargetUrl
(
)
, 'Target Url does not point to /checkout/finish'
)
;
}