In a Drupal 7 site, I installed the Pathauto module. The user account I am using to log in has the permission to create new path aliases.
When I manually create a node, unselect the checkbox for automatic alias generation, and enter a custom alias (for example, qwerty), I can use drupal_lookup_path()
to get the path alias.
$path = drupal_lookup_path('node/' . $node->nid);
However, using the following code in a test doesn't work.
$edit = array(
'title' => 'asdf',
'path[alias]' => 'qwerty',
);
$this->drupalPost("node/add/{$this->content_type}", $edit, t('Save'));
$path = drupal_lookup_path('node/' . $node->nid);
The value of $path
is NULL
, even when the path alias exists and $this->drupalGet('qwerty')
returns a 200 status.
Why is drupal_lookup_path()
failing to find the path alias only when called from a test?