function TextComparisonTest::testConditionEvaluationOperatorRegex

Tests evaluating the condition with the "regex" operator.

@covers ::evaluate

File

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

Class

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

Namespace

Drupal\Tests\rules\Unit\Integration\Condition

Code

public function testConditionEvaluationOperatorRegex() {
    // Test that when the operator is 'regex' and the regular expression in
    // the match string matches the text string, TRUE is returned.
    $this->condition
        ->setContextValue('text', 'my-text')
        ->setContextValue('operator', 'regex')
        ->setContextValue('match', 'me?y-texx?t');
    $this->assertTrue($this->condition
        ->evaluate());
    // Test that when the operator is 'regex' and the regular expression in
    // the match string does not match the text string, TRUE is returned.
    $this->condition
        ->setContextValue('text', 'my-text')
        ->setContextValue('operator', 'regex')
        ->setContextValue('match', 'me+y-texx?t');
    $this->assertFalse($this->condition
        ->evaluate());
}