public function PathAliasExistsTest::testConditionEvaluationAliasWithoutPath in Rules 8.3
Tests evaluating the condition for an alias that can not be resolved.
@covers ::evaluate
File
- tests/
src/ Unit/ Integration/ Condition/ PathAliasExistsTest.php, line 95
Class
- PathAliasExistsTest
- @coversDefaultClass \Drupal\rules\Plugin\Condition\PathAliasExists @group RulesCondition
Namespace
Drupal\Tests\rules\Unit\Integration\ConditionCode
public function testConditionEvaluationAliasWithoutPath() {
// If the path does not exist, getPathByAlias() should return the alias.
$this->aliasManager
->getPathByAlias('/alias-for-path-that-does-not-exist', NULL)
->willReturn('/alias-for-path-that-does-not-exist')
->shouldBeCalledTimes(1);
$this->aliasManager
->getPathByAlias('/alias-for-path-that-does-not-exist', 'en')
->willReturn('/alias-for-path-that-does-not-exist')
->shouldBeCalledTimes(1);
// First, only set the path context.
$this->condition
->setContextValue('alias', '/alias-for-path-that-does-not-exist');
// Test without language context set. This should return false because the
// alias was not defined.
$this
->assertFalse($this->condition
->evaluate());
// Test with language context set.
$this->condition
->setContextValue('language', $this->englishLanguage
->reveal());
$this
->assertFalse($this->condition
->evaluate());
}