requestTheNonExistingProductConcretePrices()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 9
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 4
dl 0
loc 9
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\PriceProducts\RestApi;
11
12
use Codeception\Util\HttpCode;
13
use PyzTest\Glue\PriceProducts\PriceProductsApiTester;
14
15
/**
16
 * Auto-generated group annotations
17
 *
18
 * @group PyzTest
19
 * @group Glue
20
 * @group PriceProducts
21
 * @group RestApi
22
 * @group PriceProductConcreteRestApiCest
23
 * Add your own group annotations below this line
24
 * @group EndToEnd
25
 */
26
class PriceProductConcreteRestApiCest
27
{
28
    /**
29
     * @var \PyzTest\Glue\PriceProducts\RestApi\PriceProductsRestApiFixtures
30
     */
31
    protected PriceProductsRestApiFixtures $fixtures;
32
33
    /**
34
     * @param \PyzTest\Glue\PriceProducts\PriceProductsApiTester $I
35
     *
36
     * @return void
37
     */
38
    public function loadFixtures(PriceProductsApiTester $I): void
39
    {
40
        /** @var \PyzTest\Glue\PriceProducts\RestApi\PriceProductsRestApiFixtures $fixtures */
41
        $fixtures = $I->loadFixtures(PriceProductsRestApiFixtures::class);
42
43
        $this->fixtures = $fixtures;
44
    }
45
46
    /**
47
     * @depends loadFixtures
48
     *
49
     * @param \PyzTest\Glue\PriceProducts\PriceProductsApiTester $I
50
     *
51
     * @return void
52
     */
53
    public function requestTheNonExistingProductConcretePrices(PriceProductsApiTester $I): void
54
    {
55
        // Act
56
        $I->sendGET('concrete-products/non-exist/concrete-product-prices');
57
58
        // Assert
59
        $I->seeResponseCodeIs(HttpCode::NOT_FOUND);
60
        $I->seeResponseIsJson();
61
        $I->seeResponseMatchesOpenApiSchema();
62
    }
63
64
    /**
65
     * @depends loadFixtures
66
     *
67
     * @param \PyzTest\Glue\PriceProducts\PriceProductsApiTester $I
68
     *
69
     * @return void
70
     */
71
    public function requestProductConcretePricesWithoutId(PriceProductsApiTester $I): void
72
    {
73
        // Act
74
        $I->sendGET('concrete-product-prices');
75
76
        // Assert
77
        $I->seeResponseCodeIs(HttpCode::BAD_REQUEST);
78
        $I->seeResponseIsJson();
79
    }
80
81
    /**
82
     * @depends loadFixtures
83
     *
84
     * @param \PyzTest\Glue\PriceProducts\PriceProductsApiTester $I
85
     *
86
     * @return void
87
     */
88
    public function requestExistingProductConcretePrices(PriceProductsApiTester $I): void
89
    {
90
        // Act
91
        $I->sendGET(
92
            $I->formatUrl(
93
                'concrete-products/{ProductConcreteSku}/concrete-product-prices',
94
                [
95
                    'ProductConcreteSku' => $this->fixtures->getProductConcreteTransfer()->getSku(),
96
                ],
97
            ),
98
        );
99
100
        // Assert
101
        $I->seeResponseCodeIs(HttpCode::OK);
102
        $I->seeResponseIsJson();
103
        $I->seeResponseMatchesOpenApiSchema();
104
105
        $I->amSure('Returned resource is of type concrete-product-prices')
106
            ->whenI()
107
            ->seeResponseDataContainsResourceCollectionOfTypeWithSizeOf('concrete-product-prices', 1);
0 ignored issues
show
Bug introduced by
It seems like seeResponseDataContainsR...ctionOfTypeWithSizeOf() 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

107
            ->/** @scrutinizer ignore-call */ seeResponseDataContainsResourceCollectionOfTypeWithSizeOf('concrete-product-prices', 1);
Loading history...
108
109
        $I->amSure('Returned resource has correct id')
110
            ->whenI()
111
            ->seeResourceCollectionHasResourceWithId($this->fixtures->getProductConcreteTransfer()->getSku());
0 ignored issues
show
Bug introduced by
It seems like seeResourceCollectionHasResourceWithId() 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 */ seeResourceCollectionHasResourceWithId($this->fixtures->getProductConcreteTransfer()->getSku());
Loading history...
112
    }
113
}
114