|
| 1 | +<?php |
| 2 | +/** |
| 3 | + * Copyright © Magento, Inc. All rights reserved. |
| 4 | + * See COPYING.txt for license details. |
| 5 | + */ |
| 6 | +declare(strict_types=1); |
| 7 | + |
| 8 | +namespace Magento\GraphQl\Tax; |
| 9 | + |
| 10 | +use Magento\Directory\Helper\Data; |
| 11 | +use Magento\Store\Model\ScopeInterface; |
| 12 | +use Magento\TestFramework\Fixture\Config as ConfigFixture; |
| 13 | +use Magento\TestFramework\TestCase\GraphQlAbstract; |
| 14 | +use Magento\Tax\Model\Config; |
| 15 | + |
| 16 | +/** |
| 17 | + * Test the GraphQL endpoint's StoreConfigs query |
| 18 | + */ |
| 19 | +class StoreConfigResolverTest extends GraphQlAbstract |
| 20 | +{ |
| 21 | + #[ |
| 22 | + ConfigFixture(Config::XML_PATH_DISPLAY_CART_PRICE, 1, ScopeInterface::SCOPE_STORE, 'default'), |
| 23 | + ConfigFixture(Config::XML_PATH_DISPLAY_CART_SHIPPING, 1, ScopeInterface::SCOPE_STORE, 'default'), |
| 24 | + ConfigFixture(Config::XML_PATH_DISPLAY_CART_SUBTOTAL, 1, ScopeInterface::SCOPE_STORE, 'default'), |
| 25 | + ConfigFixture(Config::XML_PATH_DISPLAY_CART_GRANDTOTAL, 1, ScopeInterface::SCOPE_STORE, 'default'), |
| 26 | + ConfigFixture(Config::XML_PATH_DISPLAY_CART_FULL_SUMMARY, 1, ScopeInterface::SCOPE_STORE, 'default'), |
| 27 | + ConfigFixture(Config::XML_PATH_DISPLAY_CART_ZERO_TAX, 1, ScopeInterface::SCOPE_STORE, 'default'), |
| 28 | + ] |
| 29 | + public function testGetStoreConfig(): void |
| 30 | + { |
| 31 | + $query |
| 32 | + = <<<QUERY |
| 33 | +{ |
| 34 | + storeConfig { |
| 35 | + shopping_cart_display_price, |
| 36 | + shopping_cart_display_shipping, |
| 37 | + shopping_cart_display_subtotal, |
| 38 | + shopping_cart_display_grand_total, |
| 39 | + shopping_cart_display_full_summary, |
| 40 | + shopping_cart_display_zero_tax, |
| 41 | + } |
| 42 | +} |
| 43 | +QUERY; |
| 44 | + $response = $this->graphQlQuery($query); |
| 45 | + $this->assertArrayHasKey('storeConfig', $response); |
| 46 | + $this->validateStoreConfig($response['storeConfig']); |
| 47 | + } |
| 48 | + |
| 49 | + /** |
| 50 | + * Validate Store Config Data |
| 51 | + * |
| 52 | + * @param array $responseConfig |
| 53 | + */ |
| 54 | + private function validateStoreConfig( |
| 55 | + array $responseConfig, |
| 56 | + ): void { |
| 57 | + $this->assertEquals(1, $responseConfig['shopping_cart_display_price']); |
| 58 | + $this->assertEquals(1, $responseConfig['shopping_cart_display_shipping']); |
| 59 | + $this->assertEquals(1, $responseConfig['shopping_cart_display_subtotal']); |
| 60 | + $this->assertEquals(1, $responseConfig['shopping_cart_display_grand_total']); |
| 61 | + $this->assertEquals(1, $responseConfig['shopping_cart_display_full_summary']); |
| 62 | + $this->assertEquals(1, $responseConfig['shopping_cart_display_zero_tax']); |
| 63 | + } |
| 64 | +} |
0 commit comments