TitleAdminSettingsTestCase.test in Title 7
File
tests/TitleAdminSettingsTestCase.test
View source
<?php
class TitleAdminSettingsTestCase extends DrupalWebTestCase {
public static function getInfo() {
return array(
'name' => 'Admin settings',
'description' => 'Test the administration settings.',
'group' => 'Title',
);
}
protected $profile = 'testing';
public function setUp(array $modules = array()) {
$modules[] = 'field_test';
$modules[] = 'taxonomy';
$modules[] = 'title';
$modules[] = 'title_test';
parent::setUp($modules);
$this
->checkPermissions(array(), TRUE);
$admin_user = $this
->drupalCreateUser(array(
'administer site configuration',
'administer taxonomy',
'administer fields',
));
$this
->drupalLogin($admin_user);
}
public function testAutomatedFieldAttachment() {
$this
->doTestAutomatedFieldAttachment(TRUE);
$this
->doTestAutomatedFieldAttachment(FALSE);
}
public function doTestAutomatedFieldAttachment($enabled) {
$edit = array(
'title_taxonomy_term[auto_attach][name]' => $enabled,
'title_taxonomy_term[auto_attach][description]' => $enabled,
);
$this
->drupalPost('admin/config/content/title', $edit, t('Save configuration'));
$edit = array(
'name' => $this
->randomName(),
'machine_name' => drupal_strtolower($this
->randomName()),
'description' => $this
->randomString(16),
);
$this
->drupalPost('admin/structure/taxonomy/add', $edit, t('Save'));
$entity_type = 'taxonomy_term';
$bundle = $edit['machine_name'];
field_info_cache_clear();
$this
->assertTrue(title_field_replacement_enabled($entity_type, $bundle, 'name') == $enabled, 'Name field correctly processed.');
$this
->assertTrue(title_field_replacement_enabled($entity_type, $bundle, 'description') == $enabled, 'Description field correctly processed.');
}
}