/** * @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)); }
/** * @param \Spryker\Zed\Oms\Business\Process\TransitionInterface $transition * @param string $label * * @return array */ protected function addEdgeEventText(TransitionInterface $transition, $label) { if ($transition->hasEvent()) { $event = $transition->getEvent(); if ($event->isOnEnter()) { $label[] = '<b>' . $event->getName() . ' (on enter)</b>'; } else { $label[] = '<b>' . $event->getName() . '</b>'; } if ($event->hasTimeout()) { $label[] = 'timeout: ' . $event->getTimeout(); } if ($event->hasCommand()) { $commandLabel = 'c:' . $event->getCommand(); if ($this->commands->has($event->getCommand())) { $commandModel = $this->commands->get($event->getCommand()); if ($commandModel instanceof CommandByOrderInterface) { $commandLabel .= ' (by order)'; } else { $commandLabel .= ' (by item)'; } } else { $commandLabel .= ' ' . $this->notImplemented; } $label[] = $commandLabel; } if ($event->isManual()) { $label[] = 'manually executable'; } } else { $label[] = '∞'; } return $label; }
/** * 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; }
/** * @return void */ public function testGetShouldThrowException() { $commandCollection = new CommandCollection(); $this->expectException(CommandNotFoundException::class); $commandCollection->get(self::COMMAND_NAME); }