You are here

function PathTestCase::testPathCache in Drupal 7

Tests the path cache.

File

modules/path/path.test, line 31
Tests for the Path module.

Class

PathTestCase
Provides a base class for testing the Path module.

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_clear_all('*', 'cache_path', TRUE);
  $this
    ->drupalGet($edit['source']);
  $this
    ->assertTrue(cache_get($edit['source'], 'cache_path'), 'Cache entry was created.');

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