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

ProductBundleCartReorderRestApiFixtures   A

Complexity

Total Complexity 9

Size/Duplication

Total Lines 171
Duplicated Lines 0 %

Importance

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

9 Methods

Rating   Name   Duplication   Size   Complexity  
A getCustomerTransfer() 0 3 1
A buildFixtures() 0 13 1
A getBundledProductConcreteTransfer2() 0 3 1
A createOrderWithProductBundle() 0 14 1
A createProductBundle() 0 35 1
A getProductConcreteTransfer() 0 3 1
A getProductBundleTransfer() 0 3 1
A getOrderWithProductBundle() 0 3 1
A getBundledProductConcreteTransfer1() 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\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\ProductBundleTransfer;
0 ignored issues
show
Bug introduced by
The type Generated\Shared\Transfer\ProductBundleTransfer 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\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...
19
use Generated\Shared\Transfer\ProductForBundleTransfer;
0 ignored issues
show
Bug introduced by
The type Generated\Shared\Transfer\ProductForBundleTransfer 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\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...
21
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...
22
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...
23
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...
24
use PyzTest\Glue\CartReorder\CartReorderApiTester;
25
use SprykerTest\Shared\Testify\Fixtures\FixturesBuilderInterface;
26
use SprykerTest\Shared\Testify\Fixtures\FixturesContainerInterface;
27
28
class ProductBundleCartReorderRestApiFixtures implements FixturesBuilderInterface, FixturesContainerInterface
29
{
30
    /**
31
     * @var string
32
     */
33
    protected const TEST_USERNAME = 'ProductBundleCartReorderRestApiFixtures';
34
35
    /**
36
     * @var \Generated\Shared\Transfer\StoreTransfer
37
     */
38
    protected StoreTransfer $storeTransfer;
39
40
    /**
41
     * @var \Generated\Shared\Transfer\CustomerTransfer
42
     */
43
    protected CustomerTransfer $customerTransfer;
44
45
    /**
46
     * @var \Generated\Shared\Transfer\ProductConcreteTransfer
47
     */
48
    protected ProductConcreteTransfer $productConcreteTransfer;
49
50
    /**
51
     * @var \Generated\Shared\Transfer\ProductConcreteTransfer
52
     */
53
    protected ProductConcreteTransfer $bundledProductConcreteTransfer1;
54
55
    /**
56
     * @var \Generated\Shared\Transfer\ProductConcreteTransfer
57
     */
58
    protected ProductConcreteTransfer $bundledProductConcreteTransfer2;
59
60
    /**
61
     * @var \Generated\Shared\Transfer\ProductConcreteTransfer
62
     */
63
    protected ProductConcreteTransfer $productBundleTransfer;
64
65
    /**
66
     * @var \Generated\Shared\Transfer\SaveOrderTransfer
67
     */
68
    protected SaveOrderTransfer $orderWithProductBundle;
69
70
    /**
71
     * @return \Generated\Shared\Transfer\CustomerTransfer
72
     */
73
    public function getCustomerTransfer(): CustomerTransfer
74
    {
75
        return $this->customerTransfer;
76
    }
77
78
    /**
79
     * @return \Generated\Shared\Transfer\ProductConcreteTransfer
80
     */
81
    public function getProductConcreteTransfer(): ProductConcreteTransfer
82
    {
83
        return $this->productConcreteTransfer;
84
    }
85
86
    /**
87
     * @return \Generated\Shared\Transfer\ProductConcreteTransfer
88
     */
89
    public function getBundledProductConcreteTransfer1(): ProductConcreteTransfer
90
    {
91
        return $this->bundledProductConcreteTransfer1;
92
    }
93
94
    /**
95
     * @return \Generated\Shared\Transfer\ProductConcreteTransfer
96
     */
97
    public function getBundledProductConcreteTransfer2(): ProductConcreteTransfer
98
    {
99
        return $this->bundledProductConcreteTransfer2;
100
    }
101
102
    /**
103
     * @return \Generated\Shared\Transfer\ProductConcreteTransfer
104
     */
105
    public function getProductBundleTransfer(): ProductConcreteTransfer
106
    {
107
        return $this->productBundleTransfer;
108
    }
109
110
    /**
111
     * @return \Generated\Shared\Transfer\SaveOrderTransfer
112
     */
113
    public function getOrderWithProductBundle(): SaveOrderTransfer
114
    {
115
        return $this->orderWithProductBundle;
116
    }
117
118
    /**
119
     * @param \PyzTest\Glue\CartReorder\CartReorderApiTester $I
120
     *
121
     * @return \SprykerTest\Shared\Testify\Fixtures\FixturesContainerInterface
122
     */
123
    public function buildFixtures(CartReorderApiTester $I): FixturesContainerInterface
124
    {
125
        $I->configureStateMachine();
126
        $this->storeTransfer = $I->getCurrentStore();
127
        $this->customerTransfer = $I->createCustomer(static::TEST_USERNAME);
128
129
        $this->productConcreteTransfer = $I->createProductWithPriceAndStock($this->storeTransfer);
130
        $this->bundledProductConcreteTransfer1 = $I->createProductWithPriceAndStock($this->storeTransfer);
131
        $this->bundledProductConcreteTransfer2 = $I->createProductWithPriceAndStock($this->storeTransfer);
132
        $this->productBundleTransfer = $this->createProductBundle($I);
133
        $this->orderWithProductBundle = $this->createOrderWithProductBundle($I);
134
135
        return $this;
136
    }
137
138
    /**
139
     * @param \PyzTest\Glue\CartReorder\CartReorderApiTester $I
140
     *
141
     * @return \Generated\Shared\Transfer\ProductConcreteTransfer
142
     */
143
    protected function createProductBundle(CartReorderApiTester $I): ProductConcreteTransfer
144
    {
145
        $productConcreteTransfer = $I->haveFullProduct();
146
        $productConcreteTransfer = $I->haveProductBundle($productConcreteTransfer, [
147
            ProductBundleTransfer::BUNDLED_PRODUCTS => [
148
                [
149
                    ProductForBundleTransfer::ID_PRODUCT_CONCRETE => $this->bundledProductConcreteTransfer1->getIdProductConcreteOrFail(),
150
                    ProductForBundleTransfer::ID_PRODUCT_BUNDLE => $productConcreteTransfer->getIdProductConcreteOrFail(),
151
                    ProductForBundleTransfer::QUANTITY => 1,
152
                ],
153
                [
154
                    ProductForBundleTransfer::ID_PRODUCT_CONCRETE => $this->bundledProductConcreteTransfer2->getIdProductConcreteOrFail(),
155
                    ProductForBundleTransfer::ID_PRODUCT_BUNDLE => $productConcreteTransfer->getIdProductConcreteOrFail(),
156
                    ProductForBundleTransfer::QUANTITY => 2,
157
                ],
158
            ],
159
        ]);
160
161
        $I->haveProductInStockForStore($this->storeTransfer, [
162
            StockProductTransfer::SKU => $productConcreteTransfer->getSku(),
163
            StockProductTransfer::IS_NEVER_OUT_OF_STOCK => 1,
164
        ]);
165
166
        $I->havePriceProduct([
167
            PriceProductTransfer::SKU_PRODUCT_ABSTRACT => $productConcreteTransfer->getAbstractSkuOrFail(),
168
            PriceProductTransfer::SKU_PRODUCT => $productConcreteTransfer->getSkuOrFail(),
169
            PriceProductTransfer::ID_PRODUCT => $productConcreteTransfer->getIdProductConcreteOrFail(),
170
            PriceProductTransfer::PRICE_TYPE_NAME => CartReorderApiTester::PRICE_TYPE,
171
            PriceProductTransfer::MONEY_VALUE => [
172
                MoneyValueTransfer::NET_AMOUNT => 7777,
173
                MoneyValueTransfer::GROSS_AMOUNT => 8888,
174
            ],
175
        ]);
176
177
        return $productConcreteTransfer;
178
    }
179
180
    /**
181
     * @param \PyzTest\Glue\CartReorder\CartReorderApiTester $I
182
     *
183
     * @return \Generated\Shared\Transfer\SaveOrderTransfer
184
     */
185
    protected function createOrderWithProductBundle(CartReorderApiTester $I): SaveOrderTransfer
186
    {
187
        $itemsData = [
188
            (new ItemBuilder([
189
                ItemTransfer::SKU => $this->productConcreteTransfer->getSkuOrFail(),
190
                ItemTransfer::QUANTITY => 1,
191
            ]))->build()->toArray(),
192
            (new ItemBuilder([
193
                ItemTransfer::SKU => $this->productBundleTransfer->getSkuOrFail(),
194
                ItemTransfer::QUANTITY => 2,
195
            ]))->build()->toArray(),
196
        ];
197
198
        return $I->createOrder($this->customerTransfer, [QuoteTransfer::ITEMS => $itemsData]);
199
    }
200
}
201