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); } }