function TextComparisonTest::testConditionEvaluationOperatorContains

Tests evaluating the condition with the "contains" operator.

@covers ::evaluate

File

tests/src/Unit/Integration/Condition/TextComparisonTest.php, line 82

Class

TextComparisonTest
@coversDefaultClass \Drupal\rules\Plugin\Condition\TextComparison @group RulesCondition

Namespace

Drupal\Tests\rules\Unit\Integration\Condition

Code

public function testConditionEvaluationOperatorContains() {
    // Test that when the text string contains the match string and
    // the operator is 'contains', TRUE is returned.
    $this->condition
        ->setContextValue('text', 'my-text')
        ->setContextValue('operator', 'contains')
        ->setContextValue('match', 'y-t');
    $this->assertTrue($this->condition
        ->evaluate());
    // Test that when the text string does not contain the match string and
    // the operator is 'contains', FALSE is returned.
    $this->condition
        ->setContextValue('text', 'my-text')
        ->setContextValue('operator', 'contains')
        ->setContextValue('match', 't-y');
    $this->assertFalse($this->condition
        ->evaluate());
}