UrlsRestApiFixtures::getProductConcreteTransfer()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 1
dl 0
loc 3
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 0
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\Urls\RestApi;
11
12
use Generated\Shared\Transfer\ProductAbstractTransfer;
13
use Generated\Shared\Transfer\ProductConcreteTransfer;
14
use Generated\Shared\Transfer\ProductUrlTransfer;
15
use Generated\Shared\Transfer\UrlTransfer;
16
use PyzTest\Glue\Urls\UrlsRestApiTester;
17
use Spryker\Zed\Locale\Business\LocaleFacade;
18
use Spryker\Zed\Url\Business\UrlFacade;
19
use SprykerTest\Shared\Testify\Fixtures\FixturesBuilderInterface;
20
use SprykerTest\Shared\Testify\Fixtures\FixturesContainerInterface;
21
22
/**
23
 * Auto-generated group annotations
24
 *
25
 * @group PyzTest
26
 * @group Glue
27
 * @group Urls
28
 * @group RestApi
29
 * @group UrlsRestApiFixtures
30
 * Add your own group annotations below this line
31
 * @group EndToEnd
32
 */
33
class UrlsRestApiFixtures implements FixturesBuilderInterface, FixturesContainerInterface
34
{
35
    /**
36
     * @var \Generated\Shared\Transfer\ProductConcreteTransfer
37
     */
38
    protected ProductConcreteTransfer $productConcreteTransfer;
39
40
    /**
41
     * @var \Generated\Shared\Transfer\ProductUrlTransfer
42
     */
43
    protected ProductUrlTransfer $productUrlTransfer;
44
45
    /**
46
     * @var \Generated\Shared\Transfer\UrlTransfer
47
     */
48
    protected UrlTransfer $categoryUrlTransfer;
49
50
    /**
51
     * @return \Generated\Shared\Transfer\ProductConcreteTransfer
52
     */
53
    public function getProductConcreteTransfer(): ProductConcreteTransfer
54
    {
55
        return $this->productConcreteTransfer;
56
    }
57
58
    /**
59
     * @return \Generated\Shared\Transfer\ProductUrlTransfer
60
     */
61
    public function getProductUrlTransfer(): ProductUrlTransfer
62
    {
63
        return $this->productUrlTransfer;
64
    }
65
66
    /**
67
     * @param \PyzTest\Glue\Urls\UrlsRestApiTester $I
68
     *
69
     * @return \SprykerTest\Shared\Testify\Fixtures\FixturesContainerInterface
70
     */
71
    public function buildFixtures(UrlsRestApiTester $I): FixturesContainerInterface
72
    {
73
        $this->createProductConcrete($I);
74
        $this->createProductUrl($I);
75
        $this->createCategoryUrl($I);
76
77
        return $this;
78
    }
79
80
    /**
81
     * @param \PyzTest\Glue\Urls\UrlsRestApiTester $I
82
     *
83
     * @return void
84
     */
85
    protected function createProductConcrete(UrlsRestApiTester $I): void
86
    {
87
        $this->productConcreteTransfer = $I->haveFullProduct();
88
    }
89
90
    /**
91
     * @param \PyzTest\Glue\Urls\UrlsRestApiTester $I
92
     *
93
     * @return void
94
     */
95
    protected function createProductUrl(UrlsRestApiTester $I): void
96
    {
97
        $productAbstractTransfer = (new ProductAbstractTransfer())
98
            ->setIdProductAbstract($this->productConcreteTransfer->getFkProductAbstract());
99
100
        $this->productUrlTransfer = $I->getProductFacade()->getProductUrl($productAbstractTransfer);
101
    }
102
103
    /**
104
     * @param \PyzTest\Glue\Urls\UrlsRestApiTester $I
105
     *
106
     * @return void
107
     */
108
    protected function createCategoryUrl(UrlsRestApiTester $I): void
109
    {
110
        $categoryTransfer = $I->haveLocalizedCategory();
111
112
        $storeTransfer = $I->getLocator()->store()->facade()->getCurrentStore();
113
114
        $I->haveCategoryStoreRelation(
115
            $categoryTransfer->getIdCategory(),
116
            $storeTransfer->getIdStore(),
117
        );
118
119
        $this->categoryUrlTransfer = (new UrlFacade())
0 ignored issues
show
Deprecated Code introduced by
The function Spryker\Zed\Url\Business...tegoryNodeIdAndLocale() has been deprecated: Will be removed with next major release. Category bundle handles logic internally. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-deprecated  annotation

119
        $this->categoryUrlTransfer = /** @scrutinizer ignore-deprecated */ (new UrlFacade())

This function has been deprecated. The supplier of the function has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the function will be removed and what other function to use instead.

Loading history...
120
            ->getResourceUrlByCategoryNodeIdAndLocale(
121
                $categoryTransfer->getCategoryNode()->getIdCategoryNode(),
122
                (new LocaleFacade())->getCurrentLocale(),
123
            );
124
    }
125
}
126