function ConditionExpressionTest::testNegation
Tests that negating a condition works.
File
-
tests/
src/ Unit/ ConditionExpressionTest.php, line 142
Class
- ConditionExpressionTest
- @coversDefaultClass \Drupal\rules\Plugin\RulesExpression\ConditionExpression @group Rules
Namespace
Drupal\Tests\rules\UnitCode
public function testNegation() {
$this->trueCondition
->getContextDefinitions()
->willReturn([]);
$this->trueCondition
->refineContextDefinitions([])
->shouldBeCalledTimes(1);
$this->trueCondition
->getProvidedContextDefinitions()
->willReturn([])
->shouldBeCalledTimes(1);
$this->conditionManager
->createInstance('test_condition', [
'negate' => TRUE,
])
->willReturn($this->trueCondition
->reveal())
->shouldBeCalledTimes(1);
$this->conditionManager
->getDefinition('test_condition')
->willReturn([
'label' => 'Test Condition',
])
->shouldBeCalledTimes(1);
// Create a condition which is negated.
$condition_expression = new ConditionExpression([
'condition_id' => 'test_condition',
'negate' => TRUE,
], '', [
'label' => 'Test Condition',
], $this->conditionManager
->reveal(), $this->processorManager
->reveal(), $this->rulesDebugLogger
->reveal());
$condition_expression->setStringTranslation($this->getStringTranslationStub());
$this->assertFalse($condition_expression->execute());
}