@@ -50,41 +50,34 @@ public function testItRoutesToDefaultBus()
5050 ->willReturn ($ envelope );
5151
5252 $ 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 );
5753
58- $ routableBus = new RoutableMessageBus ($ container );
54+ $ routableBus = new RoutableMessageBus ($ container, $ defaultBus );
5955
6056 $ this ->assertSame ($ envelope , $ routableBus ->dispatch ($ envelope , [$ stamp ]));
6157 }
6258
63- public function testItExceptionOnDefaultBusNotFound ()
59+ public function testItExceptionOnBusNotFound ()
6460 {
6561 $ 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. ' );
6763
68- $ envelope = new Envelope (new \stdClass ());
64+ $ envelope = new Envelope (new \stdClass (), [
65+ new BusNameStamp ('my_cool_bus ' ),
66+ ]);
6967
7068 $ container = $ this ->createMock (ContainerInterface::class);
71- $ container ->expects ($ this ->once ())->method ('has ' )->with (MessageBusInterface::class)
72- ->willReturn (false );
73-
7469 $ routableBus = new RoutableMessageBus ($ container );
7570 $ routableBus ->dispatch ($ envelope );
7671 }
7772
78- public function testItExceptionOnBusNotFound ()
73+ public function testItExceptionOnDefaultBusNotFound ()
7974 {
8075 $ 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. ' );
8277
83- $ envelope = new Envelope (new \stdClass (), [ new BusNameStamp ( ' foo_bus ' )] );
78+ $ envelope = new Envelope (new \stdClass ());
8479
8580 $ container = $ this ->createMock (ContainerInterface::class);
86- $ container ->expects ($ this ->once ())->method ('has ' )->willReturn (false );
87-
8881 $ routableBus = new RoutableMessageBus ($ container );
8982 $ routableBus ->dispatch ($ envelope );
9083 }
0 commit comments