You are here

public function DataListItemAddTest::testActionExecutionItemAppend in Rules 8.3

Tests the action execution - item append.

@covers ::execute

File

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

Class

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

Namespace

Drupal\Tests\rules\Unit\Integration\RulesAction

Code

public function testActionExecutionItemAppend() {

  // Test adding a value at the end.
  $list = [
    'One',
    'Two',
    'Three',
  ];
  $this->action
    ->setContextValue('list', $list)
    ->setContextValue('item', 'Four')
    ->setContextValue('position', 'end');
  $this->action
    ->execute();

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