function TextComparisonTest::testConditionEvaluationOperatorStarts

Tests evaluating the condition with the "starts" operator.

@covers ::evaluate

File

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

Class

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

Namespace

Drupal\Tests\rules\Unit\Integration\Condition

Code

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