function CountriesBaseInstallUnitTest::testCountriesAdminListing in Countries 7.2
This browes the admin listing, making sure that the countries are correctly listed.
File
- tests/
countries.test, line 223 - Tests for countries.module.
Class
Code
function testCountriesAdminListing() {
// Test all of the existing and updated countries via the countries module
// admin listing.
// INSTALLATION DOES NOT UPDATE BY DEFAULT!
$test_countries = array(
array(
'options' => array(),
'AF' => array(
'Afghanistan',
'Islamic Republic of Afghanistan',
'AFG',
'004',
'Asia',
'Enabled',
),
'IO' => array(
'British Indian Ocean Territory',
'British Indian Ocean Territory',
'IOT',
'086',
'Asia',
'Enabled',
),
),
array(
'options' => array(
'query' => array(
'page' => '2',
),
),
'CI' => array(
"Ivory Coast",
"Republic of Côte d'Ivoire",
'CIV',
'384',
'Africa',
'Enabled',
),
),
array(
'options' => array(
'query' => array(
'page' => '2',
'sort' => 'asc',
'order' => 'ISO numeric-3 code',
),
),
'KP' => array(
"North Korea",
"Democratic People's Republic of Korea",
'PRK',
'408',
'Asia',
'Enabled',
),
),
);
foreach ($test_countries as $countries) {
$options = $countries['options'];
unset($countries['options']);
$this
->drupalGet('admin/config/regional/countries', $options);
foreach ($countries as $iso2 => $info) {
$test_country = country_create(array(
'iso2' => $iso2,
'name' => $info[0],
));
$existing = country_load($iso2);
$this
->assertListingLink($test_country, 'title', 1, NULL, empty($options['query']) ? NULL : $options['query']);
$this
->assertRaw("<td id=\"{$iso2}-iso2\">{$iso2}</td>", 'Testing iso2 for ' . $info[0] . ' - ' . $iso2);
$this
->assertRaw("<td id=\"{$iso2}-official_name\">" . check_plain($info[1]) . "</td>", 'Testing officical name for ' . $info[0] . ' - ' . $iso2 . " ({$info[1]})");
$this
->assertRaw("<td id=\"{$iso2}-iso3\">{$info[2]}</td>", 'Testing iso3 for ' . $info[0] . ' - ' . $iso2 . " ({$info[2]})");
// Sorting adds an active class
$this
->assertRaw(">{$info[3]}</td>", 'Testing numcode for ' . $info[0] . ' - ' . $iso2 . " ({$info[3]})");
$this
->assertRaw("<td id=\"{$iso2}-continent\">{$info[4]}</td>", 'Testing continent for ' . $info[0] . ' - ' . $iso2 . " ({$info[4]})");
$this
->assertRaw("<td id=\"{$iso2}-enabled\">{$info[5]}</td>", 'Testing enabled for ' . $info[0] . ' - ' . $iso2 . " ({$info[5]})");
$this
->assertListingLink($test_country, 'edit', 1, NULL, empty($options['query']) ? NULL : $options['query']);
$this
->assertListingLink($test_country, 'delete', 0, NULL, empty($options['query']) ? NULL : $options['query']);
}
}
}