1 book.test | BookTestCase::testBookDelete() |
Tests the access for deleting top-level book nodes.
File
- core/
modules/ book/ tests/ book.test, line 333 - Tests for book.module.
Class
- BookTestCase
- Tests the functionality of the Book module.
Code
function testBookDelete() {
$nodes = $this->createBook();
$this->backdropLogin($this->admin_user);
$edit = array();
// Test access to delete top-level and child book nodes.
$this->backdropGet('node/' . $this->book->nid . '/outline-remove');
$this->assertResponse('403', 'Deleting top-level book node properly forbidden.');
$this->backdropPost('node/' . $nodes[4]->nid . '/outline-remove', $edit, t('Remove'));
$node4 = node_load($nodes[4]->nid, NULL, TRUE);
$this->assertTrue(empty($node4->book), 'Deleting child book node properly allowed.');
// Delete all child book nodes and retest top-level node deletion.
foreach ($nodes as $node) {
$nids[] = $node->nid;
}
node_delete_multiple($nids);
$this->backdropPost('node/' . $this->book->nid . '/outline-remove', $edit, t('Remove'));
$node = node_load($this->book->nid, NULL, TRUE);
$this->assertTrue(empty($node->book), 'Deleting childless top-level book node properly allowed.');
}