function PathAliasTest::testPathCache

Tests the path cache.

File

drupal/core/modules/path/lib/Drupal/path/Tests/PathAliasTest.php, line 41
Definition of Drupal\path\Tests\PathAliasTest.

Class

PathAliasTest
Tests path alias functionality.

Namespace

Drupal\path\Tests

Code

function testPathCache() {

  // Create test node.
  $node1 = $this
    ->drupalCreateNode();

  // Create alias.
  $edit = array();
  $edit['source'] = 'node/' . $node1->nid;
  $edit['alias'] = $this
    ->randomName(8);
  $this
    ->drupalPost('admin/config/search/path/add', $edit, t('Save'));

  // Visit the system path for the node and confirm a cache entry is
  // created.
  cache('path')
    ->deleteAll();
  $this
    ->drupalGet($edit['source']);
  $this
    ->assertTrue(cache('path')
    ->get($edit['source']), 'Cache entry was created.');

  // Visit the alias for the node and confirm a cache entry is created.
  cache('path')
    ->deleteAll();
  $this
    ->drupalGet($edit['alias']);
  $this
    ->assertTrue(cache('path')
    ->get($edit['source']), 'Cache entry was created.');
}