function DataListItemAddTest::testActionExecutionEnforceUnique

Tests the action execution - enforce unique items.

@covers ::execute

File

tests/src/Unit/Integration/RulesAction/DataListItemAddTest.php, line 117

Class

DataListItemAddTest
@coversDefaultClass \Drupal\rules\Plugin\RulesAction\DataListItemAdd @group RulesAction

Namespace

Drupal\Tests\rules\Unit\Integration\RulesAction

Code

public function testActionExecutionEnforceUnique() {
    // Test unique.
    $list = [
        'One',
        'Two',
        'Three',
        'Four',
    ];
    $this->action
        ->setContextValue('list', $list)
        ->setContextValue('item', 'Four')
        ->setContextValue('unique', TRUE);
    $this->action
        ->execute();
    // The list should remain the same.
    $this->assertEquals([
        'One',
        'Two',
        'Three',
        'Four',
    ], $this->action
        ->getContextValue('list'));
}