Skip to content

Commit fbc20cf

Browse files
committed
LYNX-259: parametrized fixtures for tests
1 parent 760bc1f commit fbc20cf

File tree

2 files changed

+13
-26
lines changed

2 files changed

+13
-26
lines changed

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

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -39,11 +39,6 @@ class CreateEmptyCartTest extends GraphQlAbstract
3939
*/
4040
private $quoteIdMaskFactory;
4141

42-
/**
43-
* @var string
44-
*/
45-
private $maskedQuoteId;
46-
4742
protected function setUp(): void
4843
{
4944
$objectManager = Bootstrap::getObjectManager();

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

Lines changed: 13 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,15 @@
77

88
namespace Magento\GraphQl\Quote\Guest;
99

10+
use Magento\Quote\Api\GuestCartRepositoryInterface;
1011
use Magento\Quote\Model\QuoteIdMaskFactory;
1112
use Magento\Quote\Model\ResourceModel\Quote\CollectionFactory as QuoteCollectionFactory;
1213
use Magento\Quote\Model\ResourceModel\Quote as QuoteResource;
14+
use Magento\Store\Test\Fixture\Store;
15+
use Magento\TestFramework\Fixture\DataFixture;
16+
use Magento\TestFramework\Fixture\DataFixtureStorageManager;
1317
use Magento\TestFramework\Helper\Bootstrap;
1418
use Magento\TestFramework\TestCase\GraphQlAbstract;
15-
use Magento\Quote\Api\GuestCartRepositoryInterface;
1619

1720
/**
1821
* Test for guest cart creation mutation
@@ -68,13 +71,16 @@ public function testSuccessfulCreateGuestCart()
6871
self::assertEquals('1', $guestCart->getCustomerIsGuest());
6972
}
7073

71-
/**
72-
* @magentoApiDataFixture Magento/Store/_files/second_store.php
73-
*/
74+
#[
75+
DataFixture(Store::class, as: 'store')
76+
]
7477
public function testSuccessfulWithNotDefaultStore()
7578
{
79+
$store = DataFixtureStorageManager::getStorage()->get('store');
80+
$storeCode = $store->getCode();
81+
7682
$query = $this->getQuery();
77-
$headerMap = ['Store' => 'fixture_second_store'];
83+
$headerMap = ['Store' => $storeCode];
7884
$response = $this->graphQlMutation($query, [], '', $headerMap);
7985

8086
self::assertArrayHasKey('createGuestCart', $response);
@@ -88,13 +94,10 @@ public function testSuccessfulWithNotDefaultStore()
8894

8995
self::assertNotNull($guestCart->getId());
9096
self::assertNull($guestCart->getCustomer()->getId());
91-
self::assertSame('fixture_second_store', $guestCart->getStore()->getCode());
97+
self::assertSame($storeCode, $guestCart->getStore()->getCode());
9298
self::assertEquals('1', $guestCart->getCustomerIsGuest());
9399
}
94100

95-
/**
96-
* @magentoApiDataFixture Magento/Customer/_files/customer.php
97-
*/
98101
public function testSuccessfulWithPredefinedCartId()
99102
{
100103
$predefinedCartId = '572cda51902b5b517c0e1a2b2fd004b4';
@@ -108,16 +111,9 @@ public function testSuccessfulWithPredefinedCartId()
108111
self::assertNotEmpty($response['createGuestCart']['cart']);
109112
self::assertArrayHasKey('id', $response['createGuestCart']['cart']);
110113
self::assertNotEmpty($response['createGuestCart']['cart']['id']);
111-
112-
$guestCart = $this->guestCartRepository->get($response['createGuestCart']['cart']['id']);
113-
self::assertNotNull($guestCart->getId());
114-
self::assertNull($guestCart->getCustomer()->getId());
114+
self::assertEquals($predefinedCartId, $response['createGuestCart']['cart']['id']);
115115
}
116116

117-
/**
118-
* @magentoApiDataFixture Magento/Customer/_files/customer.php
119-
*
120-
*/
121117
public function testFailIfPredefinedCartIdAlreadyExists()
122118
{
123119
$this->expectException(\Exception::class);
@@ -130,10 +126,6 @@ public function testFailIfPredefinedCartIdAlreadyExists()
130126
$this->graphQlMutation($query);
131127
}
132128

133-
/**
134-
* @magentoApiDataFixture Magento/Customer/_files/customer.php
135-
*
136-
*/
137129
public function testFailWithWrongPredefinedCartId()
138130
{
139131
$this->expectException(\Exception::class);

0 commit comments

Comments
 (0)