public function PathautoKernelTest::testPatternStatus in Pathauto 8
Test if aliases are (not) generated with enabled/disabled patterns.
File
- tests/
src/ Kernel/ PathautoKernelTest.php, line 503
Class
- PathautoKernelTest
- Unit tests for Pathauto functions.
Namespace
Drupal\Tests\pathauto\KernelCode
public function testPatternStatus() {
// Create a node to get an alias for.
$title = 'Pattern enabled';
$alias = '/content/pattern-enabled';
$node1 = $this
->drupalCreateNode([
'title' => $title,
'type' => 'page',
]);
$this
->assertEntityAlias($node1, $alias);
// Disable the pattern, save the node again and make sure the alias is still
// working.
$this->nodePattern
->setStatus(FALSE)
->save();
$node1
->save();
$this
->assertEntityAlias($node1, $alias);
// Create a new node with disabled pattern and make sure there is no new
// alias created.
$title = 'Pattern disabled';
$node2 = $this
->drupalCreateNode([
'title' => $title,
'type' => 'page',
]);
$this
->assertNoEntityAlias($node2);
}