@@ -72,8 +72,6 @@ public function testReceiverNameArgument()
72
72
73
73
public function testReceiverNameArgumentNotFound ()
74
74
{
75
- $ this ->expectException (\RuntimeException::class);
76
- $ this ->expectExceptionMessage ('The "not_found" transport does not exist. ' );
77
75
// mock a service locator
78
76
/** @var MockObject&ServiceLocator $serviceLocator */
79
77
$ serviceLocator = $ this ->createMock (ServiceLocator::class);
@@ -86,9 +84,40 @@ public function testReceiverNameArgumentNotFound()
86
84
87
85
$ command = new SetupTransportsCommand ($ serviceLocator , ['amqp ' , 'other_transport ' ]);
88
86
$ tester = new CommandTester ($ command );
87
+
88
+ $ this ->expectException (\RuntimeException::class);
89
+ $ this ->expectExceptionMessage ('The "not_found" transport does not exist. ' );
89
90
$ tester ->execute (['transport ' => 'not_found ' ]);
90
91
}
91
92
93
+ public function testThrowsExceptionOnTransportSetup ()
94
+ {
95
+ // mock a setupable-transport, that throws
96
+ $ amqpTransport = $ this ->createMock (SetupableTransportInterface::class);
97
+ $ amqpTransport ->expects ($ this ->exactly (1 ))
98
+ ->method ('setup ' )
99
+ ->willThrowException (new \RuntimeException ('Server not found ' ));
100
+
101
+ // mock a service locator
102
+ /** @var MockObject&ServiceLocator $serviceLocator */
103
+ $ serviceLocator = $ this ->createMock (ServiceLocator::class);
104
+ $ serviceLocator ->expects ($ this ->exactly (1 ))
105
+ ->method ('get ' )
106
+ ->will ($ this ->onConsecutiveCalls (
107
+ $ amqpTransport
108
+ ));
109
+ $ serviceLocator
110
+ ->method ('has ' )
111
+ ->willReturn (true );
112
+
113
+ $ command = new SetupTransportsCommand ($ serviceLocator , ['amqp ' ]);
114
+ $ tester = new CommandTester ($ command );
115
+
116
+ $ this ->expectException (\RuntimeException::class);
117
+ $ this ->expectExceptionMessage ('An error occurred while setting up the "amqp" transport: Server not found ' );
118
+ $ tester ->execute (['transport ' => 'amqp ' ]);
119
+ }
120
+
92
121
/**
93
122
* @dataProvider provideCompletionSuggestions
94
123
*/
0 commit comments