public function TermstatusAdminTestCase::testAddEditTermPublishingStatus in Taxonomy Term Status 7
Test alterations of term edit form.
File
- ./
termstatus.test, line 193 - Tests for termstatus.module
Class
- TermstatusAdminTestCase
- Tests the administrative user interface.
Code
public function testAddEditTermPublishingStatus() {
$admin = $this
->drupalCreateUser(array(
'administer taxonomy',
));
$this
->drupalLogin($admin);
// Add published term.
$name = $this
->randomName(8);
$edit = array(
'name' => $name,
'status' => TRUE,
);
$this
->drupalPost('admin/structure/taxonomy/tags/add', $edit, t('Save'));
$terms = taxonomy_get_term_by_name($name, 'tags');
$this
->assertEqual(1, count($terms), 'A term has been created');
$term = reset($terms);
$this
->assertTrue($term->status, 'The status of the term is set to published when added.');
// Edit published term and depublish it.
$edit = array(
'status' => FALSE,
);
$this
->drupalPost('taxonomy/term/' . $term->tid . '/edit', $edit, t('Save'));
$term = entity_load_unchanged('taxonomy_term', $term->tid);
$this
->assertFalse($term->status, 'The status of the term is set to unpublished after edit.');
// Add unpublished term.
$name = $this
->randomName(8);
$edit = array(
'name' => $name,
'status' => FALSE,
);
$this
->drupalPost('admin/structure/taxonomy/tags/add', $edit, t('Save'));
$terms = taxonomy_get_term_by_name($name, 'tags');
$this
->assertEqual(1, count($terms), 'A term has been created');
$term = reset($terms);
$this
->assertFalse($term->status, 'The status of the term is set to unpublished');
// Edit unpublished term and publish it.
$edit = array(
'status' => TRUE,
);
$this
->drupalPost('taxonomy/term/' . $term->tid . '/edit', $edit, t('Save'));
$term = entity_load_unchanged('taxonomy_term', $term->tid);
$this
->assertTrue($term->status, 'The status of the term is set to published after edit.');
}