RelatedProductsRestApiFixtures   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 77
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 4
eloc 31
dl 0
loc 77
rs 10
c 0
b 0
f 0

4 Methods

Rating   Name   Duplication   Size   Complexity  
A getAnotherProductConcreteTransfer() 0 3 1
A buildFixtures() 0 5 1
A createRelationBetweenProducts() 0 32 1
A getProductConcreteTransfer() 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\RelatedProducts\RestApi;
11
12
use Generated\Shared\DataBuilder\StoreRelationBuilder;
0 ignored issues
show
Bug introduced by
The type Generated\Shared\DataBuilder\StoreRelationBuilder 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\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...
14
use Generated\Shared\Transfer\StoreRelationTransfer;
0 ignored issues
show
Bug introduced by
The type Generated\Shared\Transfer\StoreRelationTransfer 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\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...
16
use PyzTest\Glue\RelatedProducts\RelatedProductsApiTester;
17
use Spryker\Shared\ProductRelation\ProductRelationTypes;
18
use SprykerTest\Shared\Testify\Fixtures\FixturesBuilderInterface;
19
use SprykerTest\Shared\Testify\Fixtures\FixturesContainerInterface;
20
21
/**
22
 * Auto-generated group annotations
23
 *
24
 * @group PyzTest
25
 * @group Glue
26
 * @group RelatedProducts
27
 * @group RestApi
28
 * @group RelatedProductsRestApiFixtures
29
 * Add your own group annotations below this line
30
 * @group EndToEnd
31
 */
32
class RelatedProductsRestApiFixtures implements FixturesBuilderInterface, FixturesContainerInterface
33
{
34
    /**
35
     * @var \Generated\Shared\Transfer\ProductConcreteTransfer
36
     */
37
    protected ProductConcreteTransfer $productConcreteTransfer;
38
39
    /**
40
     * @var \Generated\Shared\Transfer\ProductConcreteTransfer
41
     */
42
    protected ProductConcreteTransfer $anotherProductConcreteTransfer;
43
44
    /**
45
     * @return \Generated\Shared\Transfer\ProductConcreteTransfer
46
     */
47
    public function getProductConcreteTransfer(): ProductConcreteTransfer
48
    {
49
        return $this->productConcreteTransfer;
50
    }
51
52
    /**
53
     * @return \Generated\Shared\Transfer\ProductConcreteTransfer
54
     */
55
    public function getAnotherProductConcreteTransfer(): ProductConcreteTransfer
56
    {
57
        return $this->anotherProductConcreteTransfer;
58
    }
59
60
    /**
61
     * @param \PyzTest\Glue\RelatedProducts\RelatedProductsApiTester $I
62
     *
63
     * @return \SprykerTest\Shared\Testify\Fixtures\FixturesContainerInterface
64
     */
65
    public function buildFixtures(RelatedProductsApiTester $I): FixturesContainerInterface
66
    {
67
        $this->createRelationBetweenProducts($I);
68
69
        return $this;
70
    }
71
72
    /**
73
     * @param \PyzTest\Glue\RelatedProducts\RelatedProductsApiTester $I
74
     *
75
     * @return void
76
     */
77
    protected function createRelationBetweenProducts(RelatedProductsApiTester $I): void
78
    {
79
        $storeTransfer = $I->haveStore([
80
            StoreTransfer::NAME => 'DE',
81
            StoreTransfer::DEFAULT_CURRENCY_ISO_CODE => 'EUR',
82
            StoreTransfer::AVAILABLE_CURRENCY_ISO_CODES => ['EUR'],
83
        ]);
84
        $storeRelationTransfer = (new StoreRelationBuilder())->seed([
85
            StoreRelationTransfer::ID_STORES => [
86
                $storeTransfer->getIdStore(),
87
            ],
88
            StoreRelationTransfer::STORES => [
89
                $storeTransfer,
90
            ],
91
        ])->build();
92
93
        $this->productConcreteTransfer = $I->haveFullProduct();
94
        $this->anotherProductConcreteTransfer = $I->haveFullProduct();
95
96
        $I->haveProductRelation(
97
            $this->anotherProductConcreteTransfer->getAbstractSku(),
98
            $this->productConcreteTransfer->getFkProductAbstract(),
99
            uniqid('key-', false),
100
            ProductRelationTypes::TYPE_RELATED_PRODUCTS,
101
            $storeRelationTransfer,
102
        );
103
        $I->haveProductRelation(
104
            $this->productConcreteTransfer->getAbstractSku(),
105
            $this->anotherProductConcreteTransfer->getFkProductAbstract(),
106
            uniqid('key-', false),
107
            ProductRelationTypes::TYPE_RELATED_PRODUCTS,
108
            $storeRelationTransfer,
109
        );
110
    }
111
}
112