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

createProductBundle()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 35
Code Lines 21

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 21
c 1
b 0
f 0
dl 0
loc 35
rs 9.584
cc 1
nc 1
nop 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
/**
29
 * Auto-generated group annotations
30
 *
31
 * @group PyzTest
32
 * @group Glue
33
 * @group Carts
34
 * @group RestApi
35
 * @group ProductBundleCartReorderRestApiFixtures
36
 * Add your own group annotations below this line
37
 * @group EndToEnd
38
 */
39
class ProductBundleCartReorderRestApiFixtures implements FixturesBuilderInterface, FixturesContainerInterface
40
{
41
    /**
42
     * @var string
43
     */
44
    protected const TEST_USERNAME = 'ProductBundleCartReorderRestApiFixtures';
45
46
    /**
47
     * @var \Generated\Shared\Transfer\StoreTransfer
48
     */
49
    protected StoreTransfer $storeTransfer;
50
51
    /**
52
     * @var \Generated\Shared\Transfer\CustomerTransfer
53
     */
54
    protected CustomerTransfer $customerTransfer;
55
56
    /**
57
     * @var \Generated\Shared\Transfer\ProductConcreteTransfer
58
     */
59
    protected ProductConcreteTransfer $productConcreteTransfer;
60
61
    /**
62
     * @var \Generated\Shared\Transfer\ProductConcreteTransfer
63
     */
64
    protected ProductConcreteTransfer $bundledProductConcreteTransfer1;
65
66
    /**
67
     * @var \Generated\Shared\Transfer\ProductConcreteTransfer
68
     */
69
    protected ProductConcreteTransfer $bundledProductConcreteTransfer2;
70
71
    /**
72
     * @var \Generated\Shared\Transfer\ProductConcreteTransfer
73
     */
74
    protected ProductConcreteTransfer $productBundleTransfer;
75
76
    /**
77
     * @var \Generated\Shared\Transfer\SaveOrderTransfer
78
     */
79
    protected SaveOrderTransfer $orderWithProductBundle;
80
81
    /**
82
     * @return \Generated\Shared\Transfer\CustomerTransfer
83
     */
84
    public function getCustomerTransfer(): CustomerTransfer
85
    {
86
        return $this->customerTransfer;
87
    }
88
89
    /**
90
     * @return \Generated\Shared\Transfer\ProductConcreteTransfer
91
     */
92
    public function getProductConcreteTransfer(): ProductConcreteTransfer
93
    {
94
        return $this->productConcreteTransfer;
95
    }
96
97
    /**
98
     * @return \Generated\Shared\Transfer\ProductConcreteTransfer
99
     */
100
    public function getBundledProductConcreteTransfer1(): ProductConcreteTransfer
101
    {
102
        return $this->bundledProductConcreteTransfer1;
103
    }
104
105
    /**
106
     * @return \Generated\Shared\Transfer\ProductConcreteTransfer
107
     */
108
    public function getBundledProductConcreteTransfer2(): ProductConcreteTransfer
109
    {
110
        return $this->bundledProductConcreteTransfer2;
111
    }
112
113
    /**
114
     * @return \Generated\Shared\Transfer\ProductConcreteTransfer
115
     */
116
    public function getProductBundleTransfer(): ProductConcreteTransfer
117
    {
118
        return $this->productBundleTransfer;
119
    }
120
121
    /**
122
     * @return \Generated\Shared\Transfer\SaveOrderTransfer
123
     */
124
    public function getOrderWithProductBundle(): SaveOrderTransfer
125
    {
126
        return $this->orderWithProductBundle;
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->productConcreteTransfer = $I->createProductWithPriceAndStock($this->storeTransfer);
141
        $this->bundledProductConcreteTransfer1 = $I->createProductWithPriceAndStock($this->storeTransfer);
142
        $this->bundledProductConcreteTransfer2 = $I->createProductWithPriceAndStock($this->storeTransfer);
143
        $this->productBundleTransfer = $this->createProductBundle($I);
144
        $this->orderWithProductBundle = $this->createOrderWithProductBundle($I);
145
146
        return $this;
147
    }
148
149
    /**
150
     * @param \PyzTest\Glue\CartReorder\CartReorderApiTester $I
151
     *
152
     * @return \Generated\Shared\Transfer\ProductConcreteTransfer
153
     */
154
    protected function createProductBundle(CartReorderApiTester $I): ProductConcreteTransfer
155
    {
156
        $productConcreteTransfer = $I->haveFullProduct();
157
        $productConcreteTransfer = $I->haveProductBundle($productConcreteTransfer, [
158
            ProductBundleTransfer::BUNDLED_PRODUCTS => [
159
                [
160
                    ProductForBundleTransfer::ID_PRODUCT_CONCRETE => $this->bundledProductConcreteTransfer1->getIdProductConcreteOrFail(),
161
                    ProductForBundleTransfer::ID_PRODUCT_BUNDLE => $productConcreteTransfer->getIdProductConcreteOrFail(),
162
                    ProductForBundleTransfer::QUANTITY => 1,
163
                ],
164
                [
165
                    ProductForBundleTransfer::ID_PRODUCT_CONCRETE => $this->bundledProductConcreteTransfer2->getIdProductConcreteOrFail(),
166
                    ProductForBundleTransfer::ID_PRODUCT_BUNDLE => $productConcreteTransfer->getIdProductConcreteOrFail(),
167
                    ProductForBundleTransfer::QUANTITY => 2,
168
                ],
169
            ],
170
        ]);
171
172
        $I->haveProductInStockForStore($this->storeTransfer, [
173
            StockProductTransfer::SKU => $productConcreteTransfer->getSku(),
174
            StockProductTransfer::IS_NEVER_OUT_OF_STOCK => 1,
175
        ]);
176
177
        $I->havePriceProduct([
178
            PriceProductTransfer::SKU_PRODUCT_ABSTRACT => $productConcreteTransfer->getAbstractSkuOrFail(),
179
            PriceProductTransfer::SKU_PRODUCT => $productConcreteTransfer->getSkuOrFail(),
180
            PriceProductTransfer::ID_PRODUCT => $productConcreteTransfer->getIdProductConcreteOrFail(),
181
            PriceProductTransfer::PRICE_TYPE_NAME => CartReorderApiTester::PRICE_TYPE,
182
            PriceProductTransfer::MONEY_VALUE => [
183
                MoneyValueTransfer::NET_AMOUNT => 7777,
184
                MoneyValueTransfer::GROSS_AMOUNT => 8888,
185
            ],
186
        ]);
187
188
        return $productConcreteTransfer;
189
    }
190
191
    /**
192
     * @param \PyzTest\Glue\CartReorder\CartReorderApiTester $I
193
     *
194
     * @return \Generated\Shared\Transfer\SaveOrderTransfer
195
     */
196
    protected function createOrderWithProductBundle(CartReorderApiTester $I): SaveOrderTransfer
197
    {
198
        $itemsData = [
199
            (new ItemBuilder([
200
                ItemTransfer::SKU => $this->productConcreteTransfer->getSkuOrFail(),
201
                ItemTransfer::QUANTITY => 1,
202
            ]))->build()->toArray(),
203
            (new ItemBuilder([
204
                ItemTransfer::SKU => $this->productBundleTransfer->getSkuOrFail(),
205
                ItemTransfer::QUANTITY => 2,
206
            ]))->build()->toArray(),
207
        ];
208
209
        return $I->createOrder($this->customerTransfer, [QuoteTransfer::ITEMS => $itemsData]);
210
    }
211
}
212