You are here

public function CartAccessApiResourceTest::testNotUsersCart in Commerce Cart API 8

Check no access for cart not belonging to user (cart canonical).

File

tests/src/Functional/CartAccessApiResourceTest.php, line 112

Class

CartAccessApiResourceTest
Tests cart api access check.

Namespace

Drupal\Tests\commerce_cart_api\Functional

Code

public function testNotUsersCart() {
  $request_options = $this
    ->getAuthenticationRequestOptions('GET');
  $cart = $this->cartProvider
    ->createCart('default', $this->store);
  $this->cartManager
    ->addEntity($cart, $this->variation, 2);
  $url = Url::fromUri('base:cart/' . $cart
    ->id());
  $url
    ->setOption('query', [
    '_format' => static::$format,
  ]);
  $response = $this
    ->request('GET', $url, $request_options);
  $this
    ->assertResourceErrorResponse(403, "", $response, [
    '4xx-response',
    'commerce_order:1',
    'http_response',
  ], [
    '',
  ], FALSE);
}