You are here

public function TextComparisonTest::testConditionEvaluationOperatorContains in Rules 8.3

Tests evaluating the condition with the "contains" operator.

@covers ::evaluate

File

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

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