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

ProductConcreteCartReorderRestApiFixtures   A

Complexity

Total Complexity 12

Size/Duplication

Total Lines 213
Duplicated Lines 0 %

Importance

Changes 1
Bugs 1 Features 0
Metric Value
wmc 12
eloc 71
c 1
b 1
f 0
dl 0
loc 213
rs 10

12 Methods

Rating   Name   Duplication   Size   Complexity  
A createOrderFromAnotherCustomer() 0 14 1
A getOrderFromAnotherCustomer() 0 3 1
A getOrderWithConcreteProducts() 0 3 1
A getOrderWithNotAvailableConcreteProduct() 0 3 1
A createNotAvailableProductConcrete() 0 20 1
A getProductConcreteTransfer2() 0 3 1
A createOrderWithNotAvailableConcreteProduct() 0 14 1
A getNotAvailableProductConcreteTransfer() 0 3 1
A getProductConcreteTransfer1() 0 3 1
A getCustomerTransfer() 0 3 1
A createOrderWithConcreteProducts() 0 14 1
A buildFixtures() 0 15 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\MoneyValueTransfer;
0 ignored issues
show
Bug introduced by
The type Generated\Shared\Transfer\MoneyValueTransfer 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\PriceProductTransfer;
0 ignored issues
show
Bug introduced by
The type Generated\Shared\Transfer\PriceProductTransfer 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\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...
18
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...
19
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...
20
use Generated\Shared\Transfer\StockProductTransfer;
0 ignored issues
show
Bug introduced by
The type Generated\Shared\Transfer\StockProductTransfer 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\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...
22
use PyzTest\Glue\CartReorder\CartReorderApiTester;
23
use SprykerTest\Shared\Testify\Fixtures\FixturesBuilderInterface;
24
use SprykerTest\Shared\Testify\Fixtures\FixturesContainerInterface;
25
26
class ProductConcreteCartReorderRestApiFixtures implements FixturesBuilderInterface, FixturesContainerInterface
27
{
28
    /**
29
     * @var string
30
     */
31
    protected const TEST_USERNAME = 'ProductConcreteCartReorderRestApiFixtures';
32
33
    /**
34
     * @var \Generated\Shared\Transfer\StoreTransfer
35
     */
36
    protected StoreTransfer $storeTransfer;
37
38
    /**
39
     * @var \Generated\Shared\Transfer\CustomerTransfer
40
     */
41
    protected CustomerTransfer $customerTransfer;
42
43
    /**
44
     * @var \Generated\Shared\Transfer\ProductConcreteTransfer
45
     */
46
    protected ProductConcreteTransfer $productConcreteTransfer1;
47
48
    /**
49
     * @var \Generated\Shared\Transfer\ProductConcreteTransfer
50
     */
51
    protected ProductConcreteTransfer $productConcreteTransfer2;
52
53
    /**
54
     * @var \Generated\Shared\Transfer\ProductConcreteTransfer
55
     */
56
    protected ProductConcreteTransfer $notAvailableProductConcreteTransfer;
57
58
    /**
59
     * @var \Generated\Shared\Transfer\SaveOrderTransfer
60
     */
61
    protected SaveOrderTransfer $orderWithConcreteProducts;
62
63
    /**
64
     * @var \Generated\Shared\Transfer\SaveOrderTransfer
65
     */
66
    protected SaveOrderTransfer $orderWithNotAvailableConcreteProduct;
67
68
    /**
69
     * @var \Generated\Shared\Transfer\SaveOrderTransfer
70
     */
71
    protected SaveOrderTransfer $orderFromAnotherCustomer;
72
73
    /**
74
     * @return \Generated\Shared\Transfer\CustomerTransfer
75
     */
76
    public function getCustomerTransfer(): CustomerTransfer
77
    {
78
        return $this->customerTransfer;
79
    }
80
81
    /**
82
     * @return \Generated\Shared\Transfer\ProductConcreteTransfer
83
     */
84
    public function getProductConcreteTransfer1(): ProductConcreteTransfer
85
    {
86
        return $this->productConcreteTransfer1;
87
    }
88
89
    /**
90
     * @return \Generated\Shared\Transfer\ProductConcreteTransfer
91
     */
92
    public function getProductConcreteTransfer2(): ProductConcreteTransfer
93
    {
94
        return $this->productConcreteTransfer2;
95
    }
96
97
    /**
98
     * @return \Generated\Shared\Transfer\ProductConcreteTransfer
99
     */
100
    public function getNotAvailableProductConcreteTransfer(): ProductConcreteTransfer
101
    {
102
        return $this->notAvailableProductConcreteTransfer;
103
    }
104
105
    /**
106
     * @return \Generated\Shared\Transfer\SaveOrderTransfer
107
     */
108
    public function getOrderWithConcreteProducts(): SaveOrderTransfer
109
    {
110
        return $this->orderWithConcreteProducts;
111
    }
112
113
    /**
114
     * @return \Generated\Shared\Transfer\SaveOrderTransfer
115
     */
116
    public function getOrderWithNotAvailableConcreteProduct(): SaveOrderTransfer
117
    {
118
        return $this->orderWithNotAvailableConcreteProduct;
119
    }
120
121
    /**
122
     * @return \Generated\Shared\Transfer\SaveOrderTransfer
123
     */
124
    public function getOrderFromAnotherCustomer(): SaveOrderTransfer
125
    {
126
        return $this->orderFromAnotherCustomer;
127
    }
128
129
    /**
130
     * @param \PyzTest\Glue\CartReorder\CartReorderApiTester $I
131
     *
132
     * @return \SprykerTest\Shared\Testify\Fixtures\FixturesContainerInterface
133
     */
134
    public function buildFixtures(CartReorderApiTester $I): FixturesContainerInterface
135
    {
136
        $I->configureStateMachine();
137
        $this->storeTransfer = $I->getCurrentStore();
138
        $this->customerTransfer = $I->createCustomer(static::TEST_USERNAME);
139
140
        $this->productConcreteTransfer1 = $I->createProductWithPriceAndStock($this->storeTransfer);
141
        $this->productConcreteTransfer2 = $I->createProductWithPriceAndStock($this->storeTransfer);
142
        $this->notAvailableProductConcreteTransfer = $this->createNotAvailableProductConcrete($I);
143
144
        $this->orderWithConcreteProducts = $this->createOrderWithConcreteProducts($I);
145
        $this->orderWithNotAvailableConcreteProduct = $this->createOrderWithNotAvailableConcreteProduct($I);
146
        $this->orderFromAnotherCustomer = $this->createOrderFromAnotherCustomer($I);
147
148
        return $this;
149
    }
150
151
    /**
152
     * @param \PyzTest\Glue\CartReorder\CartReorderApiTester $I
153
     *
154
     * @return \Generated\Shared\Transfer\ProductConcreteTransfer
155
     */
156
    protected function createNotAvailableProductConcrete(CartReorderApiTester $I): ProductConcreteTransfer
157
    {
158
        $productConcreteTransfer = $I->haveFullProduct();
159
        $I->havePriceProduct([
160
            PriceProductTransfer::SKU_PRODUCT_ABSTRACT => $productConcreteTransfer->getAbstractSkuOrFail(),
161
            PriceProductTransfer::SKU_PRODUCT => $productConcreteTransfer->getSkuOrFail(),
162
            PriceProductTransfer::ID_PRODUCT => $productConcreteTransfer->getIdProductConcreteOrFail(),
163
            PriceProductTransfer::PRICE_TYPE_NAME => CartReorderApiTester::PRICE_TYPE,
164
            PriceProductTransfer::MONEY_VALUE => [
165
                MoneyValueTransfer::NET_AMOUNT => 777,
166
                MoneyValueTransfer::GROSS_AMOUNT => 888,
167
            ],
168
        ]);
169
        $I->haveProductInStockForStore($this->storeTransfer, [
170
            StockProductTransfer::SKU => $productConcreteTransfer->getSku(),
171
            StockProductTransfer::IS_NEVER_OUT_OF_STOCK => 0,
172
            StockProductTransfer::QUANTITY => 0,
173
        ]);
174
175
        return $productConcreteTransfer;
176
    }
177
178
    /**
179
     * @param \PyzTest\Glue\CartReorder\CartReorderApiTester $I
180
     *
181
     * @return \Generated\Shared\Transfer\SaveOrderTransfer
182
     */
183
    protected function createOrderWithConcreteProducts(CartReorderApiTester $I): SaveOrderTransfer
184
    {
185
        $itemsData = [
186
            (new ItemBuilder([
187
                ItemTransfer::SKU => $this->productConcreteTransfer1->getSkuOrFail(),
188
                ItemTransfer::QUANTITY => 2,
189
            ]))->build()->toArray(),
190
            (new ItemBuilder([
191
                ItemTransfer::SKU => $this->productConcreteTransfer2->getSkuOrFail(),
192
                ItemTransfer::QUANTITY => 1,
193
            ]))->build()->toArray(),
194
        ];
195
196
        return $I->createOrder($this->customerTransfer, [QuoteTransfer::ITEMS => $itemsData]);
197
    }
198
199
    /**
200
     * @param \PyzTest\Glue\CartReorder\CartReorderApiTester $I
201
     *
202
     * @return \Generated\Shared\Transfer\SaveOrderTransfer
203
     */
204
    protected function createOrderWithNotAvailableConcreteProduct(CartReorderApiTester $I): SaveOrderTransfer
205
    {
206
        $itemsData = [
207
            (new ItemBuilder([
208
                ItemTransfer::SKU => $this->productConcreteTransfer1->getSkuOrFail(),
209
                ItemTransfer::QUANTITY => 2,
210
            ]))->build()->toArray(),
211
            (new ItemBuilder([
212
                ItemTransfer::SKU => $this->notAvailableProductConcreteTransfer->getSkuOrFail(),
213
                ItemTransfer::QUANTITY => 1,
214
            ]))->build()->toArray(),
215
        ];
216
217
        return $I->createOrder($this->customerTransfer, [QuoteTransfer::ITEMS => $itemsData]);
218
    }
219
220
    /**
221
     * @param \PyzTest\Glue\CartReorder\CartReorderApiTester $I
222
     *
223
     * @return \Generated\Shared\Transfer\SaveOrderTransfer
224
     */
225
    protected function createOrderFromAnotherCustomer(CartReorderApiTester $I): SaveOrderTransfer
226
    {
227
        $itemsData = [
228
            (new ItemBuilder([
229
                ItemTransfer::SKU => $this->productConcreteTransfer1->getSkuOrFail(),
230
                ItemTransfer::QUANTITY => 2,
231
            ]))->build()->toArray(),
232
            (new ItemBuilder([
233
                ItemTransfer::SKU => $this->notAvailableProductConcreteTransfer->getSkuOrFail(),
234
                ItemTransfer::QUANTITY => 1,
235
            ]))->build()->toArray(),
236
        ];
237
238
        return $I->createOrder($I->haveCustomer(), [QuoteTransfer::ITEMS => $itemsData]);
239
    }
240
}
241