/** * Tests the action execution. * * @covers ::execute */ public function testActionExecution() { $list = ['One', 'Two', 'Three']; $this->action->setContextValue('list', $list)->setContextValue('item', 'Two'); $this->action->execute(); // The second item should be removed from the list. $this->assertArrayEquals(['One', 'Three'], array_values($this->action->getContextValue('list'))); }
/** * Tests that a variable can be set to NULL. */ public function testSetToNull() { // We don't need to set the 'value' context, it is NULL by default. $this->action->setContextValue('data', 'original'); $this->action->execute(); $this->assertNull($this->action->getContextValue('data')); $this->assertSame([], $this->action->autoSaveContext()); }
/** * Tests the action execution - add non-unique items. * * @covers ::execute */ public function testActionExecutionNonUnique() { // Test non-unique. $list = ['One', 'Two', 'Three', 'Four']; $this->action->setContextValue('list', $list)->setContextValue('item', 'Four')->setContextValue('unique', FALSE)->setContextValue('pos', 'end'); $this->action->execute(); // The list should contain five items, with the new item added at the end. $this->assertArrayEquals(['One', 'Two', 'Three', 'Four', 'Four'], $this->action->getContextValue('list')); }