55use OldSound \RabbitMqBundle \Event \AMQPEvent ;
66use OldSound \RabbitMqBundle \RabbitMq \BaseAmqp ;
77use OldSound \RabbitMqBundle \RabbitMq \Consumer ;
8- use PhpAmqpLib \Connection \AMQPLazyConnection ;
98
109class BaseAmqpTest extends \PHPUnit_Framework_TestCase
1110{
12- /**
13- * @expectedException \ErrorException
14- */
11+
1512 public function testLazyConnection ()
1613 {
17- $ amqpLazyConnection = new AMQPLazyConnection ('localhost ' , 123 , 'lazy_user ' , 'lazy_password ' );
14+ $ connection = $ this ->getMockBuilder ('PhpAmqpLib\Connection\AbstractConnection ' )
15+ ->disableOriginalConstructor ()
16+ ->getMock ();
17+
18+ $ connection
19+ ->method ('connectOnConstruct ' )
20+ ->willReturn (false );
21+ $ connection
22+ ->expects (static ::never ())
23+ ->method ('channel ' );
24+
25+ new Consumer ($ connection , null );
26+ }
27+
28+ public function testNotLazyConnection ()
29+ {
30+ $ connection = $ this ->getMockBuilder ('PhpAmqpLib\Connection\AbstractConnection ' )
31+ ->disableOriginalConstructor ()
32+ ->getMock ();
33+
34+ $ connection
35+ ->method ('connectOnConstruct ' )
36+ ->willReturn (true );
37+ $ connection
38+ ->expects (static ::once ())
39+ ->method ('channel ' );
1840
19- $ consumer = new Consumer ($ amqpLazyConnection , null );
20- $ consumer ->getChannel ();
41+ new Consumer ($ connection , null );
2142 }
2243
2344 public function testDispatchEvent ()
@@ -26,7 +47,7 @@ public function testDispatchEvent()
2647 $ baseAmqpConsumer = $ this ->getMockBuilder ('OldSound\RabbitMqBundle\RabbitMq\BaseAmqp ' )
2748 ->disableOriginalConstructor ()
2849 ->getMock ();
29- $ eventDispatcher = $ this ->getMockBuilder ('Symfony\Component\EventDispatcher\EventDispatcher ' )
50+ $ eventDispatcher = $ this ->getMockBuilder ('Symfony\Component\EventDispatcher\EventDispatcherInterface ' )
3051 ->disableOriginalConstructor ()
3152 ->getMock ();
3253 $ baseAmqpConsumer ->expects ($ this ->atLeastOnce ())
0 commit comments