You are here

public function DataListItemAddTest::testActionExecutionEnforceUnique in Rules 8.3

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