public function CustomerProfileTest::testIncompleteProfiles in Commerce Core 8.2
Tests switching between incomplete profiles.
File
- modules/
order/ tests/ src/ FunctionalJavascript/ CustomerProfileTest.php, line 915
Class
- CustomerProfileTest
- Tests the customer_profile inline form.
Namespace
Drupal\Tests\commerce_order\FunctionalJavascriptCode
public function testIncompleteProfiles() {
$us_profile = Profile::create([
'type' => 'customer',
'uid' => $this->adminUser
->id(),
'address' => $this->usAddress,
]);
$us_profile
->save();
$empty_profile = Profile::create([
'type' => 'customer',
'uid' => $this->adminUser
->id(),
'address' => $this->emptyAddress,
]);
$empty_profile
->save();
$hu_profile = Profile::create([
'type' => 'customer',
'uid' => $this->adminUser
->id(),
'address' => $this->huAddress,
]);
$hu_profile
->save();
$this
->drupalGet('/commerce_order_test/customer_profile_test_form/' . $us_profile
->id() . '/TRUE');
$this
->assertRenderedAddress($this->usAddress);
// Switch to empty address.
$this
->getSession()
->getPage()
->fillField('profile[select_address]', $empty_profile
->id());
$this
->assertSession()
->assertWaitOnAjaxRequest();
foreach ($this->emptyAddress as $property => $value) {
$this
->assertSession()
->fieldValueEquals("profile[address][0][address][{$property}]", $value);
}
// Switch to Hungarian incomplete profile.
$this
->getSession()
->getPage()
->fillField('profile[select_address]', $hu_profile
->id());
$this
->assertSession()
->assertWaitOnAjaxRequest();
foreach ($this->huAddress as $property => $value) {
$this
->assertSession()
->fieldValueEquals("profile[address][0][address][{$property}]", $value);
}
// Switch to creating new profile.
$this
->getSession()
->getPage()
->fillField('profile[select_address]', '_new');
$this
->assertSession()
->assertWaitOnAjaxRequest();
foreach ($this->emptyAddress as $property => $value) {
$this
->assertSession()
->fieldValueEquals("profile[address][0][address][{$property}]", $value);
}
// Switch back to US address.
$this
->getSession()
->getPage()
->fillField('profile[select_address]', $us_profile
->id());
$this
->assertSession()
->assertWaitOnAjaxRequest();
$this
->assertRenderedAddress($this->usAddress);
}