File
- core/modules/path/tests/path.test, line 607
- Tests for the Path module.
Class
- PathHooksTestCase
- Tests that path hooks are invoked.
Code
function testPathHooks() {
$node1 = $this->backdropCreateNode();
$alias1 = $this->randomName(8);
$alias2 = $this->randomName(8);
$edit = array();
$edit['source'] = 'node/' . $node1->nid;
$edit['alias'] = $alias1;
$this->backdropPost('admin/config/urls/path/add', $edit, t('Save URL alias'));
$this->assertRaw('path_test_path_insert(): ' . $edit['alias'] . ' => ' . $edit['source'], t('hook_path_insert() was called.'));
$edit['alias'] = $alias2;
$this->backdropPost('admin/config/urls/path/add', $edit, t('Save URL alias'));
$inserted_path = state_get('path_test_inserted_path', array());
$pid2 = $inserted_path['pid'];
$edit['alias'] = $alias2 = $this->randomName(8);
$this->backdropPost('admin/config/urls/path/edit/' . $pid2, $edit, t('Save URL alias'));
$this->assertRaw('path_test_path_update(): ' . $edit['alias'] . ' => ' . $edit['source'], t('hook_path_update() was called.'));
$this->backdropPost('node/' . $node1->nid . '/delete', array(), t('Delete'));
$this->assertRaw('path_test_path_delete(): ' . $alias1 . ' => node/' . $node1->nid, t('hook_path_delete() was called for the first URL alias.'));
$this->assertRaw('path_test_path_delete(): ' . $alias2 . ' => node/' . $node1->nid, t('hook_path_delete() was called for the second URL alias.'));
$node2 = $this->backdropCreateNode();
$this->backdropPost('node/' . $node2->nid . '/delete', array(), t('Delete'));
$this->assertNoRaw('path_test_path_delete()', t('hook_path_delete() was not called.'));
}