function PathTestCase::testPathCache

Tests the path cache.

File

modules/path/path.test, line 31

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

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.