function PathModuleTestCase::testAdminAlias in SimpleTest 6
Test alias functionality through the admin interfaces.
File
- tests/path_module.test, line 29 
Class
Code
function testAdminAlias() {
  // create test node
  $node1 = $this
    ->createNode();
  // create alias
  $edit = array();
  $edit['src'] = 'node/' . $node1->nid;
  $edit['dst'] = $this
    ->randomName(8);
  $this
    ->drupalPost('admin/build/path/add', $edit, 'Create new alias');
  // confirm that the alias works
  $this
    ->drupalGet($edit['dst']);
  $this
    ->assertText($node1->title, 'Alias works.');
  // change alias
  $pid = $this
    ->getPID($edit['dst']);
  $previous = $edit['dst'];
  $edit['dst'] = $this
    ->randomName(8);
  $this
    ->drupalPost('admin/build/path/edit/' . $pid, $edit, 'Update alias');
  // confirm that the alias works
  $this
    ->drupalGet($edit['dst']);
  $this
    ->assertText($node1->title, 'Changed alias works.');
  // make sure that previous alias no longer works
  $this
    ->drupalGet($previous);
  $this
    ->assertNoText($node1->title, 'Previous alias no longer works.');
  $this
    ->assertTitle(new PatternExpectation('/Page not found/'), 'We get page  not found error');
  // create second test node
  $node2 = $this
    ->createNode();
  // set alias to second test node
  $edit['src'] = 'node/' . $node2->nid;
  // leave $edit['dst'] the same
  $this
    ->drupalPost('admin/build/path/add', $edit, 'Create new alias');
  // confirm that the alias didn't make a duplicate
  $this
    ->assertWantedRaw(t('The alias %alias is already in use in this language.', array(
    '%alias' => $edit['dst'],
  )), 'Attempt to move alias was rejected.');
  // delete alias
  $this
    ->drupalPost('admin/build/path/delete/' . $pid, array(), 'Confirm');
  // confirm that the alias no longer works
  $this
    ->drupalGet($edit['dst']);
  $this
    ->assertNoText($node1->title, 'Alias was successfully deleted.');
}