function TextComparisonTest::testConditionEvaluationOperatorEnds

Tests evaluating the condition with the "ends" operator.

@covers ::evaluate

File

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

Class

TextComparisonTest
@coversDefaultClass \Drupal\rules\Plugin\Condition\TextComparison[[api-linebreak]] @group RulesCondition

Namespace

Drupal\Tests\rules\Unit\Integration\Condition

Code

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