function DataListItemAddTest::testActionExecutionNonUnique
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\RulesActionCode
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'));
}