function PathautoBookTokenTestCase::testBookPathAlias in Pathauto 6
Same name and namespace in other branches
- 6.2 pathauto.test \PathautoBookTokenTestCase::testBookPathAlias()
File
- ./
pathauto.test, line 675 - Functionality tests for Pathauto.
Class
Code
function testBookPathAlias() {
// Add a non-book node.
$non_book_node = $this
->drupalCreateNode(array(
'type' => 'book',
));
$this
->assertToken('node', $non_book_node, 'bookpathalias', '');
// Add a root book page.
$parent_node = $this
->drupalCreateNode(array(
'type' => 'book',
'title' => 'Root',
'book' => array(
'bid' => 'new',
) + _book_link_defaults('new'),
));
$tokens = array(
'bookpathalias' => '',
);
$this
->assertTokens('node', $parent_node, $tokens);
// Add a first child page.
$child_node1 = $this
->drupalCreateNode(array(
'type' => 'book',
'title' => 'Sub page1',
'book' => array(
'bid' => $parent_node->book['bid'],
'plid' => $parent_node->book['mlid'],
) + _book_link_defaults('new'),
));
$tokens = array(
'bookpathalias' => 'root',
);
$this
->assertTokens('node', $child_node1, $tokens);
// Add a second child page.
$child_node2 = $this
->drupalCreateNode(array(
'type' => 'book',
'title' => 'Sub page2',
'book' => array(
'bid' => $parent_node->book['bid'],
'plid' => $parent_node->book['mlid'],
) + _book_link_defaults('new'),
));
$tokens = array(
'bookpathalias' => 'root',
);
$this
->assertTokens('node', $child_node2, $tokens);
// Add a child page on an existing child page.
$sub_child_node1 = $this
->drupalCreateNode(array(
'type' => 'book',
'title' => 'Sub-sub Page1',
'book' => array(
'bid' => $parent_node->book['bid'],
'plid' => $child_node1->book['mlid'],
) + _book_link_defaults('new'),
));
$tokens = array(
'bookpathalias' => 'root/sub-page1',
);
$this
->assertTokens('node', $sub_child_node1, $tokens);
// Test that path tokens should not be altered.
$this
->saveEntityAlias('node', $child_node1, 'My Crazy/Alias/');
pathauto_nodeapi($sub_child_node1, 'update');
$this
->assertEntityAlias('node', $sub_child_node1, 'My Crazy/Alias/sub-sub-page1');
}