1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Aimeos\MW\MQueue; |
4
|
|
|
|
5
|
|
|
|
6
|
|
|
class AMQPTest extends \PHPUnit_Framework_TestCase |
7
|
|
|
{ |
8
|
|
|
protected function setUp() |
9
|
|
|
{ |
10
|
|
|
if( class_exists( '\PhpAmqpLib\Connection\AMQPStreamConnection' ) === false ) { |
11
|
|
|
$this->markTestSkipped( 'Please install the "php-amqplib" library via composer first' ); |
12
|
|
|
} |
13
|
|
|
} |
14
|
|
|
|
15
|
|
|
|
16
|
|
|
public function testProcess() |
17
|
|
|
{ |
18
|
|
|
try |
19
|
|
|
{ |
20
|
|
|
$mqueue = new \Aimeos\MW\MQueue\AMQP( array( 'host' => 'localhost' ) ); |
21
|
|
|
$queue = $mqueue->getQueue( 'aimeos_unittest' ); |
22
|
|
|
} |
23
|
|
|
catch( \Aimeos\MW\MQueue\Exception $e ) |
|
|
|
|
24
|
|
|
{ |
25
|
|
|
$this->markTestSkipped( 'No AMQP compliant server available at "localhost"' ); |
26
|
|
|
} |
27
|
|
|
|
28
|
|
|
$queue->add( 'testmsg' ); |
|
|
|
|
29
|
|
|
$msg = $queue->get(); |
30
|
|
|
$queue->del( $msg ); |
31
|
|
|
|
32
|
|
|
$this->assertNull( $queue->get() ); |
33
|
|
|
} |
34
|
|
|
|
35
|
|
|
|
36
|
|
|
public function testSingleConnection() |
37
|
|
|
{ |
38
|
|
|
$this->setExpectedException( '\Aimeos\MW\MQueue\Exception' ); |
39
|
|
|
new \Aimeos\MW\MQueue\AMQP( array( 'host' => '192.168.255.255', 'connection_timeout' => 0.1 ) ); |
40
|
|
|
} |
41
|
|
|
|
42
|
|
|
|
43
|
|
|
public function testMultiConnection() |
44
|
|
|
{ |
45
|
|
|
$this->setExpectedException( '\Aimeos\MW\MQueue\Exception' ); |
46
|
|
|
new \Aimeos\MW\MQueue\AMQP( array( 'host' => array( '192.168.254.255', '192.168.255.255' ), 'connection_timeout' => 0.1 ) ); |
47
|
|
|
} |
48
|
|
|
|
49
|
|
|
|
50
|
|
View Code Duplication |
public function testGetQueue() |
|
|
|
|
51
|
|
|
{ |
52
|
|
|
$channel = $this->getMockBuilder( 'PhpAmqpLib\Channel\AMQPChannel' ) |
53
|
|
|
->disableOriginalConstructor() |
54
|
|
|
->getMock(); |
55
|
|
|
|
56
|
|
|
$object = $this->getMockBuilder( '\Aimeos\MW\MQueue\AMQP' ) |
57
|
|
|
->setMethods( array( 'getChannel', '__destruct' ) ) |
58
|
|
|
->disableOriginalConstructor() |
59
|
|
|
->getMock(); |
60
|
|
|
|
61
|
|
|
$object->expects( $this->once() )->method( 'getChannel' ) |
62
|
|
|
->will( $this->returnValue( $channel ) ); |
63
|
|
|
|
64
|
|
|
$this->assertInstanceOf( '\Aimeos\MW\MQueue\Queue\Iface', $object->getQueue( 'test' ) ); |
65
|
|
|
} |
66
|
|
|
|
67
|
|
|
|
68
|
|
|
public function testGetQueueException() |
69
|
|
|
{ |
70
|
|
|
$object = $this->getMockBuilder( '\Aimeos\MW\MQueue\AMQP' ) |
71
|
|
|
->setMethods( array( 'getChannel', '__destruct' ) ) |
72
|
|
|
->disableOriginalConstructor() |
73
|
|
|
->getMock(); |
74
|
|
|
|
75
|
|
|
$object->expects( $this->once() )->method( 'getChannel' ) |
76
|
|
|
->will( $this->throwException( new \Exception() ) ); |
77
|
|
|
|
78
|
|
|
$this->setExpectedException( '\Aimeos\MW\MQueue\Exception' ); |
79
|
|
|
$object->getQueue( 'test' ); |
80
|
|
|
} |
81
|
|
|
} |
82
|
|
|
|
Scrutinizer analyzes your
composer.json
/composer.lock
file if available to determine the classes, and functions that are defined by your dependencies.It seems like the listed class was neither found in your dependencies, nor was it found in the analyzed files in your repository. If you are using some other form of dependency management, you might want to disable this analysis.