@@ -102,7 +102,19 @@ protected function setUp() {
102
102
$ this ->promotion ->save ();
103
103
104
104
/** @var \Drupal\commerce_payment\Entity\PaymentGateway $gateway */
105
- $ gateway = PaymentGateway::create ([
105
+ $ offsite_gateway = PaymentGateway::create ([
106
+ 'id ' => 'offsite ' ,
107
+ 'label ' => 'Off-site ' ,
108
+ 'plugin ' => 'example_offsite_redirect ' ,
109
+ 'configuration ' => [
110
+ 'redirect_method ' => 'post ' ,
111
+ 'payment_method_types ' => ['credit_card ' ],
112
+ ],
113
+ ]);
114
+ $ offsite_gateway ->save ();
115
+
116
+ /** @var \Drupal\commerce_payment\Entity\PaymentGateway $gateway */
117
+ $ onsite_gateway = PaymentGateway::create ([
106
118
'id ' => 'onsite ' ,
107
119
'label ' => 'On-site ' ,
108
120
'plugin ' => 'example_onsite ' ,
@@ -111,7 +123,7 @@ protected function setUp() {
111
123
'payment_method_types ' => ['credit_card ' ],
112
124
],
113
125
]);
114
- $ gateway ->save ();
126
+ $ onsite_gateway ->save ();
115
127
116
128
$ profile = $ this ->createEntity ('profile ' , [
117
129
'type ' => 'customer ' ,
@@ -267,4 +279,47 @@ public function testCheckoutWithMainSubmit() {
267
279
$ this ->assertEquals (new Price ('899.10 ' , 'USD ' ), $ this ->cart ->getTotalPrice ());
268
280
}
269
281
282
+ /**
283
+ * Tests that adding/removing coupons does not submit other panes.
284
+ */
285
+ public function testCheckoutSubmit () {
286
+ // Start checkout, and enter billing information.
287
+ $ this ->drupalGet (Url::fromRoute ('commerce_checkout.form ' , ['commerce_order ' => $ this ->cart ->id ()]));
288
+ $ this ->getSession ()->getPage ()->findField ('Example ' )->check ();
289
+ $ this ->waitForAjaxToFinish ();
290
+ $ this ->submitForm ([
291
+ 'payment_information[billing_information][address][0][address][given_name] ' => 'Johnny ' ,
292
+ 'payment_information[billing_information][address][0][address][family_name] ' => 'Appleseed ' ,
293
+ 'payment_information[billing_information][address][0][address][address_line1] ' => '123 New York Drive ' ,
294
+ 'payment_information[billing_information][address][0][address][locality] ' => 'New York City ' ,
295
+ 'payment_information[billing_information][address][0][address][administrative_area] ' => 'NY ' ,
296
+ 'payment_information[billing_information][address][0][address][postal_code] ' => '10001 ' ,
297
+ ], 'Continue to review ' );
298
+
299
+ // Go back and edit the billing information, but don't submit it.
300
+ $ this ->getSession ()->getPage ()->clickLink ('Go back ' );
301
+ $ address_prefix = 'payment_information[billing_information][address][0][address] ' ;
302
+ $ this ->getSession ()->getPage ()->fillField ($ address_prefix . '[given_name] ' , 'John ' );
303
+ $ this ->getSession ()->getPage ()->fillField ($ address_prefix . '[family_name] ' , 'Smith ' );
304
+
305
+ // Add a coupon.
306
+ $ coupons = $ this ->promotion ->getCoupons ();
307
+ $ coupon = reset ($ coupons );
308
+ $ page = $ this ->getSession ()->getPage ();
309
+ $ page ->fillField ('Coupon code ' , $ coupon ->getCode ());
310
+ $ page ->pressButton ('Apply coupon ' );
311
+ $ this ->waitForAjaxToFinish ();
312
+ $ this ->assertSession ()->pageTextContains ($ coupon ->getCode ());
313
+ $ this ->assertSession ()->fieldNotExists ('Coupon code ' );
314
+ $ this ->assertSession ()->buttonNotExists ('Apply coupon ' );
315
+
316
+ // Refresh the page and ensure the billing information hasn't been modified.
317
+ $ this ->drupalGet (Url::fromRoute ('commerce_checkout.form ' , ['commerce_order ' => $ this ->cart ->id (), 'step ' => 'order_information ' ]));
318
+ $ page = $ this ->getSession ()->getPage ();
319
+ $ given_name_field = $ page ->findField ('payment_information[billing_information][address][0][address][given_name] ' );
320
+ $ family_name_field = $ page ->findField ('payment_information[billing_information][address][0][address][family_name] ' );
321
+ $ this ->assertEquals ($ given_name_field ->getValue (), 'Johnny ' );
322
+ $ this ->assertEquals ($ family_name_field ->getValue (), 'Appleseed ' );
323
+ }
324
+
270
325
}
0 commit comments