2
2
3
3
class OrdersCest
4
4
{
5
- public function testThatACustomerShouldBeActivatedToPlaceAnOrder (ApiTester $ I )
5
+ public function testThatACustomerShouldBeActivatedAndHaveNoMissingInformationToPlaceAnOrder (ApiTester $ I )
6
6
{
7
7
list ($ token ) = $ I ->sendRegistrationRequest ();
8
8
$ orderDetails = $ this ->getOrderDetails ($ I , $ token );
@@ -12,14 +12,21 @@ public function testThatACustomerShouldBeActivatedToPlaceAnOrder(ApiTester $I)
12
12
13
13
list ($ token ) = $ I ->amAnActivatedCustomer ();
14
14
$ I ->sendApiPostWithToken ($ token , 'orders ' , $ orderDetails );
15
+ $ I ->seeErrorResponse (403 , 'missingCustomerInformation ' );
16
+
17
+ list ($ token , $ customerId ) = $ I ->amAnActivatedCustomerWithNoMissingInformation ();
18
+ $ I ->sendApiPutWithToken ($ token , "customers/ $ customerId " , [
19
+ 'firstName ' => 'Jean ' ,
20
+ 'lastName ' => 'Jacques ' ,
21
+ 'phoneNumber ' => '33605040302 ' ,
22
+ ]);
23
+ $ I ->sendApiPostWithToken ($ token , 'orders ' , $ orderDetails );
15
24
$ I ->seeResponseCodeIs (201 );
16
25
}
17
26
18
27
public function testThatTheRestaurantReceiveAnEmailAndASmsWhenAnOrderIsPlaced (ApiTester $ I )
19
28
{
20
- list ($ token ) = $ I ->amAnActivatedCustomer ();
21
- $ orderDetails = $ this ->getOrderDetails ($ I , $ token );
22
- $ I ->sendApiPostWithToken ($ token , 'orders ' , $ orderDetails );
29
+ list ($ token , $ orderId , $ restaurantCapacity , $ orderDetails , $ customerId ) = $ I ->createGroupOrder ();
23
30
$ productFormatId = array_keys ($ orderDetails ['productFormats ' ])[0 ];
24
31
$ restaurantEmail = $ this ->getRestaurantEmailFromProductFormat ($ productFormatId );
25
32
$ I ->assertSame ('restaurants.orderHasBeenPlaced ' , $ I ->grabFirstMailId ());
@@ -29,7 +36,7 @@ public function testThatTheRestaurantReceiveAnEmailAndASmsWhenAnOrderIsPlaced(Ap
29
36
30
37
public function testThatTheFoodRushDurationMustBeValid (ApiTester $ I )
31
38
{
32
- list ($ token ) = $ I ->amAnActivatedCustomer ();
39
+ list ($ token ) = $ I ->amAnActivatedCustomerWithNoMissingInformation ();
33
40
$ orderDetails = $ this ->getOrderDetails ($ I , $ token , ['foodRushDurationInMinutes ' => 70 ]);
34
41
35
42
$ I ->sendApiPostWithToken ($ token , 'orders ' , $ orderDetails );
@@ -42,24 +49,20 @@ public function testThatTheFoodRushDurationMustBeValid(ApiTester $I)
42
49
43
50
public function testThatTheOrderCannotBeEmpty (ApiTester $ I )
44
51
{
45
- list ($ token ) = $ I ->amAnActivatedCustomer ();
46
-
47
- $ variants = [
48
- ['productFormats ' => []],
49
- ['productFormats ' => [1 => 0 ]],
50
- ];
52
+ list ($ token ) = $ I ->amAnActivatedCustomerWithNoMissingInformation ();
51
53
52
- foreach ($ variants as $ variant ) {
53
- $ orderDetails = $ this ->getOrderDetails ($ I , $ token , $ variant );
54
+ $ orderDetails = $ this ->getOrderDetails ($ I , $ token , ['productFormats ' => []]);
55
+ $ I ->sendApiPostWithToken ($ token , 'orders ' , $ orderDetails );
56
+ $ I ->seeErrorResponse (400 , 'missingProductFormats ' );
54
57
55
- $ I -> sendApiPostWithToken ( $ token , ' orders ' , $ orderDetails );
56
- $ I ->seeErrorResponse ( 422 , 'noProductFormats ' );
57
- }
58
+ $ orderDetails = $ this -> getOrderDetails ( $ I , $ token , [ ' productFormats ' => [ 1 => 0 ]] );
59
+ $ I ->sendApiPostWithToken ( $ token , 'orders ' , $ orderDetails );
60
+ $ I -> seeErrorResponse ( 422 , ' noProductFormats ' );
58
61
}
59
62
60
63
public function testThatTheProductFormatsMustExist (ApiTester $ I )
61
64
{
62
- list ($ token ) = $ I ->amAnActivatedCustomer ();
65
+ list ($ token ) = $ I ->amAnActivatedCustomerWithNoMissingInformation ();
63
66
$ orderDetails = $ this ->getOrderDetails ($ I , $ token , ['productFormats ' => [66666 => 1 ]]);
64
67
65
68
$ I ->sendApiPostWithToken ($ token , 'orders ' , $ orderDetails );
@@ -68,7 +71,7 @@ public function testThatTheProductFormatsMustExist(ApiTester $I)
68
71
69
72
public function testThatTheAnOrderCannotBePlacedOnAClosedRestaurant (ApiTester $ I )
70
73
{
71
- list ($ token ) = $ I ->amAnActivatedCustomer ();
74
+ list ($ token ) = $ I ->amAnActivatedCustomerWithNoMissingInformation ();
72
75
$ products = $ this ->getProducts ($ I , $ token , ['around ' => true , 'opened ' => false ], function ($ restaurants ) {
73
76
foreach ($ restaurants as $ restaurant ) {
74
77
if ($ restaurant ['name ' ] == 'Toujours fermé ' ) {
@@ -85,7 +88,7 @@ public function testThatTheAnOrderCannotBePlacedOnAClosedRestaurant(ApiTester $I
85
88
86
89
public function testThatTheRestaurantMustBeCloseEnough (ApiTester $ I )
87
90
{
88
- list ($ token ) = $ I ->amAnActivatedCustomer ();
91
+ list ($ token ) = $ I ->amAnActivatedCustomerWithNoMissingInformation ();
89
92
90
93
$ latitude = 0 ;
91
94
$ longitude = 0 ;
@@ -117,7 +120,7 @@ function ($restaurants) use ($latitude, $longitude) {
117
120
118
121
public function testThatTheProductFormatsMustBelongToTheSameRestaurant (ApiTester $ I )
119
122
{
120
- list ($ token ) = $ I ->amAnActivatedCustomer ();
123
+ list ($ token ) = $ I ->amAnActivatedCustomerWithNoMissingInformation ();
121
124
$ I ->sendApiGetWithToken ($ token , 'restaurants ' );
122
125
123
126
foreach ($ I ->grabDataFromResponse () as $ restaurant ) {
@@ -148,7 +151,7 @@ function () use ($wrongRestaurantId) {
148
151
149
152
public function testThatTheGroupOrderMustExceedTheMinimumPrice (ApiTester $ I )
150
153
{
151
- list ($ token ) = $ I ->amAnActivatedCustomer ();
154
+ list ($ token ) = $ I ->amAnActivatedCustomerWithNoMissingInformation ();
152
155
$ options = ['around ' => true , 'opened ' => true ];
153
156
$ minimumPrice = 0 ;
154
157
@@ -177,7 +180,7 @@ public function testThatTheGroupOrderMustExceedTheMinimumPrice(ApiTester $I)
177
180
178
181
public function testThatTheOrderShouldNotExceedRestaurantDeliveryCapacity (ApiTester $ I )
179
182
{
180
- list ($ token ) = $ I ->amAnActivatedCustomer ();
183
+ list ($ token ) = $ I ->amAnActivatedCustomerWithNoMissingInformation ();
181
184
$ options = ['around ' => true , 'opened ' => true ];
182
185
$ deliveryCapacity = 0 ;
183
186
@@ -206,7 +209,7 @@ public function testThatTheOrderShouldNotExceedRestaurantDeliveryCapacity(ApiTes
206
209
207
210
public function testThatARestaurantCanHaveOnlyOneGroupOrderAtTheSameTime (ApiTester $ I )
208
211
{
209
- list ($ token ) = $ I ->amAnActivatedCustomer ();
212
+ list ($ token ) = $ I ->amAnActivatedCustomerWithNoMissingInformation ();
210
213
$ orderDetails = $ this ->getOrderDetails ($ I , $ token );
211
214
212
215
$ I ->sendApiPostWithToken ($ token , 'orders ' , $ orderDetails );
@@ -218,29 +221,29 @@ public function testThatARestaurantCanHaveOnlyOneGroupOrderAtTheSameTime(ApiTest
218
221
219
222
public function testThatGroupOrdersCanBeListed (ApiTester $ I )
220
223
{
221
- list ($ token ) = $ I ->amAnActivatedCustomer ();
224
+ list ($ token ) = $ I ->amAnActivatedCustomerWithNoMissingInformation ();
222
225
$ I ->sendApiGetWithToken ($ token , 'groupOrders ' );
223
226
$ I ->seeResponseCodeIs (200 );
224
227
}
225
228
226
229
public function testThatAnOrderCanBeShownByTheCustomerWhoPlacedItOnly (ApiTester $ I )
227
230
{
228
- list ($ token ) = $ I ->amAnActivatedCustomer ();
231
+ list ($ token ) = $ I ->amAnActivatedCustomerWithNoMissingInformation ();
229
232
$ orderDetails = $ this ->getOrderDetails ($ I , $ token );
230
233
$ I ->sendApiPostWithToken ($ token , 'orders ' , $ orderDetails );
231
234
$ orderId = $ I ->grabDataFromResponse ('id ' );
232
235
$ I ->sendApiGetWithToken ($ token , "orders/ $ orderId " );
233
236
$ I ->seeResponseCodeIs (200 );
234
237
$ I ->assertSame ($ orderId , $ I ->grabDataFromResponse ('id ' ));
235
238
236
- list ($ token2 ) = $ I ->amAnActivatedCustomer ();
239
+ list ($ token2 ) = $ I ->amAnActivatedCustomerWithNoMissingInformation ();
237
240
$ I ->sendApiGetWithToken ($ token2 , "orders/ $ orderId " );
238
241
$ I ->seeErrorResponse (403 , 'wrongAuthenticatedUser ' );
239
242
}
240
243
241
244
public function testThatTheDiscountRateIncreaseWhenAGroupOrderIsJoined (ApiTester $ I )
242
245
{
243
- list ($ token ) = $ I ->amAnActivatedCustomer ();
246
+ list ($ token ) = $ I ->amAnActivatedCustomerWithNoMissingInformation ();
244
247
$ orderDetails = $ this ->getOrderDetails ($ I , $ token );
245
248
$ I ->sendApiPostWithToken ($ token , 'orders ' , $ orderDetails );
246
249
$ orderId = $ I ->grabDataFromResponse ('id ' );
@@ -279,7 +282,7 @@ public function testThatTheDiscountRateIncreaseWhenAGroupOrderIsJoined(ApiTester
279
282
280
283
public function testThatTheDeliveryAddressMustBeCloseEnoughToJoinAGroupOrder (ApiTester $ I )
281
284
{
282
- list ($ token ) = $ I ->amAnActivatedCustomer ();
285
+ list ($ token ) = $ I ->amAnActivatedCustomerWithNoMissingInformation ();
283
286
$ orderDetails = $ this ->getOrderDetails ($ I , $ token );
284
287
$ I ->sendApiPostWithToken ($ token , 'orders ' , $ orderDetails );
285
288
$ orderId = $ I ->grabDataFromResponse ('id ' );
@@ -296,7 +299,7 @@ public function testThatTheDeliveryAddressMustBeCloseEnoughToJoinAGroupOrder(Api
296
299
297
300
public function testThatTheRestaurantCanSeeIfTheCustomerAttachedACommentToItsOrder (ApiTester $ I )
298
301
{
299
- list ($ token ) = $ I ->amAnActivatedCustomer ();
302
+ list ($ token ) = $ I ->amAnActivatedCustomerWithNoMissingInformation ();
300
303
$ orderDetails = $ this ->getOrderDetails ($ I , $ token );
301
304
$ comment = "Please add some meat to my vegan pizza... " ;
302
305
$ orderDetails ['comment ' ] = $ comment ;
0 commit comments