|
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\AvailabilityNotifications\RestApi; |
|
11
|
|
|
|
|
12
|
|
|
use Codeception\Util\HttpCode; |
|
13
|
|
|
use PyzTest\Glue\AvailabilityNotifications\AvailabilityNotificationsRestApiTester; |
|
14
|
|
|
use PyzTest\Glue\AvailabilityNotifications\RestApi\Fixtures\AvailabilityNotificationsApiFixtures; |
|
15
|
|
|
|
|
16
|
|
|
/** |
|
17
|
|
|
* Auto-generated group annotations |
|
18
|
|
|
* |
|
19
|
|
|
* @group PyzTest |
|
20
|
|
|
* @group Glue |
|
21
|
|
|
* @group AvailabilityNotifications |
|
22
|
|
|
* @group RestApi |
|
23
|
|
|
* @group AvailabilityNotificationsRestApiCest |
|
24
|
|
|
* Add your own group annotations below this line |
|
25
|
|
|
* @group EndToEnd |
|
26
|
|
|
*/ |
|
27
|
|
|
class AvailabilityNotificationsRestApiCest |
|
28
|
|
|
{ |
|
29
|
|
|
protected AvailabilityNotificationsApiFixtures $fixtures; |
|
30
|
|
|
|
|
31
|
|
|
public function loadFixtures(AvailabilityNotificationsRestApiTester $I): void |
|
32
|
|
|
{ |
|
33
|
|
|
/** @var \PyzTest\Glue\AvailabilityNotifications\RestApi\Fixtures\AvailabilityNotificationsApiFixtures $fixtures */ |
|
34
|
|
|
$fixtures = $I->loadFixtures(AvailabilityNotificationsApiFixtures::class); |
|
35
|
|
|
|
|
36
|
|
|
$this->fixtures = $fixtures; |
|
37
|
|
|
} |
|
38
|
|
|
|
|
39
|
|
|
public function requestCustomerAvailabilityNotifications(AvailabilityNotificationsRestApiTester $I): void |
|
40
|
|
|
{ |
|
41
|
|
|
// Arrange |
|
42
|
|
|
$customerTransfer = $this->fixtures->getCustomerTransfer(); |
|
43
|
|
|
|
|
44
|
|
|
$url = $I->buildCustomerAvailabilityNotificationsUrl($customerTransfer->getCustomerReference()); |
|
45
|
|
|
|
|
46
|
|
|
$oauthResponseTransfer = $I->haveAuthorizationToGlue($customerTransfer); |
|
47
|
|
|
$I->amBearerAuthenticated($oauthResponseTransfer->getAccessToken()); |
|
48
|
|
|
|
|
49
|
|
|
// Act |
|
50
|
|
|
$I->sendGET($url); |
|
51
|
|
|
|
|
52
|
|
|
// Assert |
|
53
|
|
|
$I->seeResponseCodeIs(HttpCode::OK); |
|
54
|
|
|
$I->seeResponseIsJson(); |
|
55
|
|
|
$I->seeResponseMatchesOpenApiSchema(); |
|
56
|
|
|
} |
|
57
|
|
|
|
|
58
|
|
|
public function requestCustomerAvailabilityNotificationsAuthorizationError(AvailabilityNotificationsRestApiTester $I): void |
|
59
|
|
|
{ |
|
60
|
|
|
// Arrange |
|
61
|
|
|
$customerTransfer = $this->fixtures->getCustomerTransfer(); |
|
62
|
|
|
|
|
63
|
|
|
$url = $I->buildCustomerAvailabilityNotificationsUrl('wrongCustomerReference'); |
|
64
|
|
|
|
|
65
|
|
|
$oauthResponseTransfer = $I->haveAuthorizationToGlue($customerTransfer); |
|
66
|
|
|
$I->amBearerAuthenticated($oauthResponseTransfer->getAccessToken()); |
|
67
|
|
|
|
|
68
|
|
|
// Act |
|
69
|
|
|
$I->sendGET($url); |
|
70
|
|
|
|
|
71
|
|
|
// Assert |
|
72
|
|
|
$I->seeResponseCodeIs(HttpCode::FORBIDDEN); |
|
73
|
|
|
$I->seeResponseIsJson(); |
|
74
|
|
|
$I->seeResponseMatchesOpenApiSchema(); |
|
75
|
|
|
} |
|
76
|
|
|
} |
|
77
|
|
|
|