|
| 1 | +<?php |
| 2 | +/** |
| 3 | + * Copyright 2024 Adobe |
| 4 | + * All Rights Reserved. |
| 5 | + */ |
| 6 | +declare(strict_types=1); |
| 7 | + |
| 8 | +namespace Magento\GraphQl\Sales; |
| 9 | + |
| 10 | +use Exception; |
| 11 | +use Magento\TestFramework\TestCase\GraphQlAbstract; |
| 12 | + |
| 13 | +class SalesTaxStoreConfigTest extends GraphQlAbstract |
| 14 | +{ |
| 15 | + private const CONFIG_KEYS = [ |
| 16 | + 'display_product_prices_in_catalog', |
| 17 | + 'display_shipping_prices', |
| 18 | + 'orders_invoices_credit_memos_display_price', |
| 19 | + 'orders_invoices_credit_memos_display_subtotal', |
| 20 | + 'orders_invoices_credit_memos_display_shipping_amount', |
| 21 | + 'orders_invoices_credit_memos_display_grandtotal', |
| 22 | + 'orders_invoices_credit_memos_display_full_summary', |
| 23 | + 'orders_invoices_credit_memos_display_zero_tax', |
| 24 | + 'fixed_product_taxes_enable', |
| 25 | + 'fixed_product_taxes_display_prices_in_product_lists', |
| 26 | + 'fixed_product_taxes_display_prices_on_product_view_page', |
| 27 | + 'fixed_product_taxes_display_prices_in_sales_modules', |
| 28 | + 'fixed_product_taxes_display_prices_in_emails', |
| 29 | + 'fixed_product_taxes_apply_tax_to_fpt', |
| 30 | + 'fixed_product_taxes_include_fpt_in_subtotal', |
| 31 | + ]; |
| 32 | + /** |
| 33 | + * @throws Exception |
| 34 | + */ |
| 35 | + public function testSalesTaxStoreConfigExists() |
| 36 | + { |
| 37 | + $response = $this->graphQlQuery($this->getQuery()); |
| 38 | + $this->assertArrayHasKey('storeConfig', $response); |
| 39 | + $this->assertStoreConfigsExist($response['storeConfig']); |
| 40 | + } |
| 41 | + |
| 42 | + /** |
| 43 | + * Check if all the added store configs are returned in graphql response |
| 44 | + * |
| 45 | + * @param array $response |
| 46 | + * @return void |
| 47 | + */ |
| 48 | + private function assertStoreConfigsExist(array $response): void |
| 49 | + { |
| 50 | + foreach (self::CONFIG_KEYS as $key) { |
| 51 | + $this->assertArrayHasKey($key, $response); |
| 52 | + } |
| 53 | + } |
| 54 | + |
| 55 | + /** |
| 56 | + * Generates storeConfig query with newly added configurations from sales->tax |
| 57 | + * |
| 58 | + * @return string |
| 59 | + */ |
| 60 | + private function getQuery(): string |
| 61 | + { |
| 62 | + return <<<QUERY |
| 63 | + { |
| 64 | + storeConfig { |
| 65 | + display_product_prices_in_catalog |
| 66 | + display_shipping_prices |
| 67 | + orders_invoices_credit_memos_display_price |
| 68 | + orders_invoices_credit_memos_display_subtotal |
| 69 | + orders_invoices_credit_memos_display_shipping_amount |
| 70 | + orders_invoices_credit_memos_display_grandtotal |
| 71 | + orders_invoices_credit_memos_display_full_summary |
| 72 | + orders_invoices_credit_memos_display_zero_tax |
| 73 | + fixed_product_taxes_enable |
| 74 | + fixed_product_taxes_display_prices_in_product_lists |
| 75 | + fixed_product_taxes_display_prices_on_product_view_page |
| 76 | + fixed_product_taxes_display_prices_in_sales_modules |
| 77 | + fixed_product_taxes_display_prices_in_emails |
| 78 | + fixed_product_taxes_apply_tax_to_fpt |
| 79 | + fixed_product_taxes_include_fpt_in_subtotal |
| 80 | + } |
| 81 | + } |
| 82 | + QUERY; |
| 83 | + } |
| 84 | +} |
0 commit comments