3
3
namespace OldSound \RabbitMqBundle \Tests \RabbitMq ;
4
4
5
5
use OldSound \RabbitMqBundle \RabbitMq \RpcClient ;
6
+ use PhpAmqpLib \Exception \AMQPTimeoutException ;
6
7
use PhpAmqpLib \Message \AMQPMessage ;
7
8
use PHPUnit \Framework \TestCase ;
8
9
@@ -55,9 +56,6 @@ public function testProcessMessageWithNotifyMethod()
55
56
$ this ->assertSame ($ expectedNotify , $ notified );
56
57
}
57
58
58
- /**
59
- * @expectedException \InvalidArgumentException
60
- */
61
59
public function testInvalidParameterOnNotify ()
62
60
{
63
61
/** @var RpcClient $client */
@@ -66,6 +64,34 @@ public function testInvalidParameterOnNotify()
66
64
->disableOriginalConstructor ()
67
65
->getMock ();
68
66
67
+ $ this ->expectException ('\InvalidArgumentException ' );
68
+
69
69
$ client ->notify ('not a callable ' );
70
70
}
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
+ }
71
97
}
0 commit comments