Completed
Push — master ( f465c8...ce649b )
by Ilya
52s queued 19s
created

SalesUnitCartReorderRestApiFixtures   A

Complexity

Total Complexity 9

Size/Duplication

Total Lines 157
Duplicated Lines 0 %

Importance

Changes 1
Bugs 1 Features 0
Metric Value
wmc 9
eloc 47
c 1
b 1
f 0
dl 0
loc 157
rs 10

9 Methods

Rating   Name   Duplication   Size   Complexity  
A getProductPackagingUnitTransfer() 0 3 1
A createOrderWithProductPackagingUnit() 0 19 1
A getProductConcreteTransfer() 0 3 1
A buildFixtures() 0 14 1
A getProductMeasurementSalesUnitTransfer() 0 3 1
A getOrderWithSalesUnit() 0 3 1
A getCustomerTransfer() 0 3 1
A createProductPackagingUnit() 0 13 1
A getProductConcreteTransferWithSalesUnit() 0 3 1
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
declare(strict_types = 1);
9
10
namespace PyzTest\Glue\CartReorder\RestApi\Fixtures;
11
12
use Generated\Shared\DataBuilder\ItemBuilder;
0 ignored issues
show
Bug introduced by
The type Generated\Shared\DataBuilder\ItemBuilder 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\CustomerTransfer;
0 ignored issues
show
Bug introduced by
The type Generated\Shared\Transfer\CustomerTransfer 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 Generated\Shared\Transfer\ItemTransfer;
0 ignored issues
show
Bug introduced by
The type Generated\Shared\Transfer\ItemTransfer 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...
15
use Generated\Shared\Transfer\ProductConcreteTransfer;
0 ignored issues
show
Bug introduced by
The type Generated\Shared\Transfer\ProductConcreteTransfer 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...
16
use Generated\Shared\Transfer\ProductMeasurementSalesUnitTransfer;
0 ignored issues
show
Bug introduced by
The type Generated\Shared\Transfe...rementSalesUnitTransfer 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...
17
use Generated\Shared\Transfer\ProductPackagingUnitTransfer;
0 ignored issues
show
Bug introduced by
The type Generated\Shared\Transfe...ctPackagingUnitTransfer 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...
18
use Generated\Shared\Transfer\ProductPackagingUnitTypeTransfer;
0 ignored issues
show
Bug introduced by
The type Generated\Shared\Transfe...ckagingUnitTypeTransfer 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...
19
use Generated\Shared\Transfer\QuoteTransfer;
0 ignored issues
show
Bug introduced by
The type Generated\Shared\Transfer\QuoteTransfer 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...
20
use Generated\Shared\Transfer\SaveOrderTransfer;
0 ignored issues
show
Bug introduced by
The type Generated\Shared\Transfer\SaveOrderTransfer 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...
21
use Generated\Shared\Transfer\SpyProductPackagingUnitEntityTransfer;
0 ignored issues
show
Bug introduced by
The type Generated\Shared\Transfe...agingUnitEntityTransfer 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...
22
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...
23
use PyzTest\Glue\CartReorder\CartReorderApiTester;
24
use SprykerTest\Shared\Testify\Fixtures\FixturesBuilderInterface;
25
use SprykerTest\Shared\Testify\Fixtures\FixturesContainerInterface;
26
27
class SalesUnitCartReorderRestApiFixtures implements FixturesBuilderInterface, FixturesContainerInterface
28
{
29
    /**
30
     * @var string
31
     */
32
    protected const TEST_USERNAME = 'ProductPackagingUnitCartReorderRestApiFixtures';
33
34
    /**
35
     * @var string
36
     */
37
    protected const TEST_PRODUCT_PACKAGING_UNIT_TYPE = 'box';
38
39
    /**
40
     * @var \Generated\Shared\Transfer\StoreTransfer
41
     */
42
    protected StoreTransfer $storeTransfer;
43
44
    /**
45
     * @var \Generated\Shared\Transfer\CustomerTransfer
46
     */
47
    protected CustomerTransfer $customerTransfer;
48
49
    /**
50
     * @var \Generated\Shared\Transfer\ProductConcreteTransfer
51
     */
52
    protected ProductConcreteTransfer $productConcreteTransfer;
53
54
    /**
55
     * @var \Generated\Shared\Transfer\ProductConcreteTransfer
56
     */
57
    protected ProductConcreteTransfer $productConcreteTransferWithSalesUnit;
58
59
    /**
60
     * @var \Generated\Shared\Transfer\ProductMeasurementSalesUnitTransfer
61
     */
62
    protected ProductMeasurementSalesUnitTransfer $productMeasurementSalesUnitTransfer;
63
64
    protected ProductPackagingUnitTransfer $productPackagingUnitTransfer;
65
66
    /**
67
     * @var \Generated\Shared\Transfer\SaveOrderTransfer
68
     */
69
    protected SaveOrderTransfer $orderWithSalesUnit;
70
71
    /**
72
     * @return \Generated\Shared\Transfer\CustomerTransfer
73
     */
74
    public function getCustomerTransfer(): CustomerTransfer
75
    {
76
        return $this->customerTransfer;
77
    }
78
79
    /**
80
     * @return \Generated\Shared\Transfer\ProductConcreteTransfer
81
     */
82
    public function getProductConcreteTransfer(): ProductConcreteTransfer
83
    {
84
        return $this->productConcreteTransfer;
85
    }
86
87
    /**
88
     * @return \Generated\Shared\Transfer\ProductConcreteTransfer
89
     */
90
    public function getProductConcreteTransferWithSalesUnit(): ProductConcreteTransfer
91
    {
92
        return $this->productConcreteTransferWithSalesUnit;
93
    }
94
95
    /**
96
     * @return \Generated\Shared\Transfer\ProductMeasurementSalesUnitTransfer
97
     */
98
    public function getProductMeasurementSalesUnitTransfer(): ProductMeasurementSalesUnitTransfer
99
    {
100
        return $this->productMeasurementSalesUnitTransfer;
101
    }
102
103
    /**
104
     * @return \Generated\Shared\Transfer\ProductPackagingUnitTransfer
105
     */
106
    public function getProductPackagingUnitTransfer(): ProductPackagingUnitTransfer
107
    {
108
        return $this->productPackagingUnitTransfer;
109
    }
110
111
    /**
112
     * @return \Generated\Shared\Transfer\SaveOrderTransfer
113
     */
114
    public function getOrderWithSalesUnit(): SaveOrderTransfer
115
    {
116
        return $this->orderWithSalesUnit;
117
    }
118
119
    /**
120
     * @param \PyzTest\Glue\CartReorder\CartReorderApiTester $I
121
     *
122
     * @return \SprykerTest\Shared\Testify\Fixtures\FixturesContainerInterface
123
     */
124
    public function buildFixtures(CartReorderApiTester $I): FixturesContainerInterface
125
    {
126
        $I->configureStateMachine();
127
        $this->storeTransfer = $I->getCurrentStore();
128
        $this->customerTransfer = $I->createCustomer(static::TEST_USERNAME);
129
130
        $this->productConcreteTransfer = $I->createProductWithPriceAndStock($this->storeTransfer);
131
        $this->productConcreteTransferWithSalesUnit = $I->createProductWithPriceAndStock($this->storeTransfer);
132
        $this->productMeasurementSalesUnitTransfer = $I->createProductMeasurementSalesUnit($this->productConcreteTransferWithSalesUnit);
133
        $this->productPackagingUnitTransfer = $this->createProductPackagingUnit($I);
134
135
        $this->orderWithSalesUnit = $this->createOrderWithProductPackagingUnit($I);
136
137
        return $this;
138
    }
139
140
    /**
141
     * @param \PyzTest\Glue\CartReorder\CartReorderApiTester $I
142
     *
143
     * @return \Generated\Shared\Transfer\ProductPackagingUnitTransfer
144
     */
145
    protected function createProductPackagingUnit(CartReorderApiTester $I): ProductPackagingUnitTransfer
146
    {
147
        $productPackagingUnitTypeTransfer = $I->haveProductPackagingUnitType([
148
            ProductPackagingUnitTypeTransfer::NAME => static::TEST_PRODUCT_PACKAGING_UNIT_TYPE,
149
        ]);
150
151
        $productPackagingUnitEntityTransfer = $I->haveProductPackagingUnit([
152
            SpyProductPackagingUnitEntityTransfer::FK_PRODUCT => $this->productConcreteTransferWithSalesUnit->getIdProductConcreteOrFail(),
153
            SpyProductPackagingUnitEntityTransfer::FK_PRODUCT_PACKAGING_UNIT_TYPE => $productPackagingUnitTypeTransfer->getIdProductPackagingUnitTypeOrFail(),
154
            SpyProductPackagingUnitEntityTransfer::FK_LEAD_PRODUCT => $this->productConcreteTransferWithSalesUnit->getIdProductConcreteOrFail(),
155
        ]);
156
157
        return (new ProductPackagingUnitTransfer())->fromArray($productPackagingUnitEntityTransfer->toArray(), true);
158
    }
159
160
    /**
161
     * @param \PyzTest\Glue\CartReorder\CartReorderApiTester $I
162
     *
163
     * @return \Generated\Shared\Transfer\SaveOrderTransfer
164
     */
165
    protected function createOrderWithProductPackagingUnit(CartReorderApiTester $I): SaveOrderTransfer
166
    {
167
        $itemsData = [
168
            (new ItemBuilder([
169
                ItemTransfer::SKU => $this->productConcreteTransfer->getSkuOrFail(),
170
                ItemTransfer::QUANTITY => 1,
171
            ]))->build()->toArray(),
172
            (new ItemBuilder([
173
                ItemTransfer::ID => $this->productConcreteTransferWithSalesUnit->getIdProductConcreteOrFail(),
174
                ItemTransfer::SKU => $this->productConcreteTransferWithSalesUnit->getSkuOrFail(),
175
                ItemTransfer::AMOUNT_SALES_UNIT => $this->productMeasurementSalesUnitTransfer,
176
                ItemTransfer::QUANTITY_SALES_UNIT => $this->productMeasurementSalesUnitTransfer,
177
                ItemTransfer::AMOUNT_LEAD_PRODUCT => $this->productConcreteTransferWithSalesUnit->toArray(),
178
                ItemTransfer::QUANTITY => 2,
179
                ItemTransfer::AMOUNT => 3,
180
            ]))->build()->toArray(),
181
        ];
182
183
        return $I->createOrder($this->customerTransfer, [QuoteTransfer::ITEMS => $itemsData]);
184
    }
185
}
186