Skip to content

Commit bc1b96f

Browse files
Deepak TiwariDeepak Tiwari
authored andcommitted
AC-14142: Added new fixtures
1 parent 7498e5c commit bc1b96f

File tree

1 file changed

+15
-8
lines changed

1 file changed

+15
-8
lines changed

dev/tests/api-functional/testsuite/Magento/GraphQl/GraphQlCache/CacheIdFactorProviders/Customer/CustomerGroupProviderTest.php

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,15 @@
77

88
namespace Magento\GraphQl\GraphQlCache\CacheIdFactorProviders\Customer;
99

10+
use Magento\Catalog\Test\Fixture\Product as ProductFixture;
1011
use Magento\Customer\Api\CustomerRepositoryInterface;
1112
use Magento\Customer\Model\Group;
13+
use Magento\Customer\Test\Fixture\Customer;
1214
use Magento\Framework\Exception\AuthenticationException;
1315
use Magento\GraphQlCache\Model\CacheId\CacheIdCalculator;
1416
use Magento\Integration\Api\CustomerTokenServiceInterface;
17+
use Magento\TestFramework\Fixture\DataFixture;
18+
use Magento\TestFramework\Fixture\DataFixtureStorageManager;
1519
use Magento\TestFramework\Helper\Bootstrap;
1620
use Magento\TestFramework\TestCase\GraphQlAbstract;
1721

@@ -45,13 +49,16 @@ protected function setUp(): void
4549

4650
/**
4751
* Tests that cache id header changes based on customer group and remains consistent for same customer group
48-
*
49-
* @magentoApiDataFixture Magento/Customer/_files/customer.php
50-
* @magentoApiDataFixture Magento/GraphQl/Catalog/_files/simple_product.php
5152
*/
53+
#[
54+
DataFixture(Customer::class, as: 'customer'),
55+
DataFixture(ProductFixture::class, as: 'product'),
56+
]
5257
public function testCacheIdHeaderWithCustomerGroup()
5358
{
54-
$sku = 'simple_product';
59+
$customer = DataFixtureStorageManager::getStorage()->get('customer');
60+
$product = DataFixtureStorageManager::getStorage()->get('product');
61+
$sku = $product->getSku();
5562
$query = <<<QUERY
5663
{
5764
products(filter: {sku: {eq: "{$sku}"}})
@@ -67,12 +74,12 @@ public function testCacheIdHeaderWithCustomerGroup()
6774
}
6875
}
6976
QUERY;
70-
$response = $this->graphQlQueryWithResponseHeaders($query, [], '', $this->getHeaderMap());
77+
$response = $this->graphQlQueryWithResponseHeaders($query, [], '', $this->getHeaderMap($customer->getEmail()));
7178
$this->assertArrayHasKey(CacheIdCalculator::CACHE_ID_HEADER, $response['headers']);
7279
$cacheId = $response['headers'][CacheIdCalculator::CACHE_ID_HEADER];
7380
$this->assertTrue((boolean)preg_match('/^[0-9a-f]{64}$/i', $cacheId));
7481
$groupCode = 'Retailer';
75-
$customer = $this->customerRepository->get('customer@example.com');
82+
$customer = $this->customerRepository->get($customer->getEmail());
7683
$customerGroupId = $this->customerGroup->load($groupCode, 'customer_group_code')->getId();
7784
// change the customer group of this customer from the default group
7885
$customer->setGroupId($customerGroupId);
@@ -81,7 +88,7 @@ public function testCacheIdHeaderWithCustomerGroup()
8188
$query,
8289
[],
8390
'',
84-
$this->getHeaderMap()
91+
$this->getHeaderMap($customer->getEmail())
8592
);
8693
$this->assertArrayHasKey(CacheIdCalculator::CACHE_ID_HEADER, $responseAfterCustomerGroupChange['headers']);
8794
$cacheIdCustomerGroupChange = $responseAfterCustomerGroupChange['headers'][CacheIdCalculator::CACHE_ID_HEADER];
@@ -96,7 +103,7 @@ public function testCacheIdHeaderWithCustomerGroup()
96103
$query,
97104
[],
98105
'',
99-
$this->getHeaderMap()
106+
$this->getHeaderMap($customer->getEmail())
100107
);
101108
$cacheIdDefaultCustomerGroup = $responseDefaultCustomerGroup['headers'][CacheIdCalculator::CACHE_ID_HEADER];
102109
//Verify that the cache id is same as original $cacheId

0 commit comments

Comments
 (0)