You are here

public function DataListItemAddTest::testActionExecutionNonUnique in Rules 8.3

Tests the action execution - add non-unique items.

@covers ::execute

File

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

Class

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

Namespace

Drupal\Tests\rules\Unit\Integration\RulesAction

Code

public function testActionExecutionNonUnique() {

  // Test non-unique.
  $list = [
    'One',
    'Two',
    'Three',
    'Four',
  ];
  $this->action
    ->setContextValue('list', $list)
    ->setContextValue('item', 'Four')
    ->setContextValue('unique', FALSE)
    ->setContextValue('position', 'end');
  $this->action
    ->execute();

  // The list should contain five items, with the new item added at the end.
  $this
    ->assertEquals([
    'One',
    'Two',
    'Three',
    'Four',
    'Four',
  ], $this->action
    ->getContextValue('list'));
}