Completed
Push — master ( 0541e3...1b0cb6 )
by Ilya
55s queued 18s
created

ProductConcreteCartReorderRestApiFixtures   A

Complexity

Total Complexity 12

Size/Duplication

Total Lines 213
Duplicated Lines 0 %

Importance

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