public function DomainSourceTest::testDomainSourceForm in Domain Access 7.3
File
- domain_source/
tests/ domain_source.test, line 64 - Simpletest for Domain Source.
Class
- DomainSourceTest
- @file Simpletest for Domain Source.
Code
public function testDomainSourceForm() {
// Test the node edit form.
$type = 'article';
$admin_account = $this
->drupalCreateUser(array(
'administer nodes',
'bypass node access',
'set domain access',
));
$this
->drupalLogin($admin_account);
$form = $this
->domainNodeForm($admin_account->uid, $type);
// Check the form element.
$this
->assertTrue(isset($form['domain']['domain_source']), t('Domain Source node form element appears.'));
$domains = domain_domains();
// There should be four domains, plus the use current domain option.
$this
->assertTrue(count($form['domain']['domain_source']['#options']) == count($domains) + 1, t('Domain source options list correctly.'));
// The default domain option should be use active.
$this
->assertTrue($form['domain']['domain_source']['#default_value'] == DOMAIN_SOURCE_USE_ACTIVE, t('The default form value is "use active".'));
// Set the default value for this node type and check again. Note that the
// variable is stored as a machine_name and transforms to an id by the form.
variable_set('domain_source_article', domain_default_machine_name());
$form = $this
->domainNodeForm($admin_account->uid, $type);
// The default domain option should be default.
$this
->assertTrue($form['domain']['domain_source']['#default_value'] == domain_default_id(), t('The default form value is the node type default.'));
// TODO: There are more advanced form use-cases. They can wait.
}