public function PathHasAliasTest::testConditionEvaluationPathWithAlias in Rules 8.3
Tests evaluating the condition for a path with an alias.
@covers ::evaluate
File
- tests/
src/ Unit/ Integration/ Condition/ PathHasAliasTest.php, line 67
Class
- PathHasAliasTest
- @coversDefaultClass \Drupal\rules\Plugin\Condition\PathHasAlias @group RulesCondition
Namespace
Drupal\Tests\rules\Unit\Integration\ConditionCode
public function testConditionEvaluationPathWithAlias() {
// If the alias exists, getAliasByPath() should return the alias.
$this->aliasManager
->getAliasByPath('/path-with-alias', NULL)
->willReturn('/alias-for-path')
->shouldBeCalledTimes(1);
$this->aliasManager
->getAliasByPath('/path-with-alias', 'en')
->willReturn('/alias-for-path')
->shouldBeCalledTimes(1);
// First, only set the path context.
$this->condition
->setContextValue('path', '/path-with-alias');
// Test without language context set.
$this
->assertTrue($this->condition
->evaluate());
// Test with language context set.
$this->condition
->setContextValue('language', $this->englishLanguage
->reveal());
$this
->assertTrue($this->condition
->evaluate());
}