requestProductConcreteWithProductLabelRelationshipByPatch()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 15
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 5
dl 0
loc 15
rs 10
c 0
b 0
f 0
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\ProductLabels\RestApi;
11
12
use Codeception\Util\HttpCode;
13
use PyzTest\Glue\ProductLabels\ProductLabelsApiTester;
14
use Spryker\Glue\ProductLabelsRestApi\ProductLabelsRestApiConfig;
15
16
/**
17
 * Auto-generated group annotations
18
 *
19
 * @group PyzTest
20
 * @group Glue
21
 * @group ProductLabels
22
 * @group RestApi
23
 * @group ProductConcreteProductLabelsRestApiCest
24
 * Add your own group annotations below this line
25
 * @group EndToEnd
26
 */
27
class ProductConcreteProductLabelsRestApiCest
28
{
29
    /**
30
     * @var \PyzTest\Glue\ProductLabels\RestApi\ProductLabelsRestApiFixtures
31
     */
32
    protected ProductLabelsRestApiFixtures $fixtures;
33
34
    /**
35
     * @param \PyzTest\Glue\ProductLabels\ProductLabelsApiTester $I
36
     *
37
     * @return void
38
     */
39
    public function loadFixtures(ProductLabelsApiTester $I): void
40
    {
41
        /** @var \PyzTest\Glue\ProductLabels\RestApi\ProductLabelsRestApiFixtures $fixtures */
42
        $fixtures = $I->loadFixtures(ProductLabelsRestApiFixtures::class);
43
44
        $this->fixtures = $fixtures;
45
    }
46
47
    /**
48
     * @depends loadFixtures
49
     *
50
     * @param \PyzTest\Glue\ProductLabels\ProductLabelsApiTester $I
51
     *
52
     * @return void
53
     */
54
    public function requestProductConcreteWithProductLabelsRelationship(ProductLabelsApiTester $I): void
55
    {
56
        // Arrange
57
        $idProductLabel = $this->fixtures->getProductLabelTransfer()->getIdProductLabel();
58
        $url = $I->buildProductConcreteUrl(
59
            $this->fixtures->getProductConcreteTransferWithLabel()->getSku(),
60
            [
61
                ProductLabelsRestApiConfig::RESOURCE_PRODUCT_LABELS,
62
            ],
63
        );
64
65
        // Act
66
        $I->sendGET($url);
67
68
        // Assert
69
        $I->seeResponseCodeIs(HttpCode::OK);
70
        $I->seeResponseIsJson();
71
        $I->seeResponseMatchesOpenApiSchema();
72
73
        $I->amSure('The returned resource has product-labels relationship')
74
            ->whenI()
75
            ->seeSingleResourceHasRelationshipByTypeAndId(
0 ignored issues
show
Bug introduced by
It seems like seeSingleResourceHasRelationshipByTypeAndId() must be provided by classes using this trait. How about adding it as abstract method to this trait? ( Ignorable by Annotation )

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

75
            ->/** @scrutinizer ignore-call */ seeSingleResourceHasRelationshipByTypeAndId(
Loading history...
76
                ProductLabelsRestApiConfig::RESOURCE_PRODUCT_LABELS,
77
                (string)$idProductLabel,
78
            );
79
80
        $I->amSure('The returned resource has product-labels include')
81
            ->whenI()
82
            ->seeIncludesContainsResourceByTypeAndId(
0 ignored issues
show
Bug introduced by
It seems like seeIncludesContainsResourceByTypeAndId() must be provided by classes using this trait. How about adding it as abstract method to this trait? ( Ignorable by Annotation )

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

82
            ->/** @scrutinizer ignore-call */ seeIncludesContainsResourceByTypeAndId(
Loading history...
83
                ProductLabelsRestApiConfig::RESOURCE_PRODUCT_LABELS,
84
                (string)$idProductLabel,
85
            );
86
87
        $I->amSure('The include has correct self-link')
88
            ->whenI()
89
            ->seeIncludedResourceByTypeAndIdHasSelfLink(
0 ignored issues
show
Bug introduced by
It seems like seeIncludedResourceByTypeAndIdHasSelfLink() must be provided by classes using this trait. How about adding it as abstract method to this trait? ( Ignorable by Annotation )

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

89
            ->/** @scrutinizer ignore-call */ seeIncludedResourceByTypeAndIdHasSelfLink(
Loading history...
90
                ProductLabelsRestApiConfig::RESOURCE_PRODUCT_LABELS,
91
                (string)$idProductLabel,
92
                $I->buildProductLabelUrl($idProductLabel),
93
            );
94
    }
95
96
    /**
97
     * @depends loadFixtures
98
     *
99
     * @param \PyzTest\Glue\ProductLabels\ProductLabelsApiTester $I
100
     *
101
     * @return void
102
     */
103
    public function requestProductConcreteWithoutProductLabelRelationship(ProductLabelsApiTester $I): void
104
    {
105
        // Arrange
106
        $url = $I->buildProductConcreteUrl(
107
            $this->fixtures->getProductConcreteTransfer()->getSku(),
108
            [
109
                ProductLabelsRestApiConfig::RESOURCE_PRODUCT_LABELS,
110
            ],
111
        );
112
113
        // Act
114
        $I->sendGET($url);
115
116
        // Assert
117
        $I->seeResponseCodeIs(HttpCode::OK);
118
        $I->seeResponseIsJson();
119
        $I->seeResponseMatchesOpenApiSchema();
120
121
        $I->amSure('The returned resource does not have product-labels includes')
122
            ->whenI()
123
            ->dontSeeIncludesContainResourceOfType(ProductLabelsRestApiConfig::RESOURCE_PRODUCT_LABELS);
0 ignored issues
show
Bug introduced by
It seems like dontSeeIncludesContainResourceOfType() must be provided by classes using this trait. How about adding it as abstract method to this trait? ( Ignorable by Annotation )

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

123
            ->/** @scrutinizer ignore-call */ dontSeeIncludesContainResourceOfType(ProductLabelsRestApiConfig::RESOURCE_PRODUCT_LABELS);
Loading history...
124
    }
125
126
    /**
127
     * @depends loadFixtures
128
     *
129
     * @param \PyzTest\Glue\ProductLabels\ProductLabelsApiTester $I
130
     *
131
     * @return void
132
     */
133
    public function requestProductConcreteWithProductLabelRelationshipByPost(ProductLabelsApiTester $I): void
134
    {
135
        // Arrange
136
        $url = $I->buildProductConcreteUrl(
137
            $this->fixtures->getProductConcreteTransferWithLabel()->getSku(),
138
            [
139
                ProductLabelsRestApiConfig::RESOURCE_PRODUCT_LABELS,
140
            ],
141
        );
142
143
        // Act
144
        $I->sendPOST($url);
145
146
        // Assert
147
        $I->seeResponseCodeIs(HttpCode::NOT_FOUND);
148
        $I->seeResponseIsJson();
149
    }
150
151
    /**
152
     * @depends loadFixtures
153
     *
154
     * @param \PyzTest\Glue\ProductLabels\ProductLabelsApiTester $I
155
     *
156
     * @return void
157
     */
158
    public function requestProductConcreteWithProductLabelRelationshipByPatch(ProductLabelsApiTester $I): void
159
    {
160
        // Arrange
161
        $url = $I->buildProductConcreteUrl(
162
            $this->fixtures->getProductConcreteTransferWithLabel()->getSku(),
163
            [
164
                ProductLabelsRestApiConfig::RESOURCE_PRODUCT_LABELS,
165
            ],
166
        );
167
168
        // Act
169
        $I->sendPATCH($url);
170
171
        // Assert
172
        $I->seeResponseCodeIs(HttpCode::NOT_FOUND);
173
    }
174
}
175