public function CheckoutAddressbookTest::testMultipleAddress in Drupal Commerce Connector for AvaTax 8
Tests authenticated checkout and without existing profiles.
@covers \Drupal\commerce_avatax\CustomerProfileAlter
File
- tests/
src/ FunctionalJavascript/ CheckoutAddressbookTest.php, line 244
Class
- CheckoutAddressbookTest
- Tests the address.
Namespace
Drupal\Tests\commerce_avatax\FunctionalJavascriptCode
public function testMultipleAddress() {
// Create a default profile for the current user.
$profile_1 = Profile::create([
'type' => 'customer',
'uid' => $this->adminUser
->id(),
'address' => [
'country_code' => 'US',
'administrative_area' => 'CA',
'locality' => 'Irvine',
'postal_code' => '92614',
'address_line1' => '2000 Main Street',
'organization' => 'Centarro',
'given_name' => 'John',
'family_name' => 'Smith',
],
'data' => [
'copy_to_address_book' => TRUE,
],
]);
$profile_1
->save();
$profile_2 = Profile::create([
'type' => 'customer',
'uid' => $this->adminUser
->id(),
'default' => 1,
'address' => [
'country_code' => 'US',
'administrative_area' => 'NC',
'locality' => 'Durham',
'postal_code' => '27001',
'address_line1' => '512 S Mangu',
'organization' => 'Centarro',
'given_name' => 'John',
'family_name' => 'Smith',
],
'data' => [
'copy_to_address_book' => TRUE,
],
]);
$profile_2
->save();
$this
->reloadEntity($profile_1);
$this
->reloadEntity($profile_2);
$this
->drupalGet($this->product
->toUrl());
$this
->submitForm([], 'Add to cart');
$this
->assertSession()
->pageTextContains('1 item');
$cart_link = $this
->getSession()
->getPage()
->findLink('your cart');
$cart_link
->click();
$this
->submitForm([], 'Checkout');
$this
->assertSession()
->pageTextContains('Order Summary');
$this
->assertSession()
->pageTextContains('2000 Main Street');
$this
->assertSession()
->pageTextContains('Irvine, CA 92614');
$this
->submitForm([], 'Continue to review');
$this
->assertSession()
->waitForText('Confirm your shipping address', 45);
$this
->assertSession()
->pageTextContains('Use recommended');
$this
->assertSession()
->pageTextContains('Your shipping address is different from the post office records. We suggest you accept the recommended address to avoid shipping delays.');
$this
->getSession()
->getPage()
->findButton('Use recommended')
->click();
$this
->assertSession()
->waitForText('United States');
$this
->assertSession()
->pageTextContains('Contact information');
$this
->assertSession()
->pageTextContains('Payment information');
$this
->assertSession()
->pageTextContains('Order Summary');
$this
->assertSession()
->pageTextContains('2000 Main St');
$this
->assertSession()
->pageTextContains('Irvine, CA 92614-7202');
$this
->assertSession()
->buttonExists('Pay and complete purchase');
$this
->drupalGet('checkout/1/order_information');
$this
->getSession()
->getPage()
->fillField('shipping_information[shipping_profile][select_address]', $profile_2
->id());
$this
->assertSession()
->assertWaitOnAjaxRequest();
$this
->submitForm([], 'Continue to review');
$this
->assertSession()
->waitForText('Confirm your shipping address', 45);
$this
->assertSession()
->pageTextContains('Use as entered');
$this
->assertSession()
->pageTextContains('512 S Mangum St');
$this
->assertSession()
->pageTextContains('27701-3973');
$this
->assertSession()
->pageTextContains('Your shipping address is different from the post office records. We suggest you accept the recommended address to avoid shipping delays.');
$this
->getSession()
->getPage()
->pressButton('Use as entered');
$this
->assertSession()
->waitForText('United States');
$this
->assertSession()
->pageTextContains('Contact information');
$this
->assertSession()
->pageTextContains('Payment information');
$this
->assertSession()
->pageTextContains('Order Summary');
$this
->assertSession()
->pageTextContains('512 S Mangu');
$this
->assertSession()
->pageTextContains('Durham, NC 27001');
$this
->submitForm([], 'Pay and complete purchase');
$this
->assertSession()
->pageTextContains('Your order number is 1. You can view your order on your account page when logged in.');
$this
->assertSession()
->pageTextContains('0 items');
}