Skip to content

Commit

Permalink
Merge pull request #48 from thephpleague/improve_coverage
Browse files Browse the repository at this point in the history
Improve code coverage
  • Loading branch information
sagikazarmark committed Oct 30, 2016
2 parents d693866 + 7908620 commit b7922ae
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 1 deletion.
4 changes: 4 additions & 0 deletions spec/QueueCommandNormalizerSpec.php
Expand Up @@ -36,6 +36,8 @@ function it_normalizes_queue_command_and_delegates_message_to_aggregate(Message
'name' => 'queue',
'data' => ['key' => 'value'],
]);

$this->supportsNormalization($queueCommand)->shouldReturn(true);
}

function it_denormalizes_queue_command_and_delegates_message_to_aggregate(Message $message, AggregateNormalizer $aggregate)
Expand All @@ -52,5 +54,7 @@ function it_denormalizes_queue_command_and_delegates_message_to_aggregate(Messag
$queueCommand->shouldHaveType(QueueCommand::class);
$queueCommand->getCommand()->shouldReturn($message);
$queueCommand->getName()->shouldReturn('queue');

$this->supportsDenormalization($normalized, QueueCommand::class)->shouldReturn(true);
}
}
18 changes: 17 additions & 1 deletion spec/QueueMiddlewareSpec.php
Expand Up @@ -4,6 +4,7 @@

use Bernard\Message;
use Bernard\Producer;
use League\Tactician\Bernard\QueueCommand;
use League\Tactician\Bernard\QueuedCommand;
use League\Tactician\Bernard\QueueMiddleware;
use League\Tactician\Middleware;
Expand Down Expand Up @@ -48,7 +49,7 @@ function ($command) use ($middleware) {
);
}

function it_unwraps_a_command(Producer $producer, Message $command, Middleware $middleware)
function it_unwraps_an_already_queued_command(Producer $producer, Message $command, Middleware $middleware)
{
$queuedCommand = new QueuedCommand($command->getWrappedObject());
$producer->produce($command)->shouldNotBeCalled();
Expand All @@ -62,4 +63,19 @@ function ($command) use ($middleware) {
}
);
}

function it_unwraps_a_wrapped_command(Producer $producer, Command $command, Middleware $middleware)
{
$queuedCommand = new QueuedCommand(new QueueCommand($command->getWrappedObject()));
$producer->produce(Argument::any())->shouldNotBeCalled();

$middleware->execute($command, Argument::type('callable'))->shouldBeCalled();

$this->execute(
$queuedCommand,
function ($command) use ($middleware) {
return $middleware->getWrappedObject()->execute($command, function () {});
}
);
}
}

0 comments on commit b7922ae

Please sign in to comment.