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\Carts\RestApi\Fixtures;
11
12
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...
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\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...
15
use PyzTest\Glue\Carts\CartsApiTester;
16
use SprykerTest\Shared\Testify\Fixtures\FixturesBuilderInterface;
17
use SprykerTest\Shared\Testify\Fixtures\FixturesContainerInterface;
18
19
/**
20
 * Auto-generated group annotations
21
 *
22
 * @group PyzTest
23
 * @group Glue
24
 * @group Carts
25
 * @group RestApi
26
 * @group ConvertGuestCartToCustomerCartRestApiFixtures
27
 * Add your own group annotations below this line
28
 * @group EndToEnd
29
 */
30
class ConvertGuestCartToCustomerCartRestApiFixtures implements FixturesBuilderInterface, FixturesContainerInterface
31
{
32
    use CartsRestApiFixturesTrait;
33
34
    /**
35
     * @var string
36
     */
37
    protected const TEST_USERNAME = 'UserConvertGuestCartToCustomerCartRestApiFixtures';
38
39
    /**
40
     * @var string
41
     */
42
    protected const TEST_PASSWORD = 'change123';
43
44
    /**
45
     * @var string
46
     */
47
    protected const ANONYMOUS_PREFIX = 'anonymous:';
48
49
    /**
50
     * @var \Generated\Shared\Transfer\ProductConcreteTransfer
51
     */
52
    protected ProductConcreteTransfer $productConcreteTransfer;
53
54
    /**
55
     * @var \Generated\Shared\Transfer\CustomerTransfer
56
     */
57
    protected CustomerTransfer $customerTransfer;
58
59
    /**
60
     * @var string
61
     */
62
    protected string $guestCustomerReference;
63
64
    /**
65
     * @var \Generated\Shared\Transfer\QuoteTransfer
66
     */
67
    protected QuoteTransfer $guestQuoteTransfer;
68
69
    /**
70
     * @return \Generated\Shared\Transfer\ProductConcreteTransfer
71
     */
72
    public function getProductConcreteTransfer(): ProductConcreteTransfer
73
    {
74
        return $this->productConcreteTransfer;
75
    }
76
77
    /**
78
     * @return \Generated\Shared\Transfer\CustomerTransfer
79
     */
80
    public function getCustomerTransfer(): CustomerTransfer
81
    {
82
        return $this->customerTransfer;
83
    }
84
85
    /**
86
     * @return string
87
     */
88
    public function getGuestCustomerReference(): string
89
    {
90
        return $this->guestCustomerReference;
91
    }
92
93
    /**
94
     * @return \Generated\Shared\Transfer\QuoteTransfer
95
     */
96
    public function getGuestQuoteTransfer(): QuoteTransfer
97
    {
98
        return $this->guestQuoteTransfer;
99
    }
100
101
    /**
102
     * @param \PyzTest\Glue\Carts\CartsApiTester $I
103
     *
104
     * @return \SprykerTest\Shared\Testify\Fixtures\FixturesContainerInterface
105
     */
106
    public function buildFixtures(CartsApiTester $I): FixturesContainerInterface
107
    {
108
        $I->truncateSalesOrderThresholds();
109
110
        $this->createGuestQuote($I);
111
        $this->createCustomer($I);
112
113
        return $this;
114
    }
115
116
    /**
117
     * @param \PyzTest\Glue\Carts\CartsApiTester $I
118
     *
119
     * @return void
120
     */
121
    protected function createGuestQuote(CartsApiTester $I): void
122
    {
123
        $this->productConcreteTransfer = $this->createProduct($I);
124
        $this->guestCustomerReference = $this->createGuestCustomerReference();
125
        $guestCustomerTransfer = (new CustomerTransfer())
126
            ->setCustomerReference(static::ANONYMOUS_PREFIX . $this->guestCustomerReference);
127
        $this->guestQuoteTransfer = $this->createPersistentQuote($I, $guestCustomerTransfer, [$this->productConcreteTransfer]);
128
    }
129
130
    /**
131
     * @param \PyzTest\Glue\Carts\CartsApiTester $I
132
     *
133
     * @return void
134
     */
135
    protected function createCustomer(CartsApiTester $I): void
136
    {
137
        $customerTransfer = $I->haveCustomer([
138
            CustomerTransfer::USERNAME => static::TEST_USERNAME,
139
            CustomerTransfer::PASSWORD => static::TEST_PASSWORD,
140
            CustomerTransfer::NEW_PASSWORD => static::TEST_PASSWORD,
141
        ]);
142
143
        $this->customerTransfer = $I->confirmCustomer($customerTransfer);
144
    }
145
}
146