public function CustomerProfileTest::testAnonymous in Commerce Core 8.2
Tests the address book for anonymous customers.
File
- modules/
order/ tests/ src/ FunctionalJavascript/ CustomerProfileTest.php, line 869
Class
- CustomerProfileTest
- Tests the customer_profile inline form.
Namespace
Drupal\Tests\commerce_order\FunctionalJavascriptCode
public function testAnonymous() {
$this
->drupalLogout();
// Test the address book form when multiple profiles are allowed.
$this
->drupalGet('/commerce_order_test/customer_profile_test_form');
$this
->assertSession()
->fieldNotExists('select_address');
// Confirm that the address fields are shown and not pre-filled.
foreach ($this->emptyAddress as $property => $value) {
$this
->assertSession()
->fieldValueEquals("profile[address][0][address][{$property}]", $value);
}
$this
->assertSession()
->fieldNotExists('profile[copy_to_address_book]');
// Confirm value.
$this
->submitForm([
'profile[address][0][address][given_name]' => 'John',
'profile[address][0][address][family_name]' => 'Smith',
'profile[address][0][address][address_line1]' => 'Cetinjska 13',
'profile[address][0][address][locality]' => 'Belgrade',
], 'Submit');
$this
->assertSession()
->pageTextContains('The street is "Cetinjska 13" and the country code is RS. Address book: Yes');
// Test the address book form when only a single profile is allowed.
/** @var \Drupal\profile\Entity\ProfileTypeInterface $profile_type */
$profile_type = ProfileType::load('customer');
$profile_type
->setMultiple(FALSE);
$profile_type
->save();
$this
->drupalGet('/commerce_order_test/customer_profile_test_form');
// Confirm that the address fields are shown and not pre-filled.
foreach ($this->emptyAddress as $property => $value) {
$this
->assertSession()
->fieldValueEquals("profile[address][0][address][{$property}]", $value);
}
$this
->assertSession()
->fieldNotExists('profile[copy_to_address_book]');
// Confirm value.
$this
->submitForm([
'profile[address][0][address][given_name]' => 'John',
'profile[address][0][address][family_name]' => 'Smith',
'profile[address][0][address][address_line1]' => 'Cetinjska 13',
'profile[address][0][address][locality]' => 'Belgrade',
], 'Submit');
$this
->assertSession()
->pageTextContains('The street is "Cetinjska 13" and the country code is RS. Address book: Yes');
}