Skip to content

Commit 8aed39f

Browse files
engcom-KiloMaciej Pawłowski
authored and
Maciej Pawłowski
committed
magento2/pull/26032: Fix api-functional tests
1 parent 859307b commit 8aed39f

File tree

2 files changed

+25
-22
lines changed

2 files changed

+25
-22
lines changed

dev/tests/api-functional/testsuite/Magento/GraphQl/Catalog/ProductInMultipleStoresTest.php

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,13 @@
88
namespace Magento\GraphQl\Catalog;
99

1010
use Magento\TestFramework\ObjectManager;
11+
use Magento\TestFramework\TestCase\GraphQl\ResponseContainsErrorsException;
1112
use Magento\TestFramework\TestCase\GraphQlAbstract;
1213

1314
/**
14-
* Class ProductInMultipleStoresTest
15+
* Class for ProductInMultipleStoresTest
16+
*
17+
* @magentoAppIsolation enabled
1518
*/
1619
class ProductInMultipleStoresTest extends GraphQlAbstract
1720
{
@@ -74,6 +77,13 @@ public function testProductFromSpecificAndDefaultStore()
7477
'Product name in fixture store is invalid.'
7578
);
7679

80+
// use case for invalid storeCode
81+
$nonExistingStoreCode = "non_existent_store";
82+
$headerMapInvalidStoreCode = ['Store' => $nonExistingStoreCode];
83+
$this->expectException(ResponseContainsErrorsException::class);
84+
$this->expectExceptionMessage('Requested store is not found');
85+
$this->graphQlQuery($query, [], '', $headerMapInvalidStoreCode);
86+
7787
//use case for default storeCode
7888
$nameInDefaultStore = 'Simple Product';
7989
$headerMapDefault = ['Store' => 'default'];
@@ -92,12 +102,5 @@ public function testProductFromSpecificAndDefaultStore()
92102
$response['products']['items'][0]['name'],
93103
'Product in the default store should be returned'
94104
);
95-
96-
// use case for invalid storeCode
97-
$nonExistingStoreCode = "non_existent_store";
98-
$headerMapInvalidStoreCode = ['Store' => $nonExistingStoreCode];
99-
$this->expectException(\Exception::class);
100-
$this->expectExceptionMessage('Requested store is not found');
101-
$this->graphQlQuery($query, [], '', $headerMapInvalidStoreCode);
102105
}
103106
}

dev/tests/api-functional/testsuite/Magento/GraphQl/PageCache/ProductInMultipleStoresCacheTest.php

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -271,34 +271,41 @@ public function testProductFromSpecificAndDefaultStoreWithMultiCurrency()
271271
);
272272

273273
// test non cached store + currency header in USD not cached
274-
$headerMap = ['Store' => 'default', 'Content-Currency' => 'USD'];
274+
$headerMap = ['Store' => 'default', 'Content-Currency' => 'EUR'];
275275
$response = $this->graphQlQuery($query, [], '', $headerMap);
276276
$this->assertEquals(
277277
'Simple Product',
278278
$response['products']['items'][0]['name'],
279279
'Product name in fixture store is invalid.'
280280
);
281281
$this->assertEquals(
282-
'USD',
282+
'EUR',
283283
$response['products']['items'][0]['price']['minimalPrice']['amount']['currency'],
284-
'Currency code USD in fixture store default is unexpected'
284+
'Currency code EUR in fixture store default is unexpected'
285285
);
286286

287+
// test cached response store + currency header with non existing currency, and no valid response, no cache
288+
$headerMap = ['Store' => $storeCodeFromFixture, 'Content-Currency' => 'SOMECURRENCY'];
289+
$this->expectExceptionMessage(
290+
'GraphQL response contains errors: Please correct the target currency'
291+
);
292+
$this->graphQlQuery($query, [], '', $headerMap);
293+
287294
// test non cached store + currency header in USD not cached
288-
$headerMap = ['Store' => 'default', 'Content-Currency' => 'EUR'];
295+
$headerMap = ['Store' => 'default', 'Content-Currency' => 'USD'];
289296
$response = $this->graphQlQuery($query, [], '', $headerMap);
290297
$this->assertEquals(
291298
'Simple Product',
292299
$response['products']['items'][0]['name'],
293300
'Product name in fixture store is invalid.'
294301
);
295302
$this->assertEquals(
296-
'EUR',
303+
'USD',
297304
$response['products']['items'][0]['price']['minimalPrice']['amount']['currency'],
298-
'Currency code EUR in fixture store default is unexpected'
305+
'Currency code USD in fixture store default is unexpected'
299306
);
300307

301-
// test non cached store + currency header in USD cached
308+
// test non cached store + currency header in USD cached
302309
$headerMap = ['Store' => 'default'];
303310
$response = $this->graphQlQuery($query, [], '', $headerMap);
304311
$this->assertEquals(
@@ -311,12 +318,5 @@ public function testProductFromSpecificAndDefaultStoreWithMultiCurrency()
311318
$response['products']['items'][0]['price']['minimalPrice']['amount']['currency'],
312319
'Currency code USD in fixture store default is unexpected'
313320
);
314-
315-
// test cached response store + currency header with non existing currency, and no valid response, no cache
316-
$headerMap = ['Store' => $storeCodeFromFixture, 'Content-Currency' => 'SOMECURRENCY'];
317-
$this->expectExceptionMessage(
318-
'GraphQL response contains errors: Please correct the target currency'
319-
);
320-
$this->graphQlQuery($query, [], '', $headerMap);
321321
}
322322
}

0 commit comments

Comments
 (0)