@@ -27,12 +27,61 @@ class ProductPriceWithFPTTest extends GraphQlAbstract
27
27
/** @var ObjectManager $objectManager */
28
28
private $ objectManager ;
29
29
30
+ /** @var string[] $objectManager */
31
+ private $ initialConfig ;
32
+
33
+ /** @var ScopeConfigInterface */
34
+ private $ scopeConfig ;
35
+
30
36
/**
31
37
* @inheritdoc
32
38
*/
33
- protected function setUp () : void
39
+ protected function setUp (): void
34
40
{
35
41
$ 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 ();
36
85
}
37
86
38
87
/**
@@ -49,16 +98,7 @@ protected function setUp() :void
49
98
*/
50
99
public function testCatalogPriceExcludeTaxAndIncludeFPTOnly (array $ weeTaxSettings )
51
100
{
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 );
62
102
63
103
$ skus = ['simple-with-ftp ' ];
64
104
$ query = $ this ->getProductQuery ($ skus );
@@ -115,16 +155,7 @@ public function catalogPriceExcludeTaxAndIncludeFPTOnlySettingsProvider()
115
155
*/
116
156
public function testCatalogPriceExcludeTaxAndIncludeFPTWithDescription (array $ weeTaxSettings )
117
157
{
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 );
128
159
129
160
$ skus = ['simple-with-ftp ' ];
130
161
$ query = $ this ->getProductQuery ($ skus );
@@ -181,16 +212,7 @@ public function catalogPriceExcludeTaxAndIncludeFPTWithDescriptionSettingsProvid
181
212
*/
182
213
public function testCatalogPriceExcludeTaxCatalogDisplayIncludeTaxAndIncludeFPTOnly (array $ weeTaxSettings )
183
214
{
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 );
194
216
195
217
/** @var TaxClassCollectionFactory $taxClassCollectionFactory */
196
218
$ taxClassCollectionFactory = $ this ->objectManager ->get (TaxClassCollectionFactory::class);
@@ -257,16 +279,7 @@ public function catalogPriceExcludeTaxCatalogDisplayIncludeTaxAndIncludeFPTOnlyS
257
279
*/
258
280
public function testCatalogPriceExclTaxCatalogDisplayInclTaxAndInclFPTWithDescription (array $ weeTaxSettings )
259
281
{
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 );
270
283
271
284
/** @var TaxClassCollectionFactory $taxClassCollectionFactory */
272
285
$ taxClassCollectionFactory = $ this ->objectManager ->get (TaxClassCollectionFactory::class);
@@ -333,16 +346,7 @@ public function catalogPriceExclTaxCatalogDisplayInclTaxAndInclFPTWithDescriptio
333
346
*/
334
347
public function testCatalogPriceInclTaxCatalogDisplayExclTaxAndInclFPTWithDescription (array $ weeTaxSettings )
335
348
{
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 );
346
350
347
351
$ skus = ['simple-with-ftp ' ];
348
352
$ query = $ this ->getProductQuery ($ skus );
@@ -400,16 +404,7 @@ public function catalogPriceInclTaxCatalogDisplayExclTaxAndInclFPTWithDescriptio
400
404
*/
401
405
public function testCatalogPriceInclTaxCatalogDisplayInclTaxAndInclFPTOnly (array $ weeTaxSettings )
402
406
{
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 );
413
408
414
409
$ skus = ['simple-with-ftp ' ];
415
410
$ query = $ this ->getProductQuery ($ skus );
@@ -469,16 +464,8 @@ public function catalogPriceInclTaxCatalogDisplayInclTaxAndInclFPTOnlySettingsPr
469
464
public function testCatalogPriceIncTaxCatalogDisplayInclTaxInclFPTWithDescrWithTaxAppliedOnFPT (
470
465
array $ weeTaxSettings
471
466
) {
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 );
478
468
479
- /** @var ScopeConfigInterface $scopeConfig */
480
- $ scopeConfig = $ this ->objectManager ->get (ScopeConfigInterface::class);
481
- $ scopeConfig ->clean ();
482
469
/** @var TaxClassCollectionFactory $taxClassCollectionFactory */
483
470
$ taxClassCollectionFactory = $ this ->objectManager ->get (TaxClassCollectionFactory::class);
484
471
$ taxClassCollection = $ taxClassCollectionFactory ->create ();
@@ -552,16 +539,7 @@ public function catalogPriceIncTaxCatalogDisplayInclTaxInclFPTWithDescrWithTaxAp
552
539
*/
553
540
public function testCatalogPriceInclTaxCatalogDisplayIncludeTaxAndMuyltipleFPTs (array $ weeTaxSettings )
554
541
{
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 );
565
543
566
544
/** @var TaxClassCollectionFactory $taxClassCollectionFactory */
567
545
$ taxClassCollectionFactory = $ this ->objectManager ->get (TaxClassCollectionFactory::class);
@@ -644,16 +622,7 @@ public function catalogPriceInclTaxCatalogDisplayIncludeTaxAndMuyltipleFPTsSetti
644
622
*/
645
623
public function testCatalogPriceDisableFPT (array $ weeTaxSettings )
646
624
{
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 );
657
626
658
627
/** @var ProductRepositoryInterface $productRepository */
659
628
$ productRepository = $ this ->objectManager ->get (ProductRepositoryInterface::class);
0 commit comments