2727
2828use PHPUnit \Framework \TestCase ;
2929use Robotusers \Commander \CommandBusAwareTrait ;
30+ use Robotusers \Commander \CommandBusInterface ;
31+ use RuntimeException ;
32+ use stdClass ;
3033
3134/**
3235 * @author Robert Pustułka <r.pustulka@robotusers.com>
@@ -37,7 +40,7 @@ class CommandBusAwareTraitTest extends TestCase
3740 public function testGetCommandBus ()
3841 {
3942 $ object = $ this ->getMockForTrait (CommandBusAwareTrait::class);
40- $ bus = $ this ->createMock (\ Robotusers \ Commander \ CommandBusInterface::class);
43+ $ bus = $ this ->createMock (CommandBusInterface::class);
4144
4245 $ result = $ object ->setCommandBus ($ bus );
4346 $ this ->assertSame ($ object , $ result );
@@ -46,9 +49,26 @@ public function testGetCommandBus()
4649 $ this ->assertSame ($ bus , $ result );
4750 }
4851
52+ public function testHandleCommand ()
53+ {
54+ $ object = $ this ->getMockForTrait (CommandBusAwareTrait::class);
55+ $ bus = $ this ->createMock (CommandBusInterface::class);
56+ $ command = new stdClass ();
57+ $ result = new stdClass ();
58+
59+ $ bus ->expects ($ this ->once ())
60+ ->method ('handle ' )
61+ ->with ($ command )
62+ ->willReturn ($ result );
63+
64+ $ object ->setCommandBus ($ bus );
65+ $ return = $ object ->handleCommand ($ command );
66+ $ this ->assertSame ($ result , $ return );
67+ }
68+
4969 /**
5070 * @expectedException RuntimeException
51- * @expectedException Command bus has not been set.
71+ * @expectedExceptionMessage Command bus has not been set.
5272 */
5373 public function testGetCommandBusMissing ()
5474 {
0 commit comments