You are here

public function TextComparisonTest::testConditionEvaluationOperatorRegex in Rules 8.3

Tests evaluating the condition with the "regex" operator.

@covers ::evaluate

File

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

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 matche 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());
}