public function CartUpdateItemResourceTest::testCartNoAccess in Commerce Cart API 8
Tests cart that does not belong to the account.
File
- tests/
src/ Functional/ CartUpdateItemResourceTest.php, line 77
Class
- CartUpdateItemResourceTest
- Tests the cart update items resource.
Namespace
Drupal\Tests\commerce_cart_api\FunctionalCode
public function testCartNoAccess() {
$request_options = $this
->getAuthenticationRequestOptions('PATCH');
$request_options[RequestOptions::HEADERS]['Content-Type'] = static::$mimeType;
// Cart that does not belong to the account.
$cart = $this->cartProvider
->createCart('default', $this->store);
$this->cartManager
->addEntity($cart, $this->variation, 2);
$this
->assertEquals(count($cart
->getItems()), 1);
$items = $cart
->getItems();
$order_item = $items[0];
$url = Url::fromUri('base:cart/' . $cart
->id() . '/items/' . $order_item
->id());
$url
->setOption('query', [
'_format' => static::$format,
]);
$response = $this
->request('PATCH', $url, $request_options);
$this
->assertResourceErrorResponse(403, FALSE, $response);
}