From 859307b2cf3cd1898cf9d38860408a9eebdade2d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Maciej=20Paw=C5=82owski?= Date: Fri, 13 Dec 2019 19:05:28 +0100 Subject: [PATCH 01/11] prevent pointless session start in webapi scope --- app/code/Magento/Customer/etc/webapi_rest/di.xml | 2 +- app/code/Magento/PageCache/etc/di.xml | 3 --- app/code/Magento/PageCache/etc/frontend/di.xml | 1 + app/code/Magento/User/etc/webapi_rest/di.xml | 2 +- 4 files changed, 3 insertions(+), 5 deletions(-) diff --git a/app/code/Magento/Customer/etc/webapi_rest/di.xml b/app/code/Magento/Customer/etc/webapi_rest/di.xml index f2457963a5f3d..5f3ca2fdb7453 100644 --- a/app/code/Magento/Customer/etc/webapi_rest/di.xml +++ b/app/code/Magento/Customer/etc/webapi_rest/di.xml @@ -13,7 +13,7 @@ - Magento\Customer\Model\Authorization\CustomerSessionUserContext + Magento\Customer\Model\Authorization\CustomerSessionUserContext\Proxy 20 diff --git a/app/code/Magento/PageCache/etc/di.xml b/app/code/Magento/PageCache/etc/di.xml index adf9526fc1108..2a9abbb860805 100644 --- a/app/code/Magento/PageCache/etc/di.xml +++ b/app/code/Magento/PageCache/etc/di.xml @@ -37,9 +37,6 @@ Magento\Framework\View\Layout\LayoutCacheKeyInterface - - - diff --git a/app/code/Magento/PageCache/etc/frontend/di.xml b/app/code/Magento/PageCache/etc/frontend/di.xml index a396a46ae7346..5eaa650a0fc77 100644 --- a/app/code/Magento/PageCache/etc/frontend/di.xml +++ b/app/code/Magento/PageCache/etc/frontend/di.xml @@ -9,6 +9,7 @@ + diff --git a/app/code/Magento/User/etc/webapi_rest/di.xml b/app/code/Magento/User/etc/webapi_rest/di.xml index 7c6cccb454df7..930e505648d9c 100644 --- a/app/code/Magento/User/etc/webapi_rest/di.xml +++ b/app/code/Magento/User/etc/webapi_rest/di.xml @@ -10,7 +10,7 @@ - Magento\User\Model\Authorization\AdminSessionUserContext + Magento\User\Model\Authorization\AdminSessionUserContext\Proxy 30 From 8aed39fd69115f93282e933fdbdf7d8584daa082 Mon Sep 17 00:00:00 2001 From: Alexander Steshuk Date: Tue, 31 Mar 2020 13:44:53 +0300 Subject: [PATCH 02/11] magento2/pull/26032: Fix api-functional tests --- .../Catalog/ProductInMultipleStoresTest.php | 19 +++++++------ .../ProductInMultipleStoresCacheTest.php | 28 +++++++++---------- 2 files changed, 25 insertions(+), 22 deletions(-) diff --git a/dev/tests/api-functional/testsuite/Magento/GraphQl/Catalog/ProductInMultipleStoresTest.php b/dev/tests/api-functional/testsuite/Magento/GraphQl/Catalog/ProductInMultipleStoresTest.php index d17b434f39d9f..d26afd4287819 100644 --- a/dev/tests/api-functional/testsuite/Magento/GraphQl/Catalog/ProductInMultipleStoresTest.php +++ b/dev/tests/api-functional/testsuite/Magento/GraphQl/Catalog/ProductInMultipleStoresTest.php @@ -8,10 +8,13 @@ namespace Magento\GraphQl\Catalog; use Magento\TestFramework\ObjectManager; +use Magento\TestFramework\TestCase\GraphQl\ResponseContainsErrorsException; use Magento\TestFramework\TestCase\GraphQlAbstract; /** - * Class ProductInMultipleStoresTest + * Class for ProductInMultipleStoresTest + * + * @magentoAppIsolation enabled */ class ProductInMultipleStoresTest extends GraphQlAbstract { @@ -74,6 +77,13 @@ public function testProductFromSpecificAndDefaultStore() 'Product name in fixture store is invalid.' ); + // use case for invalid storeCode + $nonExistingStoreCode = "non_existent_store"; + $headerMapInvalidStoreCode = ['Store' => $nonExistingStoreCode]; + $this->expectException(ResponseContainsErrorsException::class); + $this->expectExceptionMessage('Requested store is not found'); + $this->graphQlQuery($query, [], '', $headerMapInvalidStoreCode); + //use case for default storeCode $nameInDefaultStore = 'Simple Product'; $headerMapDefault = ['Store' => 'default']; @@ -92,12 +102,5 @@ public function testProductFromSpecificAndDefaultStore() $response['products']['items'][0]['name'], 'Product in the default store should be returned' ); - - // use case for invalid storeCode - $nonExistingStoreCode = "non_existent_store"; - $headerMapInvalidStoreCode = ['Store' => $nonExistingStoreCode]; - $this->expectException(\Exception::class); - $this->expectExceptionMessage('Requested store is not found'); - $this->graphQlQuery($query, [], '', $headerMapInvalidStoreCode); } } diff --git a/dev/tests/api-functional/testsuite/Magento/GraphQl/PageCache/ProductInMultipleStoresCacheTest.php b/dev/tests/api-functional/testsuite/Magento/GraphQl/PageCache/ProductInMultipleStoresCacheTest.php index cf4cebdfe8e44..3bc1096db87c0 100644 --- a/dev/tests/api-functional/testsuite/Magento/GraphQl/PageCache/ProductInMultipleStoresCacheTest.php +++ b/dev/tests/api-functional/testsuite/Magento/GraphQl/PageCache/ProductInMultipleStoresCacheTest.php @@ -271,7 +271,7 @@ public function testProductFromSpecificAndDefaultStoreWithMultiCurrency() ); // test non cached store + currency header in USD not cached - $headerMap = ['Store' => 'default', 'Content-Currency' => 'USD']; + $headerMap = ['Store' => 'default', 'Content-Currency' => 'EUR']; $response = $this->graphQlQuery($query, [], '', $headerMap); $this->assertEquals( 'Simple Product', @@ -279,13 +279,20 @@ public function testProductFromSpecificAndDefaultStoreWithMultiCurrency() 'Product name in fixture store is invalid.' ); $this->assertEquals( - 'USD', + 'EUR', $response['products']['items'][0]['price']['minimalPrice']['amount']['currency'], - 'Currency code USD in fixture store default is unexpected' + 'Currency code EUR in fixture store default is unexpected' ); + // test cached response store + currency header with non existing currency, and no valid response, no cache + $headerMap = ['Store' => $storeCodeFromFixture, 'Content-Currency' => 'SOMECURRENCY']; + $this->expectExceptionMessage( + 'GraphQL response contains errors: Please correct the target currency' + ); + $this->graphQlQuery($query, [], '', $headerMap); + // test non cached store + currency header in USD not cached - $headerMap = ['Store' => 'default', 'Content-Currency' => 'EUR']; + $headerMap = ['Store' => 'default', 'Content-Currency' => 'USD']; $response = $this->graphQlQuery($query, [], '', $headerMap); $this->assertEquals( 'Simple Product', @@ -293,12 +300,12 @@ public function testProductFromSpecificAndDefaultStoreWithMultiCurrency() 'Product name in fixture store is invalid.' ); $this->assertEquals( - 'EUR', + 'USD', $response['products']['items'][0]['price']['minimalPrice']['amount']['currency'], - 'Currency code EUR in fixture store default is unexpected' + 'Currency code USD in fixture store default is unexpected' ); - // test non cached store + currency header in USD cached + // test non cached store + currency header in USD cached $headerMap = ['Store' => 'default']; $response = $this->graphQlQuery($query, [], '', $headerMap); $this->assertEquals( @@ -311,12 +318,5 @@ public function testProductFromSpecificAndDefaultStoreWithMultiCurrency() $response['products']['items'][0]['price']['minimalPrice']['amount']['currency'], 'Currency code USD in fixture store default is unexpected' ); - - // test cached response store + currency header with non existing currency, and no valid response, no cache - $headerMap = ['Store' => $storeCodeFromFixture, 'Content-Currency' => 'SOMECURRENCY']; - $this->expectExceptionMessage( - 'GraphQL response contains errors: Please correct the target currency' - ); - $this->graphQlQuery($query, [], '', $headerMap); } } From 4a05e7864ae1621dff12469cc8395ebace13699e Mon Sep 17 00:00:00 2001 From: Ihor Sviziev Date: Fri, 3 Apr 2020 22:29:15 +0300 Subject: [PATCH 03/11] #7213 prevent pointless session start in webapi scope --- app/code/Magento/PageCache/etc/frontend/di.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/code/Magento/PageCache/etc/frontend/di.xml b/app/code/Magento/PageCache/etc/frontend/di.xml index 5eaa650a0fc77..1aaa331da7025 100644 --- a/app/code/Magento/PageCache/etc/frontend/di.xml +++ b/app/code/Magento/PageCache/etc/frontend/di.xml @@ -9,7 +9,7 @@ - + From cfa889ef339d9ab826eff143d25a6a4b8ec39b20 Mon Sep 17 00:00:00 2001 From: Alexander Steshuk Date: Tue, 7 Apr 2020 11:41:54 +0300 Subject: [PATCH 04/11] Fixed tests. --- .../Catalog/ProductInMultipleStoresTest.php | 27 ++++++++--- .../ProductInMultipleStoresCacheTest.php | 47 ++++++++++++++----- 2 files changed, 54 insertions(+), 20 deletions(-) diff --git a/dev/tests/api-functional/testsuite/Magento/GraphQl/Catalog/ProductInMultipleStoresTest.php b/dev/tests/api-functional/testsuite/Magento/GraphQl/Catalog/ProductInMultipleStoresTest.php index d26afd4287819..2c07ca4ee096b 100644 --- a/dev/tests/api-functional/testsuite/Magento/GraphQl/Catalog/ProductInMultipleStoresTest.php +++ b/dev/tests/api-functional/testsuite/Magento/GraphQl/Catalog/ProductInMultipleStoresTest.php @@ -7,8 +7,8 @@ namespace Magento\GraphQl\Catalog; +use Magento\PageCache\Model\Cache\Type as PageCache; use Magento\TestFramework\ObjectManager; -use Magento\TestFramework\TestCase\GraphQl\ResponseContainsErrorsException; use Magento\TestFramework\TestCase\GraphQlAbstract; /** @@ -77,12 +77,7 @@ public function testProductFromSpecificAndDefaultStore() 'Product name in fixture store is invalid.' ); - // use case for invalid storeCode - $nonExistingStoreCode = "non_existent_store"; - $headerMapInvalidStoreCode = ['Store' => $nonExistingStoreCode]; - $this->expectException(ResponseContainsErrorsException::class); - $this->expectExceptionMessage('Requested store is not found'); - $this->graphQlQuery($query, [], '', $headerMapInvalidStoreCode); + $this->flushPageCache(); //use case for default storeCode $nameInDefaultStore = 'Simple Product'; @@ -94,6 +89,8 @@ public function testProductFromSpecificAndDefaultStore() 'Product name in default store is invalid.' ); + $this->flushPageCache(); + //use case for empty storeCode $headerMapEmpty = ['Store' => '']; $response = $this->graphQlQuery($query, [], '', $headerMapEmpty); @@ -102,5 +99,21 @@ public function testProductFromSpecificAndDefaultStore() $response['products']['items'][0]['name'], 'Product in the default store should be returned' ); + + $this->flushPageCache(); + + // use case for invalid storeCode + $nonExistingStoreCode = "non_existent_store"; + $headerMapInvalidStoreCode = ['Store' => $nonExistingStoreCode]; + $this->expectException(\Exception::class); + $this->expectExceptionMessage('Requested store is not found'); + $this->graphQlQuery($query, [], '', $headerMapInvalidStoreCode); + } + + protected function flushPageCache(): void + { + /** @var PageCache $fullPageCache */ + $fullPageCache = ObjectManager::getInstance()->get(PageCache::class); + $fullPageCache->clean(); } } diff --git a/dev/tests/api-functional/testsuite/Magento/GraphQl/PageCache/ProductInMultipleStoresCacheTest.php b/dev/tests/api-functional/testsuite/Magento/GraphQl/PageCache/ProductInMultipleStoresCacheTest.php index 3bc1096db87c0..6736b34ae3a99 100644 --- a/dev/tests/api-functional/testsuite/Magento/GraphQl/PageCache/ProductInMultipleStoresCacheTest.php +++ b/dev/tests/api-functional/testsuite/Magento/GraphQl/PageCache/ProductInMultipleStoresCacheTest.php @@ -7,6 +7,7 @@ namespace Magento\GraphQl\PageCache; +use Magento\PageCache\Model\Cache\Type as PageCache; use Magento\TestFramework\ObjectManager; use Magento\TestFramework\TestCase\GraphQlAbstract; @@ -242,6 +243,8 @@ public function testProductFromSpecificAndDefaultStoreWithMultiCurrency() 'Currency code EUR in fixture ' . $storeCodeFromFixture . ' is unexpected' ); + $this->flushPageCache(); + // test cached store + currency header in Euros $headerMap = ['Store' => $storeCodeFromFixture, 'Content-Currency' => 'EUR']; $response = $this->graphQlQuery($query, [], '', $headerMap); @@ -256,6 +259,8 @@ public function testProductFromSpecificAndDefaultStoreWithMultiCurrency() 'Currency code EUR in fixture ' . $storeCodeFromFixture . ' is unexpected' ); + $this->flushPageCache(); + // test non cached store + currency header in USD $headerMap = ['Store' => $storeCodeFromFixture, 'Content-Currency' => 'USD']; $response = $this->graphQlQuery($query, [], '', $headerMap); @@ -270,8 +275,10 @@ public function testProductFromSpecificAndDefaultStoreWithMultiCurrency() 'Currency code USD in fixture ' . $storeCodeFromFixture . ' is unexpected' ); + $this->flushPageCache(); + // test non cached store + currency header in USD not cached - $headerMap = ['Store' => 'default', 'Content-Currency' => 'EUR']; + $headerMap = ['Store' => 'default', 'Content-Currency' => 'USD']; $response = $this->graphQlQuery($query, [], '', $headerMap); $this->assertEquals( 'Simple Product', @@ -279,20 +286,15 @@ public function testProductFromSpecificAndDefaultStoreWithMultiCurrency() 'Product name in fixture store is invalid.' ); $this->assertEquals( - 'EUR', + 'USD', $response['products']['items'][0]['price']['minimalPrice']['amount']['currency'], - 'Currency code EUR in fixture store default is unexpected' + 'Currency code USD in fixture store default is unexpected' ); - // test cached response store + currency header with non existing currency, and no valid response, no cache - $headerMap = ['Store' => $storeCodeFromFixture, 'Content-Currency' => 'SOMECURRENCY']; - $this->expectExceptionMessage( - 'GraphQL response contains errors: Please correct the target currency' - ); - $this->graphQlQuery($query, [], '', $headerMap); + $this->flushPageCache(); // test non cached store + currency header in USD not cached - $headerMap = ['Store' => 'default', 'Content-Currency' => 'USD']; + $headerMap = ['Store' => 'default', 'Content-Currency' => 'EUR']; $response = $this->graphQlQuery($query, [], '', $headerMap); $this->assertEquals( 'Simple Product', @@ -300,12 +302,14 @@ public function testProductFromSpecificAndDefaultStoreWithMultiCurrency() 'Product name in fixture store is invalid.' ); $this->assertEquals( - 'USD', + 'EUR', $response['products']['items'][0]['price']['minimalPrice']['amount']['currency'], - 'Currency code USD in fixture store default is unexpected' + 'Currency code EUR in fixture store default is unexpected' ); - // test non cached store + currency header in USD cached + $this->flushPageCache(); + + // test non cached store + currency header in USD cached $headerMap = ['Store' => 'default']; $response = $this->graphQlQuery($query, [], '', $headerMap); $this->assertEquals( @@ -318,5 +322,22 @@ public function testProductFromSpecificAndDefaultStoreWithMultiCurrency() $response['products']['items'][0]['price']['minimalPrice']['amount']['currency'], 'Currency code USD in fixture store default is unexpected' ); + + $this->flushPageCache(); + + // test cached response store + currency header with non existing currency, and no valid response, no cache + $headerMap = ['Store' => $storeCodeFromFixture, 'Content-Currency' => 'SOMECURRENCY']; + $this->expectExceptionMessage( + 'GraphQL response contains errors: Please correct the target currency' + ); + + $this->graphQlQuery($query, [], '', $headerMap); + } + + protected function flushPageCache(): void + { + /** @var PageCache $fullPageCache */ + $fullPageCache = ObjectManager::getInstance()->get(PageCache::class); + $fullPageCache->clean(); } } From b219c4e8a260bd6742a0d19954aa157791ac6727 Mon Sep 17 00:00:00 2001 From: Alexander Steshuk Date: Tue, 14 Apr 2020 15:53:08 +0300 Subject: [PATCH 05/11] Added test for API functional. Check for non exist cookie PHPSESSID, for non exist session of REST call. --- .../Magento/Webapi/RestSessionCookieTest.php | 55 +++++++++++++++++++ 1 file changed, 55 insertions(+) create mode 100644 dev/tests/api-functional/testsuite/Magento/Webapi/RestSessionCookieTest.php diff --git a/dev/tests/api-functional/testsuite/Magento/Webapi/RestSessionCookieTest.php b/dev/tests/api-functional/testsuite/Magento/Webapi/RestSessionCookieTest.php new file mode 100644 index 0000000000000..9f297c5da252f --- /dev/null +++ b/dev/tests/api-functional/testsuite/Magento/Webapi/RestSessionCookieTest.php @@ -0,0 +1,55 @@ +_markTestAsRestOnly(); + /** @var $curlClient CurlClientWithCookies */ + + $curlClient = Bootstrap::getObjectManager() + ->get(\Magento\TestFramework\TestCase\HttpClient\CurlClientWithCookies::class); + $phpSessionCookieName = + [ + 'cookie_name' => 'PHPSESSID', + ]; + + $response = $curlClient->get('/rest/V1/directory/countries', []); + + $cookie = $this->findCookie($phpSessionCookieName['cookie_name'], $response['cookies']); + $this->assertNull($cookie); + } + + /** + * Find cookie with given name in the list of cookies + * + * @param string $cookieName + * @param array $cookies + * @return $cookie|null + * @SuppressWarnings(PHPMD.UnusedLocalVariable) + */ + private function findCookie($cookieName, $cookies) + { + foreach ($cookies as $cookieIndex => $cookie) { + if ($cookie['name'] === $cookieName) { + return $cookie; + } + } + return null; + } +} From c5ad40b08a573abe2a860ad9878c89d56addb3a0 Mon Sep 17 00:00:00 2001 From: Alexander Steshuk Date: Wed, 15 Apr 2020 12:39:56 +0300 Subject: [PATCH 06/11] Rename for test --- .../testsuite/Magento/Webapi/RestSessionCookieTest.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dev/tests/api-functional/testsuite/Magento/Webapi/RestSessionCookieTest.php b/dev/tests/api-functional/testsuite/Magento/Webapi/RestSessionCookieTest.php index 9f297c5da252f..e2c220164470f 100644 --- a/dev/tests/api-functional/testsuite/Magento/Webapi/RestSessionCookieTest.php +++ b/dev/tests/api-functional/testsuite/Magento/Webapi/RestSessionCookieTest.php @@ -17,7 +17,7 @@ class RestSessionCookieTest extends \Magento\TestFramework\TestCase\WebapiAbstra /** * Check for non exist cookie PHPSESSID */ - public function testRestNoAcceptHeader() + public function testRestSessionNoCookie() { $this->_markTestAsRestOnly(); /** @var $curlClient CurlClientWithCookies */ From ac0dea54914ecab82eb17a1584d4ee38c686ce9c Mon Sep 17 00:00:00 2001 From: Alexander Steshuk Date: Fri, 22 May 2020 16:59:45 +0300 Subject: [PATCH 07/11] Corrects for Test. --- .../Magento/Webapi/RestSessionCookieTest.php | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/dev/tests/api-functional/testsuite/Magento/Webapi/RestSessionCookieTest.php b/dev/tests/api-functional/testsuite/Magento/Webapi/RestSessionCookieTest.php index e2c220164470f..36dc7a9afeba0 100644 --- a/dev/tests/api-functional/testsuite/Magento/Webapi/RestSessionCookieTest.php +++ b/dev/tests/api-functional/testsuite/Magento/Webapi/RestSessionCookieTest.php @@ -6,6 +6,7 @@ namespace Magento\Webapi; +use Magento\Framework\Module\Manager; use Magento\TestFramework\Helper\Bootstrap; /** @@ -14,6 +15,21 @@ class RestSessionCookieTest extends \Magento\TestFramework\TestCase\WebapiAbstract { + private $moduleManager; + private $objectManager; + + /** + * @inheritdoc + */ + protected function setUp(): void + { + $this->objectManager = Bootstrap::getObjectManager(); + $this->moduleManager = $this->objectManager->get(Manager::class); + if ($this->moduleManager->isEnabled('Magento_B2b')) { + $this->markTestSkipped('Skipped, because this logic is rewritten on B2B.'); + } + } + /** * Check for non exist cookie PHPSESSID */ @@ -22,7 +38,7 @@ public function testRestSessionNoCookie() $this->_markTestAsRestOnly(); /** @var $curlClient CurlClientWithCookies */ - $curlClient = Bootstrap::getObjectManager() + $curlClient = $this->objectManager ->get(\Magento\TestFramework\TestCase\HttpClient\CurlClientWithCookies::class); $phpSessionCookieName = [ From ac0f4e6c48642fbf4906c88e6210c1fa0d979469 Mon Sep 17 00:00:00 2001 From: Alexander Steshuk Date: Fri, 10 Jul 2020 16:53:49 +0300 Subject: [PATCH 08/11] Added etc/graphql/di.xml --- app/code/Magento/PageCache/etc/graphql/di.xml | 12 ++++++++++++ 1 file changed, 12 insertions(+) create mode 100644 app/code/Magento/PageCache/etc/graphql/di.xml diff --git a/app/code/Magento/PageCache/etc/graphql/di.xml b/app/code/Magento/PageCache/etc/graphql/di.xml new file mode 100644 index 0000000000000..c1f6647bba8f6 --- /dev/null +++ b/app/code/Magento/PageCache/etc/graphql/di.xml @@ -0,0 +1,12 @@ + + + + + + + From 3e833b3b9d4f472a8e1ddb7aac47949ed7054a13 Mon Sep 17 00:00:00 2001 From: Alexander Steshuk Date: Fri, 10 Jul 2020 16:54:47 +0300 Subject: [PATCH 09/11] Revert changes in Tests --- .../Catalog/ProductInMultipleStoresTest.php | 14 ------------- .../ProductInMultipleStoresCacheTest.php | 20 ------------------- 2 files changed, 34 deletions(-) diff --git a/dev/tests/api-functional/testsuite/Magento/GraphQl/Catalog/ProductInMultipleStoresTest.php b/dev/tests/api-functional/testsuite/Magento/GraphQl/Catalog/ProductInMultipleStoresTest.php index 2c07ca4ee096b..c2555cb4399f5 100644 --- a/dev/tests/api-functional/testsuite/Magento/GraphQl/Catalog/ProductInMultipleStoresTest.php +++ b/dev/tests/api-functional/testsuite/Magento/GraphQl/Catalog/ProductInMultipleStoresTest.php @@ -7,7 +7,6 @@ namespace Magento\GraphQl\Catalog; -use Magento\PageCache\Model\Cache\Type as PageCache; use Magento\TestFramework\ObjectManager; use Magento\TestFramework\TestCase\GraphQlAbstract; @@ -77,8 +76,6 @@ public function testProductFromSpecificAndDefaultStore() 'Product name in fixture store is invalid.' ); - $this->flushPageCache(); - //use case for default storeCode $nameInDefaultStore = 'Simple Product'; $headerMapDefault = ['Store' => 'default']; @@ -89,8 +86,6 @@ public function testProductFromSpecificAndDefaultStore() 'Product name in default store is invalid.' ); - $this->flushPageCache(); - //use case for empty storeCode $headerMapEmpty = ['Store' => '']; $response = $this->graphQlQuery($query, [], '', $headerMapEmpty); @@ -100,8 +95,6 @@ public function testProductFromSpecificAndDefaultStore() 'Product in the default store should be returned' ); - $this->flushPageCache(); - // use case for invalid storeCode $nonExistingStoreCode = "non_existent_store"; $headerMapInvalidStoreCode = ['Store' => $nonExistingStoreCode]; @@ -109,11 +102,4 @@ public function testProductFromSpecificAndDefaultStore() $this->expectExceptionMessage('Requested store is not found'); $this->graphQlQuery($query, [], '', $headerMapInvalidStoreCode); } - - protected function flushPageCache(): void - { - /** @var PageCache $fullPageCache */ - $fullPageCache = ObjectManager::getInstance()->get(PageCache::class); - $fullPageCache->clean(); - } } diff --git a/dev/tests/api-functional/testsuite/Magento/GraphQl/PageCache/ProductInMultipleStoresCacheTest.php b/dev/tests/api-functional/testsuite/Magento/GraphQl/PageCache/ProductInMultipleStoresCacheTest.php index 0e512d2575a92..92a6b80642272 100644 --- a/dev/tests/api-functional/testsuite/Magento/GraphQl/PageCache/ProductInMultipleStoresCacheTest.php +++ b/dev/tests/api-functional/testsuite/Magento/GraphQl/PageCache/ProductInMultipleStoresCacheTest.php @@ -7,7 +7,6 @@ namespace Magento\GraphQl\PageCache; -use Magento\PageCache\Model\Cache\Type as PageCache; use Magento\TestFramework\ObjectManager; use Magento\TestFramework\TestCase\GraphQlAbstract; @@ -243,8 +242,6 @@ public function testProductFromSpecificAndDefaultStoreWithMultiCurrency() 'Currency code EUR in fixture ' . $storeCodeFromFixture . ' is unexpected' ); - $this->flushPageCache(); - // test cached store + currency header in Euros $headerMap = ['Store' => $storeCodeFromFixture, 'Content-Currency' => 'EUR']; $response = $this->graphQlQuery($query, [], '', $headerMap); @@ -259,8 +256,6 @@ public function testProductFromSpecificAndDefaultStoreWithMultiCurrency() 'Currency code EUR in fixture ' . $storeCodeFromFixture . ' is unexpected' ); - $this->flushPageCache(); - // test non cached store + currency header in USD $headerMap = ['Store' => $storeCodeFromFixture, 'Content-Currency' => 'USD']; $response = $this->graphQlQuery($query, [], '', $headerMap); @@ -275,8 +270,6 @@ public function testProductFromSpecificAndDefaultStoreWithMultiCurrency() 'Currency code USD in fixture ' . $storeCodeFromFixture . ' is unexpected' ); - $this->flushPageCache(); - // test non cached store + currency header in USD not cached $headerMap = ['Store' => 'default', 'Content-Currency' => 'USD']; $response = $this->graphQlQuery($query, [], '', $headerMap); @@ -291,8 +284,6 @@ public function testProductFromSpecificAndDefaultStoreWithMultiCurrency() 'Currency code USD in fixture store default is unexpected' ); - $this->flushPageCache(); - // test non cached store + currency header in USD not cached $headerMap = ['Store' => 'default', 'Content-Currency' => 'EUR']; $response = $this->graphQlQuery($query, [], '', $headerMap); @@ -307,8 +298,6 @@ public function testProductFromSpecificAndDefaultStoreWithMultiCurrency() 'Currency code EUR in fixture store default is unexpected' ); - $this->flushPageCache(); - // test non cached store + currency header in USD cached $headerMap = ['Store' => 'default']; $response = $this->graphQlQuery($query, [], '', $headerMap); @@ -323,21 +312,12 @@ public function testProductFromSpecificAndDefaultStoreWithMultiCurrency() 'Currency code USD in fixture store default is unexpected' ); - $this->flushPageCache(); - // test cached response store + currency header with non existing currency, and no valid response, no cache $headerMap = ['Store' => $storeCodeFromFixture, 'Content-Currency' => 'SOMECURRENCY']; $this->expectExceptionMessage( 'GraphQL response contains errors: Please correct the target currency' ); - $this->graphQlQuery($query, [], '', $headerMap); } - protected function flushPageCache(): void - { - /** @var PageCache $fullPageCache */ - $fullPageCache = ObjectManager::getInstance()->get(PageCache::class); - $fullPageCache->clean(); - } } From c1f5509be14c507b71ca7fd9a036ff5b86dbe71c Mon Sep 17 00:00:00 2001 From: Alexander Steshuk Date: Fri, 10 Jul 2020 16:56:42 +0300 Subject: [PATCH 10/11] Revert changes in Tests --- .../Magento/GraphQl/Catalog/ProductInMultipleStoresTest.php | 4 +--- .../GraphQl/PageCache/ProductInMultipleStoresCacheTest.php | 1 - 2 files changed, 1 insertion(+), 4 deletions(-) diff --git a/dev/tests/api-functional/testsuite/Magento/GraphQl/Catalog/ProductInMultipleStoresTest.php b/dev/tests/api-functional/testsuite/Magento/GraphQl/Catalog/ProductInMultipleStoresTest.php index c2555cb4399f5..d17b434f39d9f 100644 --- a/dev/tests/api-functional/testsuite/Magento/GraphQl/Catalog/ProductInMultipleStoresTest.php +++ b/dev/tests/api-functional/testsuite/Magento/GraphQl/Catalog/ProductInMultipleStoresTest.php @@ -11,9 +11,7 @@ use Magento\TestFramework\TestCase\GraphQlAbstract; /** - * Class for ProductInMultipleStoresTest - * - * @magentoAppIsolation enabled + * Class ProductInMultipleStoresTest */ class ProductInMultipleStoresTest extends GraphQlAbstract { diff --git a/dev/tests/api-functional/testsuite/Magento/GraphQl/PageCache/ProductInMultipleStoresCacheTest.php b/dev/tests/api-functional/testsuite/Magento/GraphQl/PageCache/ProductInMultipleStoresCacheTest.php index 92a6b80642272..20a612e9f88b0 100644 --- a/dev/tests/api-functional/testsuite/Magento/GraphQl/PageCache/ProductInMultipleStoresCacheTest.php +++ b/dev/tests/api-functional/testsuite/Magento/GraphQl/PageCache/ProductInMultipleStoresCacheTest.php @@ -319,5 +319,4 @@ public function testProductFromSpecificAndDefaultStoreWithMultiCurrency() ); $this->graphQlQuery($query, [], '', $headerMap); } - } From 4dac67dbf06550a1e36f2e463dad8b8f3e36a457 Mon Sep 17 00:00:00 2001 From: Alexander Steshuk Date: Mon, 27 Jul 2020 18:49:24 +0300 Subject: [PATCH 11/11] Fix typo. --- app/code/Magento/PageCache/etc/graphql/di.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/code/Magento/PageCache/etc/graphql/di.xml b/app/code/Magento/PageCache/etc/graphql/di.xml index c1f6647bba8f6..93714465f4d72 100644 --- a/app/code/Magento/PageCache/etc/graphql/di.xml +++ b/app/code/Magento/PageCache/etc/graphql/di.xml @@ -7,6 +7,6 @@ --> - +