5
5
use OldSound \RabbitMqBundle \Event \AMQPEvent ;
6
6
use OldSound \RabbitMqBundle \RabbitMq \BaseAmqp ;
7
7
use OldSound \RabbitMqBundle \RabbitMq \Consumer ;
8
- use PhpAmqpLib \Connection \AMQPLazyConnection ;
9
8
10
9
class BaseAmqpTest extends \PHPUnit_Framework_TestCase
11
10
{
12
- /**
13
- * @expectedException \ErrorException
14
- */
11
+
15
12
public function testLazyConnection ()
16
13
{
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 ' );
18
40
19
- $ consumer = new Consumer ($ amqpLazyConnection , null );
20
- $ consumer ->getChannel ();
41
+ new Consumer ($ connection , null );
21
42
}
22
43
23
44
public function testDispatchEvent ()
@@ -26,7 +47,7 @@ public function testDispatchEvent()
26
47
$ baseAmqpConsumer = $ this ->getMockBuilder ('OldSound\RabbitMqBundle\RabbitMq\BaseAmqp ' )
27
48
->disableOriginalConstructor ()
28
49
->getMock ();
29
- $ eventDispatcher = $ this ->getMockBuilder ('Symfony\Component\EventDispatcher\EventDispatcher ' )
50
+ $ eventDispatcher = $ this ->getMockBuilder ('Symfony\Component\EventDispatcher\EventDispatcherInterface ' )
30
51
->disableOriginalConstructor ()
31
52
->getMock ();
32
53
$ baseAmqpConsumer ->expects ($ this ->atLeastOnce ())
0 commit comments