function DataComparisonTest::testConditionEvaluationOperatorIn

Tests evaluating the condition with the "IN" operation.

@covers ::evaluate

File

tests/src/Unit/Integration/Condition/DataComparisonTest.php, line 127

Class

DataComparisonTest
@coversDefaultClass \Drupal\rules\Plugin\Condition\DataComparison @group RulesCondition

Namespace

Drupal\Tests\rules\Unit\Integration\Condition

Code

public function testConditionEvaluationOperatorIn() {
    // Test that when the data string is 'IN' the value array, TRUE is returned.
    $this->condition
        ->setContextValue('data', 'Llama')
        ->setContextValue('operation', 'IN')
        ->setContextValue('value', [
        'Llama',
        'Kitten',
    ]);
    $this->assertTrue($this->condition
        ->evaluate());
    // Test that when the data array is not in the value array, and the
    // operation is 'IN', FALSE is returned.
    $this->condition
        ->setContextValue('data', [
        'Llama',
    ])
        ->setContextValue('operation', 'IN')
        ->setContextValue('value', [
        'Kitten',
    ]);
    $this->assertFalse($this->condition
        ->evaluate());
}