Passed
Pull Request — master (#356)
by Denys
05:13
created

ProductAbstractPriceProductVolumesRestApiCest   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 63
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 2
eloc 26
dl 0
loc 63
rs 10
c 1
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A loadFixtures() 0 6 1
A requestProductAbstractPrices() 0 36 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
namespace PyzTest\Glue\PriceProductVolumes\RestApi;
9
10
use Codeception\Util\HttpCode;
11
use PyzTest\Glue\PriceProductVolumes\PriceProductVolumesApiTester;
12
use PyzTest\Glue\PriceProductVolumes\RestApi\Fixtures\PriceProductVolumesRestApiFixtures;
13
use Spryker\Glue\ProductPricesRestApi\ProductPricesRestApiConfig;
14
use Spryker\Glue\ProductsRestApi\ProductsRestApiConfig;
15
16
/**
17
 * Auto-generated group annotations
18
 *
19
 * @group PyzTest
20
 * @group Glue
21
 * @group PriceProductVolumes
22
 * @group RestApi
23
 * @group ProductAbstractPriceProductVolumesRestApiCest
24
 * Add your own group annotations below this line
25
 * @group EndToEnd
26
 */
27
class ProductAbstractPriceProductVolumesRestApiCest
28
{
29
    /**
30
     * @var \PyzTest\Glue\PriceProductVolumes\RestApi\Fixtures\PriceProductVolumesRestApiFixtures
31
     */
32
    protected PriceProductVolumesRestApiFixtures $fixtures;
33
34
    /**
35
     * @param \PyzTest\Glue\PriceProductVolumes\PriceProductVolumesApiTester $I
36
     *
37
     * @return void
38
     */
39
    public function loadFixtures(PriceProductVolumesApiTester $I): void
40
    {
41
        /** @var \PyzTest\Glue\PriceProductVolumes\RestApi\Fixtures\PriceProductVolumesRestApiFixtures $fixtures */
42
        $fixtures = $I->loadFixtures(PriceProductVolumesRestApiFixtures::class);
43
44
        $this->fixtures = $fixtures;
45
    }
46
47
    /**
48
     * @depends loadFixtures
49
     *
50
     * @param \PyzTest\Glue\PriceProductVolumes\PriceProductVolumesApiTester $I
51
     *
52
     * @return void
53
     */
54
    public function requestProductAbstractPrices(PriceProductVolumesApiTester $I): void
55
    {
56
        // Arrange
57
        $customerTransfer = $this->fixtures->getCustomerTransfer();
58
        $I->authorizeCustomerToGlue($customerTransfer);
59
60
        // Act
61
        $I->sendGET($I->formatFullUrl(
62
            '{resourceAbstractProducts}/{productAbstractSku}/{resourceAbstractProductPrices}',
63
            [
64
                'resourceAbstractProducts' => ProductsRestApiConfig::RESOURCE_ABSTRACT_PRODUCTS,
65
                'resourceAbstractProductPrices' => ProductPricesRestApiConfig::RESOURCE_ABSTRACT_PRODUCT_PRICES,
66
                'productAbstractSku' => $this->fixtures->getProductConcreteTransfer()->getAbstractSku(),
67
            ],
68
        ));
69
70
        // Assert
71
        $I->seeResponseCodeIs(HttpCode::OK);
72
        $I->seeResponseIsJson();
73
        $I->seeResponseMatchesOpenApiSchema();
74
75
        $I->amSure('Returned resource is of type abstract-product-prices')
76
            ->whenI()
77
            ->seeResponseDataContainsResourceCollectionOfTypeWithSizeOf(ProductPricesRestApiConfig::RESOURCE_ABSTRACT_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

77
            ->/** @scrutinizer ignore-call */ seeResponseDataContainsResourceCollectionOfTypeWithSizeOf(ProductPricesRestApiConfig::RESOURCE_ABSTRACT_PRODUCT_PRICES, 1);
Loading history...
78
79
        $I->amSure('Returned resource has correct id')
80
            ->whenI()
81
            ->seeResourceCollectionHasResourceWithId($this->fixtures->getProductConcreteTransfer()->getAbstractSku());
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

81
            ->/** @scrutinizer ignore-call */ seeResourceCollectionHasResourceWithId($this->fixtures->getProductConcreteTransfer()->getAbstractSku());
Loading history...
82
83
        $I->amSure('Returned resource has volume prices')
84
            ->whenI()
85
            ->seeResourceCollectionHasAttribute($this->fixtures::VOLUME_PRICE_ATTRIBUTE_JSON_PATH);
0 ignored issues
show
Bug introduced by
It seems like seeResourceCollectionHasAttribute() 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

85
            ->/** @scrutinizer ignore-call */ seeResourceCollectionHasAttribute($this->fixtures::VOLUME_PRICE_ATTRIBUTE_JSON_PATH);
Loading history...
86
87
        $I->amSure('Returned volume prices are correct')
88
            ->whenI()
89
            ->seeVolumePricesEqualToExpectedValue($this->fixtures::VOLUME_PRICE_DATA);
0 ignored issues
show
Bug introduced by
It seems like seeVolumePricesEqualToExpectedValue() 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 */ seeVolumePricesEqualToExpectedValue($this->fixtures::VOLUME_PRICE_DATA);
Loading history...
90
    }
91
}
92