izzum\statemachine\utils\UtilsTest::shouldGetCompositeCommand PHP Method

shouldGetCompositeCommand() public method

    public function shouldGetCompositeCommand()
    {
        //id should be increased three times
        $command_name = 'izzum\\statemachine\\utils\\IncreaseId,izzum\\statemachine\\utils\\IncreaseId,izzum\\statemachine\\utils\\IncreaseId';
        $entity = new \stdClass();
        $entity->id = 0;
        $entity->event = null;
        //modelbuilder always returns the model we give it in the constructor
        $context = new Context(new Identifier('1', 'test'), new ModelBuilder($entity));
        $event = 'event';
        $command = Utils::getCommand($command_name, $context);
        $this->assertTrue(is_a($command, 'izzum\\command\\Composite'));
        $this->assertContains('IncreaseId', $command->toString());
        $this->assertEquals(0, $entity->id);
        $command->execute();
        $this->assertEquals(3, $entity->id);
        $command->execute();
        $this->assertEquals(6, $entity->id);
    }