public function testPreview(): void
{ $cart =
$this->
generateDemoCart(2
);
$orderId =
$this->
persistCart($cart);
/** @var OrderEntity $order */
$order =
$this->orderRepository->
search(new Criteria([$orderId]),
$this->context
)->
get($orderId);
static::
assertNotNull($order);
$endpoint =
sprintf('/api/_action/order/%s/%s/document/invoice/preview', Uuid::
randomHex(),
$order->
getDeepLinkCode());
$this->
getBrowser()->
request('GET',
$endpoint);
static::
assertEquals($this->
getBrowser()->
getResponse()->
getStatusCode(), Response::HTTP_NOT_FOUND
);
$response =
json_decode((string) $this->
getBrowser()->
getResponse()->
getContent(), true, 512, \JSON_THROW_ON_ERROR
);
static::
assertNotEmpty($response['errors'
]);
if (!Feature::
isActive('v6.6.0.0'
)) { static::
assertEquals('CHECKOUT__INVALID_ORDER_ID',
$response['errors'
][0
]['code'
]);
} else { static::
assertEquals('DOCUMENT__GENERATION_ERROR',
$response['errors'
][0
]['code'
]);
}