public function CartCanonicalResourceTest::testNoCartAvailable in Commerce Cart API 8
Tests that cart that doesn't belong to account can't be retrieved.
File
- tests/
src/ Functional/ CartCanonicalResourceTest.php, line 32
Class
- CartCanonicalResourceTest
- Tests the cart canonical resource.
Namespace
Drupal\Tests\commerce_cart_api\FunctionalCode
public function testNoCartAvailable() {
$request_options = $this
->getAuthenticationRequestOptions('GET');
$cart = $this->container
->get('commerce_cart.cart_provider')
->createCart('default', $this->store, $this
->createUser());
$this
->assertInstanceOf(OrderInterface::class, $cart);
$url = Url::fromUri('base:cart/' . $cart
->id());
$url
->setOption('query', [
'_format' => static::$format,
]);
$response = $this
->request('GET', $url, $request_options);
$this
->assertSame(403, $response
->getStatusCode());
$this
->assertResourceErrorResponse(403, "", $response, [
'4xx-response',
'commerce_order:1',
'http_response',
], [
'',
], FALSE);
}