public function testExecuteCallsNextCommandInChain() { $itemParams = array(); $this->_model->expects($this->once())->method('_execute')->with($this->equalTo($itemParams))->will($this->returnValue($itemParams)); $command1 = $this->getMock('Magento\\Backend\\Model\\Menu\\Builder\\Command\\Update', array(), array(array('id' => 1))); $command1->expects($this->once())->method('execute')->with($this->equalTo($itemParams))->will($this->returnValue($itemParams)); $this->_model->chain($command1); $this->assertEquals($itemParams, $this->_model->execute($itemParams)); }
/** * Add command as last in the list of callbacks * * @param \Magento\Backend\Model\Menu\Builder\AbstractCommand $command * @return $this * @throws \InvalidArgumentException if invalid chaining command is supplied */ public function chain(\Magento\Backend\Model\Menu\Builder\AbstractCommand $command) { if (is_null($this->_next)) { $this->_next = $command; } else { $this->_next->chain($command); } return $this; }
/** * Add command as last in the list of callbacks * * @param \Magento\Backend\Model\Menu\Builder\AbstractCommand $command * @return $this * @throws \InvalidArgumentException */ public function chain(\Magento\Backend\Model\Menu\Builder\AbstractCommand $command) { if ($command instanceof \Magento\Backend\Model\Menu\Builder\Command\Add) { throw new \InvalidArgumentException("Two 'add' commands cannot have equal id (" . $command->getId() . ")"); } return parent::chain($command); }