Passed
Pull Request — master (#319)
by Dmitry
22:36
created

testConfigureTaxAppMessageIsSuccessfullyHandled()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 19
Code Lines 9

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 9
dl 0
loc 19
c 1
b 0
f 0
rs 9.9666
cc 1
nc 1
nop 0
1
<?php
2
3
/**
4
 * This file is part of the Spryker Commerce OS.
5
 * For full license information, please view the LICENSE file that was distributed with this source code.
6
 */
7
8
namespace PyzTest\Zed\MessageBroker\MessageHandlers\TaxApp\Communication;
9
10
use Codeception\Test\Unit;
11
use Generated\Shared\Transfer\ConfigureTaxAppTransfer;
0 ignored issues
show
Bug introduced by
The type Generated\Shared\Transfer\ConfigureTaxAppTransfer was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
12
use Generated\Shared\Transfer\MessageAttributesTransfer;
0 ignored issues
show
Bug introduced by
The type Generated\Shared\Transfe...ssageAttributesTransfer was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
13
use Generated\Shared\Transfer\StoreTransfer;
0 ignored issues
show
Bug introduced by
The type Generated\Shared\Transfer\StoreTransfer was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
14
use PyzTest\Zed\MessageBroker\TaxAppCommunicationTester;
15
16
/**
17
 * Auto-generated group annotations
18
 *
19
 * @group PyzTest
20
 * @group Zed
21
 * @group MessageBroker
22
 * @group MessageHandlers
23
 * @group TaxApp
24
 * @group Communication
25
 * @group TaxAppConfigMessageTest
26
 * Add your own group annotations below this line
27
 */
28
class TaxAppConfigMessageTest extends Unit
29
{
30
    /**
31
     * @var string
32
     */
33
    protected const STORE_REFERENCE = 'DE';
34
35
    /**
36
     * @var string
37
     */
38
    protected const VENDOR_CODE = 'VENDOR_CODE';
39
40
    /**
41
     * @var \PyzTest\Zed\MessageBroker\TaxAppCommunicationTester
42
     */
43
    protected TaxAppCommunicationTester $tester;
44
45
    /**
46
     * @return void
47
     */
48
    public function testConfigureTaxAppMessageIsSuccessfullyHandled(): void
49
    {
50
        // Arrange
51
        $storeTransfer = $this->tester->getAllowedStore();
52
        $this->tester->setStoreReferenceData([$storeTransfer->getName() => static::STORE_REFERENCE]);
53
54
        $configureTaxAppTransfer = $this->tester->buildConfigureTaxAppTransfer([
55
            MessageAttributesTransfer::STORE_REFERENCE => static::STORE_REFERENCE,
56
        ], [
57
            ConfigureTaxAppTransfer::VENDOR_CODE => static::VENDOR_CODE,
58
            ConfigureTaxAppTransfer::API_URL => 'url',
59
            ConfigureTaxAppTransfer::IS_ACTIVE => true,
60
        ]);
61
62
        // Act
63
        $this->tester->handleTaxAppMessage($configureTaxAppTransfer);
64
65
        // Assert
66
        $this->tester->assertTaxAppConfigIsSavedCorrectlyForStore($storeTransfer, $configureTaxAppTransfer);
67
    }
68
69
    /**
70
     * @return void
71
     */
72
    public function testDeleteTaxAppMessageIsSuccessfullyHandled(): void
73
    {
74
        // Arrange
75
        $storeTransfer = $this->tester->getAllowedStore();
76
        $this->tester->setStoreReferenceData([$storeTransfer->getName() => static::STORE_REFERENCE]);
77
78
        $this->createDummyTaxAppConfig($storeTransfer);
79
80
        $deleteTaxAppTransfer = $this->tester->buildDeleteTaxAppTransfer([
81
            MessageAttributesTransfer::STORE_REFERENCE => static::STORE_REFERENCE,
82
        ], [
83
            ConfigureTaxAppTransfer::VENDOR_CODE => static::VENDOR_CODE,
84
        ]);
85
86
        // Act
87
        $this->tester->handleTaxAppMessage($deleteTaxAppTransfer);
88
89
        // Assert
90
        $this->tester->assertTaxAppConfigIsRemovedForStore($storeTransfer, $deleteTaxAppTransfer);
91
    }
92
93
    /**
94
     * @param \Generated\Shared\Transfer\StoreTransfer $storeTransfer
95
     *
96
     * @return void
97
     */
98
    protected function createDummyTaxAppConfig(StoreTransfer $storeTransfer): void
0 ignored issues
show
Unused Code introduced by
The parameter $storeTransfer is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

98
    protected function createDummyTaxAppConfig(/** @scrutinizer ignore-unused */ StoreTransfer $storeTransfer): void

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
99
    {
100
        $this->tester->handleTaxAppMessage(
101
            $this->tester->buildConfigureTaxAppTransfer([
102
                MessageAttributesTransfer::STORE_REFERENCE => static::STORE_REFERENCE,
103
                ConfigureTaxAppTransfer::VENDOR_CODE => static::VENDOR_CODE,
104
            ]),
105
        );
106
    }
107
}
108