class CountriesElementUnitTest in Countries 8
Same name and namespace in other branches
- 7.2 tests/countries.test \CountriesElementUnitTest
Test the node_load_multiple() function.
Hierarchy
- class \CountriesBaseSetupTest extends \DrupalWebTestCase
- class \CountriesElementUnitTest
Expanded class hierarchy of CountriesElementUnitTest
File
- tests/
countries.test, line 831 - Tests for countries.module.
View source
class CountriesElementUnitTest extends CountriesBaseSetupTest {
public static function getInfo() {
return array(
'name' => 'Country Element',
'description' => 'Test the country FAPI element.',
'group' => 'Countries',
);
}
function setUp() {
parent::setUp(array(
'countries',
'countries_example',
));
$this
->drupalLogin($this->admin_user);
// We need a couple of disabled countries for the tests.
$af = country_load('af');
$af->enabled = 0;
country_save($af);
$nz = country_load('nz');
$nz->enabled = 0;
country_save($nz);
}
function testFAPIElement() {
$this
->drupalGet('countries-example');
if ($this
->assertResponse(200, t('Assert that the example page form loads.'))) {
$this
->assertOptionPresent('edit-countries-example-default-country-4', 'AD');
$this
->assertOptionPresent('edit-countries-example-default-country-4', 'AU');
$this
->assertNoOptionPresent('edit-countries-example-default-country-4', 'NZ');
$this
->assertNoOptionPresent('edit-countries-example-default-country-4', 'AF');
$this
->assertNoOptionPresent('edit-countries-example-default-country-7', 'AD');
$this
->assertNoOptionPresent('edit-countries-example-default-country-7', 'NZ');
$this
->assertNoOptionPresent('edit-countries-example-default-country-7', 'CN');
$this
->assertOptionPresent('edit-countries-example-default-country-8', 'NZ');
$this
->assertOptionPresent('edit-countries-example-default-country-8', 'AF');
$this
->assertNoOptionPresent('edit-countries-example-default-country-8', 'AU');
$this
->assertNoOptionPresent('edit-countries-example-default-country-8', 'AD');
$af = country_load('af');
$af->enabled = 0;
country_save($af);
$nz = country_load('nz');
$nz->enabled = 0;
country_save($nz);
countries_clear_caches();
$edit = array(
// Single select, enabled only
'countries_example_default_country_4' => 'AU',
// Multi-select select, enabled only
'countries_example_default_country_5[]' => array(
'AU',
'IR',
),
// Multi-select select, enabled European countries only.
// @todo check that the enabled still works
'countries_example_default_country_6[]' => array(
'FR',
'DE',
),
// Multi-select select, enabled American countries only.
// Cardinality 3, required.
'countries_example_default_country_7[]' => array(
'CA',
'US',
'MX',
),
// Single select, disabled only.
'countries_example_default_country_8' => 'NZ',
);
$this
->drupalPost('countries-example', $edit, t('Save'));
$this
->assertText('The configuration options have been saved.', 'Country example saved ok.');
$this
->assertOptionSelected('edit-countries-example-default-country-4', 'AU');
$this
->assertNoOptionSelected('edit-countries-example-default-country-4', 'AD');
$this
->assertOptionSelected('edit-countries-example-default-country-5', 'IR');
$this
->assertOptionSelected('edit-countries-example-default-country-5', 'AU');
$this
->assertNoOptionSelected('edit-countries-example-default-country-5', 'AD');
$this
->assertOptionSelected('edit-countries-example-default-country-6', 'FR');
$this
->assertOptionSelected('edit-countries-example-default-country-6', 'DE');
$this
->assertNoOptionSelected('edit-countries-example-default-country-6', 'AD');
$this
->assertNoOptionSelected('edit-countries-example-default-country-5', 'HU');
$this
->assertOptionSelected('edit-countries-example-default-country-7', 'CA');
$this
->assertOptionSelected('edit-countries-example-default-country-7', 'US');
$this
->assertOptionSelected('edit-countries-example-default-country-7', 'MX');
$this
->assertOptionSelected('edit-countries-example-default-country-8', 'NZ');
$this
->assertNoOptionSelected('edit-countries-example-default-country-8', 'AF');
$edit = array(
'countries_example_default_country_7[]' => array(
'CA',
'US',
'MX',
'CH',
'PE',
),
);
$this
->drupalPost('countries-example', $edit, t('Save'));
$this
->assertRaw(t('%title field is restricted to %count countries.', array(
'%title' => t('Select one to three countries in America (country element)'),
'%count' => 3,
)), 'Country example saved ok.');
}
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
CountriesBaseSetupTest:: |
function | |||
CountriesBaseSetupTest:: |
function | |||
CountriesBaseSetupTest:: |
function | |||
CountriesBaseSetupTest:: |
function | |||
CountriesBaseSetupTest:: |
function | Provides a sample group of countries defined by core that match the ISO Standards. | ||
CountriesBaseSetupTest:: |
function | These countries are not part of core. | ||
CountriesBaseSetupTest:: |
function | These are the invalid strings in core. | ||
CountriesBaseSetupTest:: |
function | The valid list if ISO strings | ||
CountriesBaseSetupTest:: |
function | Provides a sample group of countries defined by core that match the ISO Standards. | ||
CountriesElementUnitTest:: |
public static | function | ||
CountriesElementUnitTest:: |
function |
Overrides CountriesBaseSetupTest:: |
||
CountriesElementUnitTest:: |
function |