/** * @return void */ public function testGetShouldReturnCommand() { $commandCollection = new CommandCollection(); $command = $this->getCommandMock(); $commandCollection->add($command, self::COMMAND_NAME); $this->assertSame($command, $commandCollection->get(self::COMMAND_NAME)); }
/** * @return void */ public function testInstantiationWithCommandCollection() { $commandCollection = new CommandCollection(); $commandCollection->add($this->getCommandMock(), self::COMMAND_NAME); $orderStateMachine = new OrderStateMachine($this->getQueryContainerMock(), $this->getBuilderMock(), $this->getTransitionLogMock(), $this->getTimeoutMock(), new ReadOnlyArrayObject(), [], $commandCollection); $reflection = new \ReflectionClass(OrderStateMachine::class); $reflectionProperty = $reflection->getProperty('commands'); $reflectionProperty->setAccessible(true); $commands = $reflectionProperty->getValue($orderStateMachine); $this->assertInstanceOf(CommandCollectionInterface::class, $commands); $this->assertInstanceOf(CommandInterface::class, $commands->get(self::COMMAND_NAME)); }
/** * @return void */ public function testInstantiationWithCommandCollection() { $commandCollection = new CommandCollection(); $commandCollection->add($this->getCommandMock(), self::COMMAND_NAME); $drawer = new Drawer($commandCollection, [], $this->getGraphMock()); $reflection = new \ReflectionClass(Drawer::class); $reflectionProperty = $reflection->getProperty('commands'); $reflectionProperty->setAccessible(true); $commands = $reflectionProperty->getValue($drawer); $this->assertInstanceOf(CommandCollectionInterface::class, $commands); $this->assertInstanceOf(CommandInterface::class, $commands->get(self::COMMAND_NAME)); }
/** * Converts array to collection for BC * * @param \Spryker\Zed\Oms\Communication\Plugin\Oms\Command\CommandCollectionInterface|array $commands * * @return void */ protected function setCommands($commands) { if ($commands instanceof CommandCollectionInterface) { $this->commands = $commands; return; } $commandCollection = new CommandCollection(); foreach ($commands as $name => $command) { $commandCollection->add($command, $name); } $this->commands = $commandCollection; }