Completed
Push — master ( 0541e3...1b0cb6 )
by Ilya
55s queued 18s
created

OrderAmendmentsApiTester   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 85
Duplicated Lines 0 %

Importance

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

6 Methods

Rating   Name   Duplication   Size   Complexity  
A authorizeCustomerToGlue() 0 4 1
A haveProductWithPriceAndStock() 0 24 1
A getConcreteProductPricesUrl() 0 3 1
A assertResponseContainsAmendmentOrderReference() 0 6 1
A getCurrentStore() 0 3 1
A getCartReorderUrl() 0 4 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\OrderAmendments;
11
12
use Generated\Shared\Transfer\CustomerTransfer;
0 ignored issues
show
Bug introduced by
The type Generated\Shared\Transfer\CustomerTransfer was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
13
use Generated\Shared\Transfer\MoneyValueTransfer;
0 ignored issues
show
Bug introduced by
The type Generated\Shared\Transfer\MoneyValueTransfer was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
14
use Generated\Shared\Transfer\PriceProductTransfer;
0 ignored issues
show
Bug introduced by
The type Generated\Shared\Transfer\PriceProductTransfer was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
15
use Generated\Shared\Transfer\ProductConcreteTransfer;
0 ignored issues
show
Bug introduced by
The type Generated\Shared\Transfer\ProductConcreteTransfer was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
16
use Generated\Shared\Transfer\StockProductTransfer;
0 ignored issues
show
Bug introduced by
The type Generated\Shared\Transfer\StockProductTransfer was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
17
use Generated\Shared\Transfer\StoreTransfer;
0 ignored issues
show
Bug introduced by
The type Generated\Shared\Transfer\StoreTransfer was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
18
use Spryker\Glue\CartReorderRestApi\CartReorderRestApiConfig;
19
use SprykerTest\Glue\Testify\Tester\ApiEndToEndTester;
20
21
/**
22
 * Inherited Methods
23
 *
24
 * @method void wantTo($text)
25
 * @method void wantToTest($text)
26
 * @method void execute($callable)
27
 * @method void expectTo($prediction)
28
 * @method void expect($prediction)
29
 * @method void amGoingTo($argumentation)
30
 * @method void am($role)
31
 * @method void lookForwardTo($achieveValue)
32
 * @method void comment($description)
33
 * @method void pause($vars = [])
34
 *
35
 * @SuppressWarnings(PHPMD)
36
 */
37
class OrderAmendmentsApiTester extends ApiEndToEndTester
38
{
39
    use _generated\OrderAmendmentsApiTesterActions;
0 ignored issues
show
Bug introduced by
The type PyzTest\Glue\OrderAmendm...ndmentsApiTesterActions was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
40
41
    /**
42
     * @param \Generated\Shared\Transfer\CustomerTransfer $customerTransfer
43
     *
44
     * @return void
45
     */
46
    public function authorizeCustomerToGlue(CustomerTransfer $customerTransfer): void
47
    {
48
        $oauthResponseTransfer = $this->haveAuthorizationToGlue($customerTransfer);
49
        $this->amBearerAuthenticated($oauthResponseTransfer->getAccessToken());
50
    }
51
52
    /**
53
     * @param string $orderReference
54
     *
55
     * @return void
56
     */
57
    public function assertResponseContainsAmendmentOrderReference(string $orderReference): void
58
    {
59
        $attributes = $this->getDataFromResponseByJsonPath('$.data.attributes');
60
61
        $this->assertArrayHasKey('amendmentOrderReference', $attributes);
62
        $this->assertSame($orderReference, $attributes['amendmentOrderReference']);
63
    }
64
65
    /**
66
     * @return string
67
     */
68
    public function getCartReorderUrl(): string
69
    {
70
        return $this->formatUrl('{cartReorderResource}?include=items', [
71
            'cartReorderResource' => CartReorderRestApiConfig::RESOURCE_CART_REORDER,
72
        ]);
73
    }
74
75
    /**
76
     * @param string $sku
77
     *
78
     * @return string
79
     */
80
    public function getConcreteProductPricesUrl(string $sku): string
81
    {
82
        return $this->formatUrl('concrete-products/{sku}/concrete-product-prices', ['sku' => $sku]);
83
    }
84
85
    /**
86
     * @return \Generated\Shared\Transfer\StoreTransfer
87
     */
88
    public function getCurrentStore(): StoreTransfer
89
    {
90
        return $this->getLocator()->store()->facade()->getCurrentStore();
91
    }
92
93
    /**
94
     * @param int|null $unitPrice
95
     *
96
     * @return \Generated\Shared\Transfer\ProductConcreteTransfer
97
     */
98
    public function haveProductWithPriceAndStock(?int $unitPrice = 10000): ProductConcreteTransfer
99
    {
100
        $storeTransfer = $this->getLocator()->store()->facade()->getCurrentStore();
101
        $productConcreteTransfer = $this->haveFullProduct();
102
103
        $this->haveProductInStockForStore($storeTransfer, [
104
            StockProductTransfer::SKU => $productConcreteTransfer->getSku(),
105
            StockProductTransfer::IS_NEVER_OUT_OF_STOCK => 1,
106
        ]);
107
108
        $priceProductTransfer = $this->havePriceProduct([
109
            PriceProductTransfer::SKU_PRODUCT_ABSTRACT => $productConcreteTransfer->getAbstractSku(),
110
            PriceProductTransfer::SKU_PRODUCT => $productConcreteTransfer->getSku(),
111
            PriceProductTransfer::ID_PRODUCT => $productConcreteTransfer->getIdProductConcrete(),
112
            PriceProductTransfer::PRICE_TYPE_NAME => 'DEFAULT',
113
            PriceProductTransfer::MONEY_VALUE => [
114
                MoneyValueTransfer::NET_AMOUNT => $unitPrice,
115
                MoneyValueTransfer::GROSS_AMOUNT => $unitPrice,
116
            ],
117
        ]);
118
119
        $productConcreteTransfer->addPrice($priceProductTransfer);
120
121
        return $productConcreteTransfer;
122
    }
123
}
124