public function CustomerProfileTypeTest::testAddressFieldUi in Commerce Core 8.2
Tests the address field UI.
File
- modules/
order/ tests/ src/ Functional/ CustomerProfileTypeTest.php, line 150
Class
- CustomerProfileTypeTest
- Tests the management of customer profile types.
Namespace
Drupal\Tests\commerce_order\FunctionalCode
public function testAddressFieldUi() {
$profile_type = ProfileType::load('customer');
// Create a new profile type to confirm that non-default customer profile
// types have the same behavior.
$this
->drupalGet($profile_type
->toUrl('duplicate-form'));
$this
->submitForm([
'label' => 'Customer (Shipping information)',
'display_label' => 'Shipping information',
'id' => 'customer_shipping',
], 'Save');
$new_profile_type = ProfileType::load('customer_shipping');
$this
->assertNotEmpty($new_profile_type);
$fields_ui_url = Url::fromRoute('entity.profile.field_ui_fields', [
'profile_type' => 'customer_shipping',
]);
$this
->drupalGet($fields_ui_url);
$operation_links = $this
->xpath('//tr[@id="address"]//ul[@class = "dropbutton"]/li/a');
$link_labels = [];
foreach ($operation_links as $link) {
$link_labels[] = $link
->getText();
}
// Confirm that the field cannot be deleted.
$this
->assertNotContains('Delete', $link_labels);
// Confirm that the "Storage settings" page is not available.
$this
->assertNotContains('Storage settings', $link_labels);
$field_config = FieldConfig::loadByName('profile', 'customer_shipping', 'address');
$this
->drupalGet($field_config
->toUrl('profile-field-edit-form'));
// Confirm that the "Required" and "Available countries" field settings
// are not available.
$this
->assertSession()
->fieldNotExists('required');
$this
->assertSession()
->fieldNotExists('settings[available_countries][]');
}