GetCollectionPickingListsBackendJsonApiCest   A
last analyzed

Complexity

Total Complexity 14

Size/Duplication

Total Lines 547
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 14
eloc 260
dl 0
loc 547
rs 10
c 0
b 0
f 0

14 Methods

Rating   Name   Duplication   Size   Complexity  
A requestReturnsCollectionWithIncludedPickingListItemsAndSalesShipmentsRelations() 0 42 1
A requestReturnsEmptyCollectionWhenUserIsNotWarehouseUser() 0 23 1
A requestReturnsEmptyCollectionWhenUserDoNotHaveWarehouseAssignment() 0 23 1
A requestReturnsCollectionWithIncludedPickingListItemsAndSalesOrdersRelations() 0 42 1
A requestReturnsCollectionWithIncludedPickingListItemsAndConcreteProductsRelations() 0 36 1
A requestReturnsCollectionWithIncludedWarehouseRelations() 0 23 1
A requestReturnsCollectionWithIncludedPickingListItemsAndConcreteProductsAndConcreteProductImageSetsRelations() 0 44 1
A loadFixtures() 0 5 1
A requestReturnsCollectionWithIncludedPickingListItemsRelations() 0 29 1
A requestReturnsCollectionFilteredByPickingStartedStatus() 0 33 1
A requestReturnsCollectionWithIncludedUsersRelations() 0 23 1
A requestReturnsUnauthorizedErrorResponseWhenAuthTokenIsNotProvided() 0 9 1
A requestReturnsCollectionOfPickingListsResources() 0 43 1
A requestReturnsCollectionFilteredByReadyForPickingStatus() 0 33 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\PickingListsBackend\JsonApi;
11
12
use Codeception\Util\HttpCode;
13
use PyzTest\Glue\PickingListsBackend\JsonApi\Fixtures\PickingListsBackendJsonApiFixtures;
14
use PyzTest\Glue\PickingListsBackend\PickingListsBackendApiTester;
15
use Spryker\Glue\PickingListsBackendApi\PickingListsBackendApiConfig;
16
use Spryker\Glue\ProductImageSetsBackendApi\ProductImageSetsBackendApiConfig;
17
use Spryker\Glue\ProductsBackendApi\ProductsBackendApiConfig;
18
use Spryker\Glue\SalesOrdersBackendApi\SalesOrdersBackendApiConfig;
19
use Spryker\Glue\ShipmentsBackendApi\ShipmentsBackendApiConfig;
20
use Spryker\Glue\UsersBackendApi\UsersBackendApiConfig;
21
use Spryker\Glue\WarehousesBackendApi\WarehousesBackendApiConfig;
22
use Spryker\Shared\PickingList\PickingListConfig;
23
24
/**
25
 * Auto-generated group annotations
26
 *
27
 * @group PyzTest
28
 * @group Glue
29
 * @group PickingListsBackend
30
 * @group JsonApi
31
 * @group GetCollectionPickingListsBackendJsonApiCest
32
 * Add your own group annotations below this line
33
 * @group EndToEnd
34
 */
35
class GetCollectionPickingListsBackendJsonApiCest
36
{
37
    /**
38
     * @var \PyzTest\Glue\PickingListsBackend\JsonApi\Fixtures\PickingListsBackendJsonApiFixtures
39
     */
40
    protected PickingListsBackendJsonApiFixtures $fixtures;
41
42
    /**
43
     * @param \PyzTest\Glue\PickingListsBackend\PickingListsBackendApiTester $I
44
     *
45
     * @return void
46
     */
47
    public function loadFixtures(PickingListsBackendApiTester $I): void
48
    {
49
        /** @var \PyzTest\Glue\PickingListsBackend\JsonApi\Fixtures\PickingListsBackendJsonApiFixtures $fixtures */
50
        $fixtures = $I->loadFixtures(PickingListsBackendJsonApiFixtures::class);
51
        $this->fixtures = $fixtures;
52
    }
53
54
    /**
55
     * @depends loadFixtures
56
     *
57
     * @param \PyzTest\Glue\PickingListsBackend\PickingListsBackendApiTester $I
58
     *
59
     * @return void
60
     */
61
    public function requestReturnsCollectionOfPickingListsResources(PickingListsBackendApiTester $I): void
62
    {
63
        //Arrange
64
        $oauthResponseTransfer = $I->havePasswordAuthorizationToBackendApi($this->fixtures->getWarehouseUserTransfer());
65
        $I->amBearerAuthenticated($oauthResponseTransfer->getAccessToken());
66
67
        //Act
68
        $I->sendJsonApiGet(
69
            $I->formatUrl(PickingListsBackendApiConfig::RESOURCE_PICKING_LISTS),
70
        );
71
72
        //Assert
73
        $I->seeJsonApiResponseCodeIs(HttpCode::OK);
74
        $I->seeResponseIsJson();
75
        $I->seeResponseMatchesOpenApiSchema();
76
77
        $I->amSure('The returned resource contains collection of picking lists with correct size')
78
            ->whenI()
79
            ->seeJsonApiResponseDataContainsResourceCollectionOfTypeWithSizeOf(
0 ignored issues
show
Bug introduced by
It seems like seeJsonApiResponseDataCo...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

79
            ->/** @scrutinizer ignore-call */ seeJsonApiResponseDataContainsResourceCollectionOfTypeWithSizeOf(
Loading history...
80
                PickingListsBackendApiConfig::RESOURCE_PICKING_LISTS,
81
                2,
82
            );
83
        $I->amSure('The returned resource collection contains correct picking list')
84
            ->whenI()
85
            ->seeJsonApiResourceCollectionHasResourceWithId(
0 ignored issues
show
Bug introduced by
It seems like seeJsonApiResourceCollectionHasResourceWithId() 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 */ seeJsonApiResourceCollectionHasResourceWithId(
Loading history...
86
                $this->fixtures->getReadyForPickingPickingListTransfer()->getUuidOrFail(),
87
            );
88
        $I->amSure('The returned resource has correct self-link')
89
            ->whenI()
90
            ->seeJsonApiResourceByIdHasSelfLink(
0 ignored issues
show
Bug introduced by
It seems like seeJsonApiResourceByIdHasSelfLink() 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

90
            ->/** @scrutinizer ignore-call */ seeJsonApiResourceByIdHasSelfLink(
Loading history...
91
                $this->fixtures->getReadyForPickingPickingListTransfer()->getUuidOrFail(),
92
                $I->getGetPickingListUrl($this->fixtures->getReadyForPickingPickingListTransfer()),
93
            );
94
        $I->amSure('The returned resource has correct self-link')
95
            ->whenI()
96
            ->seeJsonApiResourceByIdHasSelfLink(
97
                $this->fixtures->getPickingStartedPickingListTransfer()->getUuidOrFail(),
98
                $I->getGetPickingListUrl($this->fixtures->getPickingStartedPickingListTransfer()),
99
            );
100
        $I->amSure('The returned resource collection has correct self-link')
101
            ->whenI()
102
            ->seeJsonApiResponseLinksContainsSelfLink(
0 ignored issues
show
Bug introduced by
It seems like seeJsonApiResponseLinksContainsSelfLink() 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

102
            ->/** @scrutinizer ignore-call */ seeJsonApiResponseLinksContainsSelfLink(
Loading history...
103
                $I->formatFullUrl(PickingListsBackendApiConfig::RESOURCE_PICKING_LISTS),
104
            );
105
    }
106
107
    /**
108
     * @depends loadFixtures
109
     *
110
     * @param \PyzTest\Glue\PickingListsBackend\PickingListsBackendApiTester $I
111
     *
112
     * @return void
113
     */
114
    public function requestReturnsCollectionFilteredByReadyForPickingStatus(PickingListsBackendApiTester $I): void
115
    {
116
        //Arrange
117
        $oauthResponseTransfer = $I->havePasswordAuthorizationToBackendApi($this->fixtures->getWarehouseUserTransfer());
118
        $I->amBearerAuthenticated($oauthResponseTransfer->getAccessToken());
119
120
        $url = $I->formatFullUrl('{resourcePickingLists}?filter[picking-lists.status]={pickingListStatus}', [
121
            'resourcePickingLists' => PickingListsBackendApiConfig::RESOURCE_PICKING_LISTS,
122
            'pickingListStatus' => PickingListConfig::STATUS_READY_FOR_PICKING,
123
        ]);
124
125
        //Act
126
        $I->sendJsonApiGet($url);
127
128
        //Assert
129
        $I->seeJsonApiResponseCodeIs(HttpCode::OK);
130
        $I->seeResponseIsJson();
131
        $I->seeResponseMatchesOpenApiSchema();
132
133
        $I->amSure('The returned resource contains collection of picking lists with correct size')
134
            ->whenI()
135
            ->seeJsonApiResponseDataContainsResourceCollectionOfTypeWithSizeOf(
136
                PickingListsBackendApiConfig::RESOURCE_PICKING_LISTS,
137
                1,
138
            );
139
        $I->amSure('The returned resource collection contains correct picking list')
140
            ->whenI()
141
            ->seeJsonApiResourceCollectionHasResourceWithId(
142
                $this->fixtures->getReadyForPickingPickingListTransfer()->getUuidOrFail(),
143
            );
144
        $I->amSure('The returned resource has correct self-link')
145
            ->whenI()
146
            ->seeJsonApiResponseLinksContainsSelfLink($url);
147
    }
148
149
    /**
150
     * @depends loadFixtures
151
     *
152
     * @param \PyzTest\Glue\PickingListsBackend\PickingListsBackendApiTester $I
153
     *
154
     * @return void
155
     */
156
    public function requestReturnsCollectionFilteredByPickingStartedStatus(PickingListsBackendApiTester $I): void
157
    {
158
        //Arrange
159
        $oauthResponseTransfer = $I->havePasswordAuthorizationToBackendApi($this->fixtures->getWarehouseUserTransfer());
160
        $I->amBearerAuthenticated($oauthResponseTransfer->getAccessToken());
161
162
        $url = $I->formatFullUrl('{resourcePickingLists}?filter[picking-lists.status]={pickingListStatus}', [
163
            'resourcePickingLists' => PickingListsBackendApiConfig::RESOURCE_PICKING_LISTS,
164
            'pickingListStatus' => PickingListConfig::STATUS_PICKING_STARTED,
165
        ]);
166
167
        //Act
168
        $I->sendJsonApiGet($url);
169
170
        //Assert
171
        $I->seeJsonApiResponseCodeIs(HttpCode::OK);
172
        $I->seeResponseIsJson();
173
        $I->seeResponseMatchesOpenApiSchema();
174
175
        $I->amSure('The returned resource contains collection of picking lists with correct size')
176
            ->whenI()
177
            ->seeJsonApiResponseDataContainsResourceCollectionOfTypeWithSizeOf(
178
                PickingListsBackendApiConfig::RESOURCE_PICKING_LISTS,
179
                1,
180
            );
181
        $I->amSure('The returned resource collection contains correct picking list')
182
            ->whenI()
183
            ->seeJsonApiResourceCollectionHasResourceWithId(
184
                $this->fixtures->getPickingStartedPickingListTransfer()->getUuidOrFail(),
185
            );
186
        $I->amSure('The returned resource has correct self-link')
187
            ->whenI()
188
            ->seeJsonApiResponseLinksContainsSelfLink($url);
189
    }
190
191
    /**
192
     * @depends loadFixtures
193
     *
194
     * @param \PyzTest\Glue\PickingListsBackend\PickingListsBackendApiTester $I
195
     *
196
     * @return void
197
     */
198
    public function requestReturnsCollectionWithIncludedPickingListItemsRelations(PickingListsBackendApiTester $I): void
199
    {
200
        //Arrange
201
        $oauthResponseTransfer = $I->havePasswordAuthorizationToBackendApi($this->fixtures->getWarehouseUserTransfer());
202
        $I->amBearerAuthenticated($oauthResponseTransfer->getAccessToken());
203
204
        $url = $I->getGetCollectionPickingListUrl([
205
            PickingListsBackendApiConfig::RESOURCE_PICKING_LIST_ITEMS,
206
        ]);
207
208
        //Act
209
        $I->sendJsonApiGet($url);
210
211
        //Assert
212
        $I->seeJsonApiResponseCodeIs(HttpCode::OK);
213
        $I->seeResponseIsJson();
214
        $I->seeResponseMatchesOpenApiSchema();
215
216
        $I->amSure('The returned resource contains included picking list items')
217
            ->whenI()
218
            ->seeJsonApiIncludesContainsResourceByTypeAndId(
0 ignored issues
show
Bug introduced by
It seems like seeJsonApiIncludesContainsResourceByTypeAndId() 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

218
            ->/** @scrutinizer ignore-call */ seeJsonApiIncludesContainsResourceByTypeAndId(
Loading history...
219
                PickingListsBackendApiConfig::RESOURCE_PICKING_LIST_ITEMS,
220
                $this->fixtures->getReadyForPickingPickingListTransfer()->getPickingListItems()->getIterator()->current()->getUuidOrFail(),
221
            );
222
        $I->amSure('The returned resource contains included picking list items')
223
            ->whenI()
224
            ->seeJsonApiIncludesContainsResourceByTypeAndId(
225
                PickingListsBackendApiConfig::RESOURCE_PICKING_LIST_ITEMS,
226
                $this->fixtures->getPickingStartedPickingListTransfer()->getPickingListItems()->getIterator()->current()->getUuidOrFail(),
227
            );
228
    }
229
230
    /**
231
     * @depends loadFixtures
232
     *
233
     * @param \PyzTest\Glue\PickingListsBackend\PickingListsBackendApiTester $I
234
     *
235
     * @return void
236
     */
237
    public function requestReturnsCollectionWithIncludedPickingListItemsAndSalesOrdersRelations(PickingListsBackendApiTester $I): void
238
    {
239
        //Arrange
240
        $oauthResponseTransfer = $I->havePasswordAuthorizationToBackendApi($this->fixtures->getWarehouseUserTransfer());
241
        $I->amBearerAuthenticated($oauthResponseTransfer->getAccessToken());
242
243
        $url = $I->getGetCollectionPickingListUrl([
244
            PickingListsBackendApiConfig::RESOURCE_PICKING_LIST_ITEMS,
245
            SalesOrdersBackendApiConfig::RESOURCE_SALES_ORDERS,
246
        ]);
247
248
        //Act
249
        $I->sendJsonApiGet($url);
250
251
        //Assert
252
        $I->seeJsonApiResponseCodeIs(HttpCode::OK);
253
        $I->seeResponseIsJson();
254
        $I->seeResponseMatchesOpenApiSchema();
255
256
        $I->amSure('The returned resource contains included picking list items')
257
            ->whenI()
258
            ->seeJsonApiIncludesContainsResourceByTypeAndId(
259
                PickingListsBackendApiConfig::RESOURCE_PICKING_LIST_ITEMS,
260
                $this->fixtures->getReadyForPickingPickingListTransfer()->getPickingListItems()->getIterator()->current()->getUuidOrFail(),
261
            );
262
        $I->amSure('The returned resource contains included picking list items')
263
            ->whenI()
264
            ->seeJsonApiIncludesContainsResourceByTypeAndId(
265
                PickingListsBackendApiConfig::RESOURCE_PICKING_LIST_ITEMS,
266
                $this->fixtures->getPickingStartedPickingListTransfer()->getPickingListItems()->getIterator()->current()->getUuidOrFail(),
267
            );
268
        $I->amSure('The returned resource contains included sales orders')
269
            ->whenI()
270
            ->seeJsonApiIncludesContainsResourceByTypeAndId(
271
                SalesOrdersBackendApiConfig::RESOURCE_SALES_ORDERS,
272
                $this->fixtures->getOrderTransfer1()->getOrderReferenceOrFail(),
273
            );
274
        $I->amSure('The returned resource contains included sales orders')
275
            ->whenI()
276
            ->seeJsonApiIncludesContainsResourceByTypeAndId(
277
                SalesOrdersBackendApiConfig::RESOURCE_SALES_ORDERS,
278
                $this->fixtures->getOrderTransfer2()->getOrderReferenceOrFail(),
279
            );
280
    }
281
282
    /**
283
     * @depends loadFixtures
284
     *
285
     * @param \PyzTest\Glue\PickingListsBackend\PickingListsBackendApiTester $I
286
     *
287
     * @return void
288
     */
289
    public function requestReturnsCollectionWithIncludedPickingListItemsAndSalesShipmentsRelations(PickingListsBackendApiTester $I): void
290
    {
291
        //Arrange
292
        $oauthResponseTransfer = $I->havePasswordAuthorizationToBackendApi($this->fixtures->getWarehouseUserTransfer());
293
        $I->amBearerAuthenticated($oauthResponseTransfer->getAccessToken());
294
295
        $url = $I->getGetCollectionPickingListUrl([
296
            PickingListsBackendApiConfig::RESOURCE_PICKING_LIST_ITEMS,
297
            ShipmentsBackendApiConfig::RESOURCE_SALES_SHIPMENTS,
298
        ]);
299
300
        //Act
301
        $I->sendJsonApiGet($url);
302
303
        //Assert
304
        $I->seeJsonApiResponseCodeIs(HttpCode::OK);
305
        $I->seeResponseIsJson();
306
        $I->seeResponseMatchesOpenApiSchema();
307
308
        $I->amSure('The returned resource contains included picking list items')
309
            ->whenI()
310
            ->seeJsonApiIncludesContainsResourceByTypeAndId(
311
                PickingListsBackendApiConfig::RESOURCE_PICKING_LIST_ITEMS,
312
                $this->fixtures->getReadyForPickingPickingListTransfer()->getPickingListItems()->getIterator()->current()->getUuidOrFail(),
313
            );
314
        $I->amSure('The returned resource contains included picking list items')
315
            ->whenI()
316
            ->seeJsonApiIncludesContainsResourceByTypeAndId(
317
                PickingListsBackendApiConfig::RESOURCE_PICKING_LIST_ITEMS,
318
                $this->fixtures->getPickingStartedPickingListTransfer()->getPickingListItems()->getIterator()->current()->getUuidOrFail(),
319
            );
320
        $I->amSure('The returned resource contains included sales shipments')
321
            ->whenI()
322
            ->seeJsonApiIncludesContainsResourceByTypeAndId(
323
                ShipmentsBackendApiConfig::RESOURCE_SALES_SHIPMENTS,
324
                $this->fixtures->getOrderTransfer1()->getItems()->getIterator()->current()->getShipmentOrFail()->getUuidOrFail(),
325
            );
326
        $I->amSure('The returned resource contains included sales shipments')
327
            ->whenI()
328
            ->seeJsonApiIncludesContainsResourceByTypeAndId(
329
                ShipmentsBackendApiConfig::RESOURCE_SALES_SHIPMENTS,
330
                $this->fixtures->getOrderTransfer2()->getItems()->getIterator()->current()->getShipmentOrFail()->getUuidOrFail(),
331
            );
332
    }
333
334
    /**
335
     * @depends loadFixtures
336
     *
337
     * @param \PyzTest\Glue\PickingListsBackend\PickingListsBackendApiTester $I
338
     *
339
     * @return void
340
     */
341
    public function requestReturnsCollectionWithIncludedPickingListItemsAndConcreteProductsRelations(PickingListsBackendApiTester $I): void
342
    {
343
        //Arrange
344
        $oauthResponseTransfer = $I->havePasswordAuthorizationToBackendApi($this->fixtures->getWarehouseUserTransfer());
345
        $I->amBearerAuthenticated($oauthResponseTransfer->getAccessToken());
346
347
        $url = $I->getGetCollectionPickingListUrl([
348
            PickingListsBackendApiConfig::RESOURCE_PICKING_LIST_ITEMS,
349
            ProductsBackendApiConfig::RESOURCE_CONCRETE_PRODUCTS,
350
        ]);
351
352
        //Act
353
        $I->sendJsonApiGet($url);
354
355
        //Assert
356
        $I->seeJsonApiResponseCodeIs(HttpCode::OK);
357
        $I->seeResponseIsJson();
358
        $I->seeResponseMatchesOpenApiSchema();
359
360
        $I->amSure('The returned resource contains included picking list items')
361
            ->whenI()
362
            ->seeJsonApiIncludesContainsResourceByTypeAndId(
363
                PickingListsBackendApiConfig::RESOURCE_PICKING_LIST_ITEMS,
364
                $this->fixtures->getReadyForPickingPickingListTransfer()->getPickingListItems()->getIterator()->current()->getUuidOrFail(),
365
            );
366
        $I->amSure('The returned resource contains included picking list items')
367
            ->whenI()
368
            ->seeJsonApiIncludesContainsResourceByTypeAndId(
369
                PickingListsBackendApiConfig::RESOURCE_PICKING_LIST_ITEMS,
370
                $this->fixtures->getPickingStartedPickingListTransfer()->getPickingListItems()->getIterator()->current()->getUuidOrFail(),
371
            );
372
        $I->amSure('The returned resource contains included concrete products')
373
            ->whenI()
374
            ->seeJsonApiIncludesContainsResourceByTypeAndId(
375
                ProductsBackendApiConfig::RESOURCE_CONCRETE_PRODUCTS,
376
                $this->fixtures->getProductConcreteTransfer()->getSkuOrFail(),
377
            );
378
    }
379
380
    /**
381
     * @depends loadFixtures
382
     *
383
     * @param \PyzTest\Glue\PickingListsBackend\PickingListsBackendApiTester $I
384
     *
385
     * @return void
386
     */
387
    public function requestReturnsCollectionWithIncludedPickingListItemsAndConcreteProductsAndConcreteProductImageSetsRelations(
388
        PickingListsBackendApiTester $I,
389
    ): void {
390
        //Arrange
391
        $oauthResponseTransfer = $I->havePasswordAuthorizationToBackendApi($this->fixtures->getWarehouseUserTransfer());
392
        $I->amBearerAuthenticated($oauthResponseTransfer->getAccessToken());
393
394
        $url = $I->getGetCollectionPickingListUrl([
395
            PickingListsBackendApiConfig::RESOURCE_PICKING_LIST_ITEMS,
396
            ProductsBackendApiConfig::RESOURCE_CONCRETE_PRODUCTS,
397
            ProductImageSetsBackendApiConfig::RESOURCE_CONCRETE_PRODUCT_IMAGE_SETS,
398
        ]);
399
400
        //Act
401
        $I->sendJsonApiGet($url);
402
403
        //Assert
404
        $I->seeJsonApiResponseCodeIs(HttpCode::OK);
405
        $I->seeResponseIsJson();
406
        $I->seeResponseMatchesOpenApiSchema();
407
408
        $I->amSure('The returned resource contains included picking list items')
409
            ->whenI()
410
            ->seeJsonApiIncludesContainsResourceByTypeAndId(
411
                PickingListsBackendApiConfig::RESOURCE_PICKING_LIST_ITEMS,
412
                $this->fixtures->getReadyForPickingPickingListTransfer()->getPickingListItems()->getIterator()->current()->getUuidOrFail(),
413
            );
414
        $I->amSure('The returned resource contains included picking list items')
415
            ->whenI()
416
            ->seeJsonApiIncludesContainsResourceByTypeAndId(
417
                PickingListsBackendApiConfig::RESOURCE_PICKING_LIST_ITEMS,
418
                $this->fixtures->getPickingStartedPickingListTransfer()->getPickingListItems()->getIterator()->current()->getUuidOrFail(),
419
            );
420
        $I->amSure('The returned resource contains included concrete products')
421
            ->whenI()
422
            ->seeJsonApiIncludesContainsResourceByTypeAndId(
423
                ProductsBackendApiConfig::RESOURCE_CONCRETE_PRODUCTS,
424
                $this->fixtures->getProductConcreteTransfer()->getSkuOrFail(),
425
            );
426
        $I->amSure('The returned resource contains included concrete product image sets')
427
            ->whenI()
428
            ->seeJsonApiIncludesContainsResourceByTypeAndId(
429
                ProductImageSetsBackendApiConfig::RESOURCE_CONCRETE_PRODUCT_IMAGE_SETS,
430
                $this->fixtures->getProductConcreteTransfer()->getImageSets()->getIterator()->current()->getSkuOrFail(),
431
            );
432
    }
433
434
    /**
435
     * @depends loadFixtures
436
     *
437
     * @param \PyzTest\Glue\PickingListsBackend\PickingListsBackendApiTester $I
438
     *
439
     * @return void
440
     */
441
    public function requestReturnsCollectionWithIncludedUsersRelations(PickingListsBackendApiTester $I): void
442
    {
443
        //Arrange
444
        $oauthResponseTransfer = $I->havePasswordAuthorizationToBackendApi($this->fixtures->getWarehouseUserTransfer());
445
        $I->amBearerAuthenticated($oauthResponseTransfer->getAccessToken());
446
447
        $url = $I->getGetCollectionPickingListUrl([
448
            UsersBackendApiConfig::RESOURCE_TYPE_USERS,
449
        ]);
450
451
        //Act
452
        $I->sendJsonApiGet($url);
453
454
        //Assert
455
        $I->seeJsonApiResponseCodeIs(HttpCode::OK);
456
        $I->seeResponseIsJson();
457
        $I->seeResponseMatchesOpenApiSchema();
458
459
        $I->amSure('The returned resource contains included users')
460
            ->whenI()
461
            ->seeJsonApiIncludesContainsResourceByTypeAndId(
462
                UsersBackendApiConfig::RESOURCE_TYPE_USERS,
463
                $this->fixtures->getWarehouseUserTransfer()->getUuidOrFail(),
464
            );
465
    }
466
467
    /**
468
     * @depends loadFixtures
469
     *
470
     * @param \PyzTest\Glue\PickingListsBackend\PickingListsBackendApiTester $I
471
     *
472
     * @return void
473
     */
474
    public function requestReturnsCollectionWithIncludedWarehouseRelations(PickingListsBackendApiTester $I): void
475
    {
476
        //Arrange
477
        $oauthResponseTransfer = $I->havePasswordAuthorizationToBackendApi($this->fixtures->getWarehouseUserTransfer());
478
        $I->amBearerAuthenticated($oauthResponseTransfer->getAccessToken());
479
480
        $url = $I->getGetCollectionPickingListUrl([
481
            WarehousesBackendApiConfig::RESOURCE_WAREHOUSES,
482
        ]);
483
484
        //Act
485
        $I->sendJsonApiGet($url);
486
487
        //Assert
488
        $I->seeJsonApiResponseCodeIs(HttpCode::OK);
489
        $I->seeResponseIsJson();
490
        $I->seeResponseMatchesOpenApiSchema();
491
492
        $I->amSure('The returned resource contains included warehouses')
493
            ->whenI()
494
            ->seeJsonApiIncludesContainsResourceByTypeAndId(
495
                WarehousesBackendApiConfig::RESOURCE_WAREHOUSES,
496
                $this->fixtures->getWarehouseTransfer()->getUuidOrFail(),
497
            );
498
    }
499
500
    /**
501
     * @depends loadFixtures
502
     *
503
     * @param \PyzTest\Glue\PickingListsBackend\PickingListsBackendApiTester $I
504
     *
505
     * @return void
506
     */
507
    public function requestReturnsEmptyCollectionWhenUserDoNotHaveWarehouseAssignment(PickingListsBackendApiTester $I): void
508
    {
509
        //Arrange
510
        $oauthResponseTransfer = $I->havePasswordAuthorizationToBackendApi($this->fixtures->getWarehouseUserTransferWithoutAssignment());
511
        $I->amBearerAuthenticated($oauthResponseTransfer->getAccessToken());
512
513
        //Act
514
        $I->sendJsonApiGet(
515
            $I->formatUrl(PickingListsBackendApiConfig::RESOURCE_PICKING_LISTS),
516
        );
517
518
        //Assert
519
        $I->seeJsonApiResponseCodeIs(HttpCode::OK);
520
        $I->seeResponseIsJson();
521
        $I->seeResponseMatchesOpenApiSchema();
522
523
        $I->amSure('The returned resource contains empty collection')
524
            ->whenI()
525
            ->seeJsonApiResponseDataContainsEmptyCollection();
0 ignored issues
show
Bug introduced by
It seems like seeJsonApiResponseDataContainsEmptyCollection() 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

525
            ->/** @scrutinizer ignore-call */ seeJsonApiResponseDataContainsEmptyCollection();
Loading history...
526
        $I->amSure('The returned resource has correct self-link')
527
            ->whenI()
528
            ->seeJsonApiResponseLinksContainsSelfLink(
529
                $I->formatFullUrl(PickingListsBackendApiConfig::RESOURCE_PICKING_LISTS),
530
            );
531
    }
532
533
    /**
534
     * @depends loadFixtures
535
     *
536
     * @param \PyzTest\Glue\PickingListsBackend\PickingListsBackendApiTester $I
537
     *
538
     * @return void
539
     */
540
    public function requestReturnsEmptyCollectionWhenUserIsNotWarehouseUser(PickingListsBackendApiTester $I): void
541
    {
542
        //Arrange
543
        $oauthResponseTransfer = $I->havePasswordAuthorizationToBackendApi($this->fixtures->getUserTransfer());
544
        $I->amBearerAuthenticated($oauthResponseTransfer->getAccessToken());
545
546
        //Act
547
        $I->sendJsonApiGet(
548
            $I->formatUrl(PickingListsBackendApiConfig::RESOURCE_PICKING_LISTS),
549
        );
550
551
        //Assert
552
        $I->seeJsonApiResponseCodeIs(HttpCode::OK);
553
        $I->seeResponseIsJson();
554
        $I->seeResponseMatchesOpenApiSchema();
555
556
        $I->amSure('The returned resource contains empty collection')
557
            ->whenI()
558
            ->seeJsonApiResponseDataContainsEmptyCollection();
559
        $I->amSure('The returned resource has correct self-link')
560
            ->whenI()
561
            ->seeJsonApiResponseLinksContainsSelfLink(
562
                $I->formatFullUrl(PickingListsBackendApiConfig::RESOURCE_PICKING_LISTS),
563
            );
564
    }
565
566
    /**
567
     * @depends loadFixtures
568
     *
569
     * @param \PyzTest\Glue\PickingListsBackend\PickingListsBackendApiTester $I
570
     *
571
     * @return void
572
     */
573
    public function requestReturnsUnauthorizedErrorResponseWhenAuthTokenIsNotProvided(PickingListsBackendApiTester $I): void
574
    {
575
        //Act
576
        $I->sendJsonApiGet(
577
            $I->formatUrl(PickingListsBackendApiConfig::RESOURCE_PICKING_LISTS),
578
        );
579
580
        //Assert
581
        $I->seeJsonApiResponseCodeIs(HttpCode::FORBIDDEN);
582
    }
583
}
584