@@ -50,41 +50,34 @@ public function testItRoutesToDefaultBus()
50
50
->willReturn ($ envelope );
51
51
52
52
$ container = $ this ->createMock (ContainerInterface::class);
53
- $ container ->expects ($ this ->once ())->method ('has ' )->with (MessageBusInterface::class)
54
- ->willReturn (true );
55
- $ container ->expects ($ this ->once ())->method ('get ' )->with (MessageBusInterface::class)
56
- ->willReturn ($ defaultBus );
57
53
58
- $ routableBus = new RoutableMessageBus ($ container );
54
+ $ routableBus = new RoutableMessageBus ($ container, $ defaultBus );
59
55
60
56
$ this ->assertSame ($ envelope , $ routableBus ->dispatch ($ envelope , [$ stamp ]));
61
57
}
62
58
63
- public function testItExceptionOnDefaultBusNotFound ()
59
+ public function testItExceptionOnBusNotFound ()
64
60
{
65
61
$ this ->expectException (InvalidArgumentException::class);
66
- $ this ->expectExceptionMessage (sprintf ( 'Bus named "%s " does not exist. ' , MessageBusInterface::class) );
62
+ $ this ->expectExceptionMessage ('Bus named "my_cool_bus " does not exist. ' );
67
63
68
- $ envelope = new Envelope (new \stdClass ());
64
+ $ envelope = new Envelope (new \stdClass (), [
65
+ new BusNameStamp ('my_cool_bus ' )
66
+ ]);
69
67
70
68
$ container = $ this ->createMock (ContainerInterface::class);
71
- $ container ->expects ($ this ->once ())->method ('has ' )->with (MessageBusInterface::class)
72
- ->willReturn (false );
73
-
74
69
$ routableBus = new RoutableMessageBus ($ container );
75
70
$ routableBus ->dispatch ($ envelope );
76
71
}
77
72
78
- public function testItExceptionOnBusNotFound ()
73
+ public function testItExceptionOnDefaultBusNotFound ()
79
74
{
80
75
$ this ->expectException (InvalidArgumentException::class);
81
- $ this ->expectExceptionMessage (sprintf ( ' Bus named "%s" does not exist. ' , ' foo_bus ' ) );
76
+ $ this ->expectExceptionMessage (' Envelope is missing a BusNameStamp and no fallback message bus is configured on RoutableMessageBus. ' );
82
77
83
- $ envelope = new Envelope (new \stdClass (), [ new BusNameStamp ( ' foo_bus ' )] );
78
+ $ envelope = new Envelope (new \stdClass ());
84
79
85
80
$ container = $ this ->createMock (ContainerInterface::class);
86
- $ container ->expects ($ this ->once ())->method ('has ' )->willReturn (false );
87
-
88
81
$ routableBus = new RoutableMessageBus ($ container );
89
82
$ routableBus ->dispatch ($ envelope );
90
83
}
0 commit comments