33namespace OldSound \RabbitMqBundle \Tests \RabbitMq ;
44
55use OldSound \RabbitMqBundle \RabbitMq \RpcClient ;
6+ use PhpAmqpLib \Exception \AMQPTimeoutException ;
67use PhpAmqpLib \Message \AMQPMessage ;
78use PHPUnit \Framework \TestCase ;
89
@@ -55,9 +56,6 @@ public function testProcessMessageWithNotifyMethod()
5556 $ this ->assertSame ($ expectedNotify , $ notified );
5657 }
5758
58- /**
59- * @expectedException \InvalidArgumentException
60- */
6159 public function testInvalidParameterOnNotify ()
6260 {
6361 /** @var RpcClient $client */
@@ -66,6 +64,34 @@ public function testInvalidParameterOnNotify()
6664 ->disableOriginalConstructor ()
6765 ->getMock ();
6866
67+ $ this ->expectException ('\InvalidArgumentException ' );
68+
6969 $ client ->notify ('not a callable ' );
7070 }
71+
72+ public function testChannelCancelOnGetRepliesException ()
73+ {
74+ $ client = $ this ->getMockBuilder ('\OldSound\RabbitMqBundle\RabbitMq\RpcClient ' )
75+ ->setMethods (null )
76+ ->disableOriginalConstructor ()
77+ ->getMock ();
78+
79+ $ channel = $ this ->createMock ('\PhpAmqpLib\Channel\AMQPChannel ' );
80+ $ channel ->expects ($ this ->any ())
81+ ->method ('getChannelId ' )
82+ ->willReturn ('test ' );
83+ $ channel ->expects ($ this ->once ())
84+ ->method ('wait ' )
85+ ->willThrowException (new AMQPTimeoutException ());
86+
87+ $ this ->expectException ('\PhpAmqpLib\Exception\AMQPTimeoutException ' );
88+
89+ $ channel ->expects ($ this ->once ())
90+ ->method ('basic_cancel ' );
91+
92+ $ client ->setChannel ($ channel );
93+ $ client ->addRequest ('a ' , 'b ' , 'c ' );
94+
95+ $ client ->getReplies ();
96+ }
7197}
0 commit comments