Passed
Pull Request — master (#729)
by Damir
08:25
created

ProductBundleCartReorderRestApiCest   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 67
Duplicated Lines 0 %

Importance

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
A loadFixtures() 0 6 1
A requestCreateCartReorder() 0 42 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\CartReorder\RestApi;
11
12
use Codeception\Util\HttpCode;
13
use PyzTest\Glue\CartReorder\CartReorderApiTester;
14
use PyzTest\Glue\CartReorder\RestApi\Fixtures\ProductBundleCartReorderRestApiFixtures;
15
use Spryker\Glue\CartReorderRestApi\CartReorderRestApiConfig;
16
17
/**
18
 * Auto-generated group annotations
19
 *
20
 * @group PyzTest
21
 * @group Glue
22
 * @group CartReorder
23
 * @group RestApi
24
 * @group ProductBundleCartReorderRestApiCest
25
 * Add your own group annotations below this line
26
 * @group EndToEnd
27
 */
28
class ProductBundleCartReorderRestApiCest
29
{
30
    /**
31
     * @var \PyzTest\Glue\CartReorder\RestApi\Fixtures\ProductBundleCartReorderRestApiFixtures
32
     */
33
    protected ProductBundleCartReorderRestApiFixtures $fixtures;
34
35
    /**
36
     * @param \PyzTest\Glue\CartReorder\CartReorderApiTester $I
37
     *
38
     * @return void
39
     */
40
    public function loadFixtures(CartReorderApiTester $I): void
41
    {
42
        /** @var \PyzTest\Glue\CartReorder\RestApi\Fixtures\ProductBundleCartReorderRestApiFixtures $fixtures */
43
        $fixtures = $I->loadFixtures(ProductBundleCartReorderRestApiFixtures::class);
44
45
        $this->fixtures = $fixtures;
46
    }
47
48
    /**
49
     * @param \PyzTest\Glue\CartReorder\CartReorderApiTester $I
50
     *
51
     * @return void
52
     */
53
    public function requestCreateCartReorder(CartReorderApiTester $I): void
54
    {
55
        // Arrange
56
        $I->authorizeCustomerToGlue($this->fixtures->getCustomerTransfer());
57
58
        $saveOrderTransfer = $this->fixtures->getOrderWithProductBundle();
59
        $requestPayload = [
60
            'data' => [
61
                'type' => CartReorderRestApiConfig::RESOURCE_CART_REORDER,
62
                'attributes' => [
63
                    'orderReference' => $saveOrderTransfer->getOrderReferenceOrFail(),
64
                ],
65
            ],
66
        ];
67
68
        // Act
69
        $I->sendPost($I->getCartReorderUrl(), $requestPayload);
70
71
        // Assert
72
        $I->seeResponseCodeIs(HttpCode::CREATED);
73
        $I->seeResponseIsJson();
74
        $I->seeResponseMatchesOpenApiSchema();
75
76
        $I->amSure('The returned resource is of correct type.')
77
            ->whenI()
78
            ->seeResponseDataContainsSingleResourceOfType(CartReorderApiTester::RESOURCE_CARTS);
0 ignored issues
show
Bug introduced by
It seems like seeResponseDataContainsSingleResourceOfType() 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

78
            ->/** @scrutinizer ignore-call */ seeResponseDataContainsSingleResourceOfType(CartReorderApiTester::RESOURCE_CARTS);
Loading history...
79
80
        $I->amSure('The returned response includes first item.')
81
            ->whenI()
82
            ->assertResponseContainsItemBySku($this->fixtures->getProductConcreteTransfer()->getSkuOrFail());
0 ignored issues
show
Bug introduced by
It seems like assertResponseContainsItemBySku() 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 */ assertResponseContainsItemBySku($this->fixtures->getProductConcreteTransfer()->getSkuOrFail());
Loading history...
83
        $I->amSure('The first item has correct quantity.')
84
            ->whenI()
85
            ->assertItemHasCorrectQuantity($this->fixtures->getProductConcreteTransfer()->getSkuOrFail(), 1);
0 ignored issues
show
Bug introduced by
It seems like assertItemHasCorrectQuantity() 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 */ assertItemHasCorrectQuantity($this->fixtures->getProductConcreteTransfer()->getSkuOrFail(), 1);
Loading history...
86
87
        $I->amSure('The returned response includes bundle item.')
88
            ->whenI()
89
            ->assertResponseContainsBundleItemBySku($this->fixtures->getProductBundleTransfer()->getSkuOrFail());
0 ignored issues
show
Bug introduced by
It seems like assertResponseContainsBundleItemBySku() 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 */ assertResponseContainsBundleItemBySku($this->fixtures->getProductBundleTransfer()->getSkuOrFail());
Loading history...
90
        $I->amSure('The bundle item has correct quantity.')
91
            ->whenI()
92
            ->assertBundleItemHasCorrectQuantity(
0 ignored issues
show
Bug introduced by
It seems like assertBundleItemHasCorrectQuantity() 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

92
            ->/** @scrutinizer ignore-call */ assertBundleItemHasCorrectQuantity(
Loading history...
93
                $this->fixtures->getProductBundleTransfer()->getSkuOrFail(),
94
                2,
95
            );
96
    }
97
}
98