function DataListItemAddTest::testActionExecutionWithDefaults

Tests the action execution with default values.

@covers ::execute

File

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

Class

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

Namespace

Drupal\Tests\rules\Unit\Integration\RulesAction

Code

public function testActionExecutionWithDefaults() {
    // Test adding a value at the end (default position).
    $list = [
        'One',
        'Two',
        'Three',
    ];
    $this->action
        ->setContextValue('list', $list)
        ->setContextValue('item', 'Four');
    $this->action
        ->execute();
    // The list should contain four items, with the new item at the end.
    $this->assertEquals([
        'One',
        'Two',
        'Three',
        'Four',
    ], $this->action
        ->getContextValue('list'));
}