@@ -49,6 +49,7 @@ public function testShouldSetRouterProcessorPropertyIfNotSetAndOnRouterQueue()
4949 ;
5050
5151 $ message = new NullMessage ();
52+ $ message ->setProperty (Config::TOPIC , 'aTopic ' );
5253
5354 $ messageReceived = new MessageReceived (
5455 $ this ->createContextMock (),
@@ -64,6 +65,7 @@ public function testShouldSetRouterProcessorPropertyIfNotSetAndOnRouterQueue()
6465
6566 $ this ->assertEquals ([
6667 Config::PROCESSOR => 'router-processor-name ' ,
68+ Config::TOPIC => 'aTopic ' ,
6769 ], $ message ->getProperties ());
6870 }
6971
@@ -86,6 +88,7 @@ public function testShouldNotSetRouterProcessorPropertyIfNotSetAndNotOnRouterQue
8688 ;
8789
8890 $ message = new NullMessage ();
91+ $ message ->setProperty (Config::TOPIC , 'aTopic ' );
8992
9093 $ messageReceived = new MessageReceived (
9194 $ this ->createContextMock (),
@@ -99,7 +102,9 @@ public function testShouldNotSetRouterProcessorPropertyIfNotSetAndNotOnRouterQue
99102 $ extension = new SetRouterPropertiesExtension ($ driver );
100103 $ extension ->onMessageReceived ($ messageReceived );
101104
102- $ this ->assertEquals ([], $ message ->getProperties ());
105+ $ this ->assertEquals ([
106+ Config::TOPIC => 'aTopic ' ,
107+ ], $ message ->getProperties ());
103108 }
104109
105110 public function testShouldNotSetAnyPropertyIfProcessorNamePropertyAlreadySet ()
@@ -130,6 +135,31 @@ public function testShouldNotSetAnyPropertyIfProcessorNamePropertyAlreadySet()
130135 ], $ message ->getProperties ());
131136 }
132137
138+ public function testShouldSkipMessagesWithoutTopicPropertySet ()
139+ {
140+ $ driver = $ this ->createDriverMock ();
141+ $ driver
142+ ->expects ($ this ->never ())
143+ ->method ('getConfig ' )
144+ ;
145+
146+ $ message = new NullMessage ();
147+
148+ $ messageReceived = new MessageReceived (
149+ $ this ->createContextMock (),
150+ $ this ->createConsumerStub (null ),
151+ $ message ,
152+ $ this ->createProcessorMock (),
153+ 1 ,
154+ new NullLogger ()
155+ );
156+
157+ $ extension = new SetRouterPropertiesExtension ($ driver );
158+ $ extension ->onMessageReceived ($ messageReceived );
159+
160+ $ this ->assertEquals ([], $ message ->getProperties ());
161+ }
162+
133163 /**
134164 * @return \PHPUnit_Framework_MockObject_MockObject|InteropContext
135165 */
0 commit comments