Skip to content

Commit 05dacc6

Browse files
committed
MC-21491: Pricing :: FPT display settings
- fix test
1 parent 823599d commit 05dacc6

File tree

1 file changed

+59
-90
lines changed

1 file changed

+59
-90
lines changed

dev/tests/api-functional/testsuite/Magento/GraphQl/Weee/ProductPriceWithFPTTest.php

Lines changed: 59 additions & 90 deletions
Original file line numberDiff line numberDiff line change
@@ -27,12 +27,61 @@ class ProductPriceWithFPTTest extends GraphQlAbstract
2727
/** @var ObjectManager $objectManager */
2828
private $objectManager;
2929

30+
/** @var string[] $objectManager */
31+
private $initialConfig;
32+
33+
/** @var ScopeConfigInterface */
34+
private $scopeConfig;
35+
3036
/**
3137
* @inheritdoc
3238
*/
33-
protected function setUp() :void
39+
protected function setUp(): void
3440
{
3541
$this->objectManager = Bootstrap::getObjectManager();
42+
43+
/** @var ScopeConfigInterface $scopeConfig */
44+
$this->scopeConfig = $this->objectManager->get(ScopeConfigInterface::class);
45+
46+
$currentSettingsArray = [
47+
'tax/display/type',
48+
'tax/weee/enable',
49+
'tax/weee/display',
50+
'tax/defaults/region',
51+
'tax/weee/apply_vat',
52+
'tax/calculation/price_includes_tax'
53+
];
54+
55+
foreach ($currentSettingsArray as $configPath) {
56+
$this->initialConfig[$configPath] = $this->scopeConfig->getValue(
57+
$configPath
58+
);
59+
}
60+
}
61+
62+
/**
63+
* @inheritdoc
64+
*/
65+
protected function tearDown(): void
66+
{
67+
$this->writeConfig($this->initialConfig);
68+
}
69+
70+
/**
71+
* Write configuration for weee
72+
*
73+
* @param array $weeTaxSettings
74+
* @return void
75+
*/
76+
private function writeConfig(array $weeTaxSettings): void
77+
{
78+
/** @var WriterInterface $configWriter */
79+
$configWriter = $this->objectManager->get(WriterInterface::class);
80+
81+
foreach ($weeTaxSettings as $path => $value) {
82+
$configWriter->save($path, $value);
83+
}
84+
$this->scopeConfig->clean();
3685
}
3786

3887
/**
@@ -49,16 +98,7 @@ protected function setUp() :void
4998
*/
5099
public function testCatalogPriceExcludeTaxAndIncludeFPTOnly(array $weeTaxSettings)
51100
{
52-
/** @var WriterInterface $configWriter */
53-
$configWriter = $this->objectManager->get(WriterInterface::class);
54-
55-
foreach ($weeTaxSettings as $path => $value) {
56-
$configWriter->save($path, $value);
57-
}
58-
59-
/** @var ScopeConfigInterface $scopeConfig */
60-
$scopeConfig = $this->objectManager->get(ScopeConfigInterface::class);
61-
$scopeConfig->clean();
101+
$this->writeConfig($weeTaxSettings);
62102

63103
$skus = ['simple-with-ftp'];
64104
$query = $this->getProductQuery($skus);
@@ -115,16 +155,7 @@ public function catalogPriceExcludeTaxAndIncludeFPTOnlySettingsProvider()
115155
*/
116156
public function testCatalogPriceExcludeTaxAndIncludeFPTWithDescription(array $weeTaxSettings)
117157
{
118-
/** @var WriterInterface $configWriter */
119-
$configWriter = $this->objectManager->get(WriterInterface::class);
120-
121-
foreach ($weeTaxSettings as $path => $value) {
122-
$configWriter->save($path, $value);
123-
}
124-
125-
/** @var ScopeConfigInterface $scopeConfig */
126-
$scopeConfig = $this->objectManager->get(ScopeConfigInterface::class);
127-
$scopeConfig->clean();
158+
$this->writeConfig($weeTaxSettings);
128159

129160
$skus = ['simple-with-ftp'];
130161
$query = $this->getProductQuery($skus);
@@ -181,16 +212,7 @@ public function catalogPriceExcludeTaxAndIncludeFPTWithDescriptionSettingsProvid
181212
*/
182213
public function testCatalogPriceExcludeTaxCatalogDisplayIncludeTaxAndIncludeFPTOnly(array $weeTaxSettings)
183214
{
184-
/** @var WriterInterface $configWriter */
185-
$configWriter = $this->objectManager->get(WriterInterface::class);
186-
187-
foreach ($weeTaxSettings as $path => $value) {
188-
$configWriter->save($path, $value);
189-
}
190-
191-
/** @var ScopeConfigInterface $scopeConfig */
192-
$scopeConfig = $this->objectManager->get(ScopeConfigInterface::class);
193-
$scopeConfig->clean();
215+
$this->writeConfig($weeTaxSettings);
194216

195217
/** @var TaxClassCollectionFactory $taxClassCollectionFactory */
196218
$taxClassCollectionFactory = $this->objectManager->get(TaxClassCollectionFactory::class);
@@ -257,16 +279,7 @@ public function catalogPriceExcludeTaxCatalogDisplayIncludeTaxAndIncludeFPTOnlyS
257279
*/
258280
public function testCatalogPriceExclTaxCatalogDisplayInclTaxAndInclFPTWithDescription(array $weeTaxSettings)
259281
{
260-
/** @var WriterInterface $configWriter */
261-
$configWriter = $this->objectManager->get(WriterInterface::class);
262-
263-
foreach ($weeTaxSettings as $path => $value) {
264-
$configWriter->save($path, $value);
265-
}
266-
267-
/** @var ScopeConfigInterface $scopeConfig */
268-
$scopeConfig = $this->objectManager->get(ScopeConfigInterface::class);
269-
$scopeConfig->clean();
282+
$this->writeConfig($weeTaxSettings);
270283

271284
/** @var TaxClassCollectionFactory $taxClassCollectionFactory */
272285
$taxClassCollectionFactory = $this->objectManager->get(TaxClassCollectionFactory::class);
@@ -333,16 +346,7 @@ public function catalogPriceExclTaxCatalogDisplayInclTaxAndInclFPTWithDescriptio
333346
*/
334347
public function testCatalogPriceInclTaxCatalogDisplayExclTaxAndInclFPTWithDescription(array $weeTaxSettings)
335348
{
336-
/** @var WriterInterface $configWriter */
337-
$configWriter = $this->objectManager->get(WriterInterface::class);
338-
339-
foreach ($weeTaxSettings as $path => $value) {
340-
$configWriter->save($path, $value);
341-
}
342-
343-
/** @var ScopeConfigInterface $scopeConfig */
344-
$scopeConfig = $this->objectManager->get(ScopeConfigInterface::class);
345-
$scopeConfig->clean();
349+
$this->writeConfig($weeTaxSettings);
346350

347351
$skus = ['simple-with-ftp'];
348352
$query = $this->getProductQuery($skus);
@@ -400,16 +404,7 @@ public function catalogPriceInclTaxCatalogDisplayExclTaxAndInclFPTWithDescriptio
400404
*/
401405
public function testCatalogPriceInclTaxCatalogDisplayInclTaxAndInclFPTOnly(array $weeTaxSettings)
402406
{
403-
/** @var WriterInterface $configWriter */
404-
$configWriter = $this->objectManager->get(WriterInterface::class);
405-
406-
foreach ($weeTaxSettings as $path => $value) {
407-
$configWriter->save($path, $value);
408-
}
409-
410-
/** @var ScopeConfigInterface $scopeConfig */
411-
$scopeConfig = $this->objectManager->get(ScopeConfigInterface::class);
412-
$scopeConfig->clean();
407+
$this->writeConfig($weeTaxSettings);
413408

414409
$skus = ['simple-with-ftp'];
415410
$query = $this->getProductQuery($skus);
@@ -469,16 +464,8 @@ public function catalogPriceInclTaxCatalogDisplayInclTaxAndInclFPTOnlySettingsPr
469464
public function testCatalogPriceIncTaxCatalogDisplayInclTaxInclFPTWithDescrWithTaxAppliedOnFPT(
470465
array $weeTaxSettings
471466
) {
472-
/** @var WriterInterface $configWriter */
473-
$configWriter = $this->objectManager->get(WriterInterface::class);
474-
475-
foreach ($weeTaxSettings as $path => $value) {
476-
$configWriter->save($path, $value);
477-
}
467+
$this->writeConfig($weeTaxSettings);
478468

479-
/** @var ScopeConfigInterface $scopeConfig */
480-
$scopeConfig = $this->objectManager->get(ScopeConfigInterface::class);
481-
$scopeConfig->clean();
482469
/** @var TaxClassCollectionFactory $taxClassCollectionFactory */
483470
$taxClassCollectionFactory = $this->objectManager->get(TaxClassCollectionFactory::class);
484471
$taxClassCollection = $taxClassCollectionFactory->create();
@@ -552,16 +539,7 @@ public function catalogPriceIncTaxCatalogDisplayInclTaxInclFPTWithDescrWithTaxAp
552539
*/
553540
public function testCatalogPriceInclTaxCatalogDisplayIncludeTaxAndMuyltipleFPTs(array $weeTaxSettings)
554541
{
555-
/** @var WriterInterface $configWriter */
556-
$configWriter = $this->objectManager->get(WriterInterface::class);
557-
558-
foreach ($weeTaxSettings as $path => $value) {
559-
$configWriter->save($path, $value);
560-
}
561-
562-
/** @var ScopeConfigInterface $scopeConfig */
563-
$scopeConfig = $this->objectManager->get(ScopeConfigInterface::class);
564-
$scopeConfig->clean();
542+
$this->writeConfig($weeTaxSettings);
565543

566544
/** @var TaxClassCollectionFactory $taxClassCollectionFactory */
567545
$taxClassCollectionFactory = $this->objectManager->get(TaxClassCollectionFactory::class);
@@ -644,16 +622,7 @@ public function catalogPriceInclTaxCatalogDisplayIncludeTaxAndMuyltipleFPTsSetti
644622
*/
645623
public function testCatalogPriceDisableFPT(array $weeTaxSettings)
646624
{
647-
/** @var WriterInterface $configWriter */
648-
$configWriter = $this->objectManager->get(WriterInterface::class);
649-
650-
foreach ($weeTaxSettings as $path => $value) {
651-
$configWriter->save($path, $value);
652-
}
653-
654-
/** @var ScopeConfigInterface $scopeConfig */
655-
$scopeConfig = $this->objectManager->get(ScopeConfigInterface::class);
656-
$scopeConfig->clean();
625+
$this->writeConfig($weeTaxSettings);
657626

658627
/** @var ProductRepositoryInterface $productRepository */
659628
$productRepository = $this->objectManager->get(ProductRepositoryInterface::class);

0 commit comments

Comments
 (0)