Skip to content

Commit a241594

Browse files
committed
GraphQL-606: [Test coverage] Add virtual product to cart
1 parent b99e9dd commit a241594

File tree

2 files changed

+16
-20
lines changed

2 files changed

+16
-20
lines changed

dev/tests/api-functional/testsuite/Magento/GraphQl/Quote/Customer/AddVirtualProductToCartTest.php

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -56,36 +56,34 @@ public function testAddVirtualProductToCart()
5656
/**
5757
* @magentoApiDataFixture Magento/Customer/_files/customer.php
5858
* @magentoApiDataFixture Magento/GraphQl/Catalog/_files/virtual_product.php
59+
*
60+
* @expectedException \Exception
61+
* @expectedExceptionMessage Could not find a cart with ID "non_existent_masked_id"
5962
*/
6063
public function testAddVirtualToNonExistentCart()
6164
{
6265
$sku = 'virtual_product';
6366
$qty = 2;
6467
$nonExistentMaskedQuoteId = 'non_existent_masked_id';
65-
$query = $this->getQuery($nonExistentMaskedQuoteId, $sku, $qty);
66-
67-
$this->expectExceptionMessage(
68-
"Could not find a cart with ID \"$nonExistentMaskedQuoteId\""
69-
);
7068

69+
$query = $this->getQuery($nonExistentMaskedQuoteId, $sku, $qty);
7170
$this->graphQlMutation($query, [], '', $this->getHeaderMap());
7271
}
7372

7473
/**
7574
* @magentoApiDataFixture Magento/Customer/_files/customer.php
7675
* @magentoApiDataFixture Magento/GraphQl/Quote/_files/customer/create_empty_cart.php
76+
*
77+
* @expectedException \Exception
78+
* @expectedExceptionMessage Could not find a product with SKU "virtual_product"
7779
*/
7880
public function testNonExistentProductToCart()
7981
{
8082
$sku = 'virtual_product';
8183
$qty = 2;
8284
$maskedQuoteId = $this->getMaskedQuoteIdByReservedOrderId->execute('test_quote');
83-
$query = $this->getQuery($maskedQuoteId, $sku, $qty);
84-
85-
$this->expectExceptionMessage(
86-
"Could not find a product with SKU \"virtual_product\""
87-
);
8885

86+
$query = $this->getQuery($maskedQuoteId, $sku, $qty);
8987
$this->graphQlMutation($query, [], '', $this->getHeaderMap());
9088
}
9189

dev/tests/api-functional/testsuite/Magento/GraphQl/Quote/Guest/AddVirtualProductToCartTest.php

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -50,35 +50,33 @@ public function testAddVirtualProductToCart()
5050

5151
/**
5252
* @magentoApiDataFixture Magento/GraphQl/Catalog/_files/virtual_product.php
53+
*
54+
* @expectedException \Exception
55+
* @expectedExceptionMessage Could not find a cart with ID "non_existent_masked_id"
5356
*/
5457
public function testAddVirtualToNonExistentCart()
5558
{
5659
$sku = 'virtual_product';
5760
$qty = 1;
5861
$maskedQuoteId = 'non_existent_masked_id';
59-
$query = $this->getQuery($maskedQuoteId, $sku, $qty);
60-
61-
$this->expectExceptionMessage(
62-
"Could not find a cart with ID \"non_existent_masked_id\""
63-
);
6462

63+
$query = $this->getQuery($maskedQuoteId, $sku, $qty);
6564
$this->graphQlMutation($query);
6665
}
6766

6867
/**
6968
* @magentoApiDataFixture Magento/GraphQl/Quote/_files/guest/create_empty_cart.php
69+
*
70+
* @expectedException \Exception
71+
* @expectedExceptionMessage Could not find a product with SKU "virtual_product"
7072
*/
7173
public function testNonExistentProductToCart()
7274
{
7375
$sku = 'virtual_product';
7476
$qty = 1;
7577
$maskedQuoteId = $this->getMaskedQuoteIdByReservedOrderId->execute('test_quote');
76-
$query = $this->getQuery($maskedQuoteId, $sku, $qty);
77-
78-
$this->expectExceptionMessage(
79-
"Could not find a product with SKU \"virtual_product\""
80-
);
8178

79+
$query = $this->getQuery($maskedQuoteId, $sku, $qty);
8280
$this->graphQlMutation($query);
8381
}
8482

0 commit comments

Comments
 (0)