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
    protected ProductLabelsRestApiFixtures $fixtures;
30
31
    public function loadFixtures(ProductLabelsApiTester $I): void
32
    {
33
        /** @var \PyzTest\Glue\ProductLabels\RestApi\ProductLabelsRestApiFixtures $fixtures */
34
        $fixtures = $I->loadFixtures(ProductLabelsRestApiFixtures::class);
35
36
        $this->fixtures = $fixtures;
37
    }
38
39
    /**
40
     * @depends loadFixtures
41
     *
42
     * @param \PyzTest\Glue\ProductLabels\ProductLabelsApiTester $I
43
     */
44
    public function requestProductConcreteWithProductLabelsRelationship(ProductLabelsApiTester $I): void
45
    {
46
        // Arrange
47
        $idProductLabel = $this->fixtures->getProductLabelTransfer()->getIdProductLabel();
48
        $url = $I->buildProductConcreteUrl(
49
            $this->fixtures->getProductConcreteTransferWithLabel()->getSku(),
50
            [
51
                ProductLabelsRestApiConfig::RESOURCE_PRODUCT_LABELS,
52
            ],
53
        );
54
55
        // Act
56
        $I->sendGET($url);
57
58
        // Assert
59
        $I->seeResponseCodeIs(HttpCode::OK);
60
        $I->seeResponseIsJson();
61
        $I->seeResponseMatchesOpenApiSchema();
62
63
        $I->amSure('The returned resource has product-labels relationship')
64
            ->whenI()
65
            ->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

65
            ->/** @scrutinizer ignore-call */ seeSingleResourceHasRelationshipByTypeAndId(
Loading history...
66
                ProductLabelsRestApiConfig::RESOURCE_PRODUCT_LABELS,
67
                (string)$idProductLabel,
68
            );
69
70
        $I->amSure('The returned resource has product-labels include')
71
            ->whenI()
72
            ->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

72
            ->/** @scrutinizer ignore-call */ seeIncludesContainsResourceByTypeAndId(
Loading history...
73
                ProductLabelsRestApiConfig::RESOURCE_PRODUCT_LABELS,
74
                (string)$idProductLabel,
75
            );
76
77
        $I->amSure('The include has correct self-link')
78
            ->whenI()
79
            ->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

79
            ->/** @scrutinizer ignore-call */ seeIncludedResourceByTypeAndIdHasSelfLink(
Loading history...
80
                ProductLabelsRestApiConfig::RESOURCE_PRODUCT_LABELS,
81
                (string)$idProductLabel,
82
                $I->buildProductLabelUrl($idProductLabel),
83
            );
84
    }
85
86
    /**
87
     * @depends loadFixtures
88
     *
89
     * @param \PyzTest\Glue\ProductLabels\ProductLabelsApiTester $I
90
     */
91
    public function requestProductConcreteWithoutProductLabelRelationship(ProductLabelsApiTester $I): void
92
    {
93
        // Arrange
94
        $url = $I->buildProductConcreteUrl(
95
            $this->fixtures->getProductConcreteTransfer()->getSku(),
96
            [
97
                ProductLabelsRestApiConfig::RESOURCE_PRODUCT_LABELS,
98
            ],
99
        );
100
101
        // Act
102
        $I->sendGET($url);
103
104
        // Assert
105
        $I->seeResponseCodeIs(HttpCode::OK);
106
        $I->seeResponseIsJson();
107
        $I->seeResponseMatchesOpenApiSchema();
108
109
        $I->amSure('The returned resource does not have product-labels includes')
110
            ->whenI()
111
            ->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

111
            ->/** @scrutinizer ignore-call */ dontSeeIncludesContainResourceOfType(ProductLabelsRestApiConfig::RESOURCE_PRODUCT_LABELS);
Loading history...
112
    }
113
114
    /**
115
     * @depends loadFixtures
116
     *
117
     * @param \PyzTest\Glue\ProductLabels\ProductLabelsApiTester $I
118
     */
119
    public function requestProductConcreteWithProductLabelRelationshipByPost(ProductLabelsApiTester $I): void
120
    {
121
        // Arrange
122
        $url = $I->buildProductConcreteUrl(
123
            $this->fixtures->getProductConcreteTransferWithLabel()->getSku(),
124
            [
125
                ProductLabelsRestApiConfig::RESOURCE_PRODUCT_LABELS,
126
            ],
127
        );
128
129
        // Act
130
        $I->sendPOST($url);
131
132
        // Assert
133
        $I->seeResponseCodeIs(HttpCode::NOT_FOUND);
134
        $I->seeResponseIsJson();
135
    }
136
137
    /**
138
     * @depends loadFixtures
139
     *
140
     * @param \PyzTest\Glue\ProductLabels\ProductLabelsApiTester $I
141
     */
142
    public function requestProductConcreteWithProductLabelRelationshipByPatch(ProductLabelsApiTester $I): void
143
    {
144
        // Arrange
145
        $url = $I->buildProductConcreteUrl(
146
            $this->fixtures->getProductConcreteTransferWithLabel()->getSku(),
147
            [
148
                ProductLabelsRestApiConfig::RESOURCE_PRODUCT_LABELS,
149
            ],
150
        );
151
152
        // Act
153
        $I->sendPATCH($url);
154
155
        // Assert
156
        $I->seeResponseCodeIs(HttpCode::NOT_FOUND);
157
    }
158
}
159