function PathTestCase::testPathCache

7.x path.test PathTestCase::testPathCache()

Tests the path cache.

File

drupal-7.x/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.');
}