You are here

public function CartUpdateItemsResourceTest::testMissingCart in Commerce Cart API 8

Tests patch when cart does not exist.

File

tests/src/Functional/CartUpdateItemsResourceTest.php, line 35

Class

CartUpdateItemsResourceTest
Tests the cart update items resource.

Namespace

Drupal\Tests\commerce_cart_api\Functional

Code

public function testMissingCart() {
  $request_options = $this
    ->getAuthenticationRequestOptions('PATCH');
  $request_options[RequestOptions::HEADERS]['Content-Type'] = static::$mimeType;

  // Attempt to patch items when no cart exists.
  $url = Url::fromUri('base:cart/1/items');
  $url
    ->setOption('query', [
    '_format' => static::$format,
  ]);
  $request_options[RequestOptions::BODY] = '{"1":{"quantity":"1"}}';
  $response = $this
    ->request('PATCH', $url, $request_options);
  $this
    ->assertResourceErrorResponse(404, FALSE, $response);
}