ProophTest\ServiceBus\Mock\AsyncCommand::createCommand PHP Метод

createCommand() публичный статический Метод

public static createCommand ( string $data ) : AsyncCommand
$data string
Результат AsyncCommand
    public static function createCommand($data)
    {
        return new self(['data' => $data]);
    }

Usage Example

 /**
  * @test
  */
 public function marked_message_is_passed_to_decorated_router_as_already_handled_by_async_provider()
 {
     $messageProducer = $this->prophesize(MessageProducer::class);
     $decoratedRouter = $this->prophesize(SingleHandlerRouter::class);
     $message = AsyncCommand::createCommand('test-data');
     $message = $message->withAddedMetadata('handled-async', true);
     $actionEvent = new DefaultActionEvent(AsyncCommand::class, new CommandBus(), [MessageBus::EVENT_PARAM_MESSAGE_NAME => get_class($message), MessageBus::EVENT_PARAM_MESSAGE => $message]);
     $decoratedRouter->onRouteMessage($actionEvent)->willReturn('handled-by-decorated-router');
     $router = new AsyncSwitchMessageRouter($decoratedRouter->reveal(), $messageProducer->reveal());
     $rtn = $router->onRouteMessage($actionEvent);
     $this->assertEquals('handled-by-decorated-router', $rtn);
     $updatedMessage = $actionEvent->getParam(MessageBus::EVENT_PARAM_MESSAGE);
     $this->assertArrayHasKey('handled-async', $updatedMessage->metadata());
     $this->assertTrue($updatedMessage->metadata()['handled-async']);
 }
AsyncCommand