public function PathautoPersistTestCase::testNodeAPI in Pathauto Persistent State 7
File
- ./pathauto_persist.test, line 65
Class
- PathautoPersistTestCase
- Tests for the pathauto_persist module.
Code
public function testNodeAPI() {
$node = $this
->drupalCreateNode(array(
'title' => 'Node version one',
'type' => 'article',
'path' => array(
'pathauto' => FALSE,
),
));
$this
->assertNoEntityAlias('node', $node);
$node->path['alias'] = 'test-alias';
node_save($node);
$node = node_load($node->nid, NULL, TRUE);
$this
->assertFalse($node->path['pathauto']);
$this
->assertEntityAlias('node', $node, 'test-alias');
$this
->assertNoEntityAliasExists('node', $node, 'content/node-version-one');
$this
->drupalLogin($this->nodeNoAliasUser);
$this
->drupalGet('node/' . $node->nid . '/edit');
$this
->assertNoFieldByName('path[pathauto]');
$edit = array(
'title' => 'Node version two',
);
$this
->drupalPost(NULL, $edit, 'Save');
$this
->assertText('Article Node version two has been updated.');
$this
->assertEntityAlias('node', $node, 'test-alias');
$this
->assertNoEntityAliasExists('node', $node, 'content/node-version-one');
$this
->assertNoEntityAliasExists('node', $node, 'content/node-version-two');
$this
->drupalLogin($this->nodeAliasUser);
$this
->drupalGet('node/' . $node->nid . '/edit');
$this
->assertNoFieldChecked('edit-path-pathauto');
$edit = array(
'title' => 'Node version three',
'path[alias]' => 'manually-edited-alias',
);
$this
->drupalPost(NULL, $edit, 'Save');
$this
->assertText('Article Node version three has been updated.');
$this
->assertEntityAlias('node', $node, 'manually-edited-alias');
$this
->assertNoEntityAliasExists('node', $node, 'test-alias');
$this
->assertNoEntityAliasExists('node', $node, 'content/node-version-one');
$this
->assertNoEntityAliasExists('node', $node, 'content/node-version-two');
$this
->assertNoEntityAliasExists('node', $node, 'content/node-version-three');
$node = node_load($node->nid, NULL, TRUE);
$node->path['pathauto'] = TRUE;
node_save($node);
$node = node_load($node->nid, NULL, TRUE);
$this
->assertTrue($node->path['pathauto']);
$this
->assertEntityAlias('node', $node, 'content/node-version-three');
$this
->assertNoEntityAliasExists('node', $node, 'manually-edited-alias');
$this
->assertNoEntityAliasExists('node', $node, 'test-alias');
$this
->assertNoEntityAliasExists('node', $node, 'content/node-version-one');
$this
->assertNoEntityAliasExists('node', $node, 'content/node-version-two');
}