protected function AdministrativeAreaFilterTest::assertAdministrativeAreaOptions in Address 8
Assert the right administrative area options for a given country code.
Parameters
string $active_country: The country code.
3 calls to AdministrativeAreaFilterTest::assertAdministrativeAreaOptions()
- AdministrativeAreaFilterTest::testContextualCountryFilterAdministrativeAreaOptions in tests/
src/ Functional/ Views/ AdministrativeAreaFilterTest.php - Test options for administrative area using a contextual country filter.
- AdministrativeAreaFilterTest::testExposedCountryFilterAdministrativeAreaOptions in tests/
src/ Functional/ Views/ AdministrativeAreaFilterTest.php - Test options for administrative area using an exposed country filter.
- AdministrativeAreaFilterTest::testStaticCountryAdministrativeAreaOptions in tests/
src/ Functional/ Views/ AdministrativeAreaFilterTest.php - Test options for administrative area using a static country code.
File
- tests/
src/ Functional/ Views/ AdministrativeAreaFilterTest.php, line 160
Class
- AdministrativeAreaFilterTest
- Tests the administrative area Views filter for Address fields.
Namespace
Drupal\Tests\address\Functional\ViewsCode
protected function assertAdministrativeAreaOptions($active_country) {
// These are not exhaustive lists, nor are the keys guaranteed to be unique.
$areas = [
'BR' => [
'AM' => 'Amazonas',
'BA' => 'Bahia',
'PE' => 'Pernambuco',
'RJ' => 'Rio de Janeiro',
],
'EG' => [
'Alexandria Governorate' => 'Alexandria Governorate',
'Cairo Governorate' => 'Cairo Governorate',
],
'MX' => [
'Chis.' => 'Chiapas',
'Jal.' => 'Jalisco',
'Oax.' => 'Oaxaca',
'Ver.' => 'Veracruz',
],
'US' => [
'LA' => 'Louisiana',
'MA' => 'Massachusetts',
'WI' => 'Wisconsin',
],
];
foreach ($areas as $country => $areas) {
foreach ($areas as $area_key => $area_value) {
// For the active country, ensure both the key and value match.
if ($country == $active_country) {
$this
->assertSession()
->optionExists('edit-field-address-test-administrative-area', $area_key);
$this
->assertSession()
->optionExists('edit-field-address-test-administrative-area', $area_value);
}
else {
$this
->assertSession()
->pageTextNotContains($area_value);
}
}
}
}