1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Aimeos\MW\MQueue; |
4
|
|
|
|
5
|
|
|
|
6
|
|
|
class StompTest extends \PHPUnit_Framework_TestCase |
7
|
|
|
{ |
8
|
|
|
protected function setUp() |
9
|
|
|
{ |
10
|
|
|
if( class_exists( '\Stomp' ) === false ) { |
11
|
|
|
$this->markTestSkipped( 'Please install the "stomp" PHP extension first' ); |
12
|
|
|
} |
13
|
|
|
} |
14
|
|
|
|
15
|
|
|
|
16
|
|
View Code Duplication |
public function testProcess() |
|
|
|
|
17
|
|
|
{ |
18
|
|
|
try |
19
|
|
|
{ |
20
|
|
|
$config = array( 'username' => 'guest', 'password' => 'guest' ); |
21
|
|
|
$mqueue = new \Aimeos\MW\MQueue\Stomp( $config ); |
22
|
|
|
$queue = $mqueue->getQueue( 'aimeos_unittest' ); |
23
|
|
|
} |
24
|
|
|
catch( \Aimeos\MW\MQueue\Exception $e ) |
|
|
|
|
25
|
|
|
{ |
26
|
|
|
$this->markTestSkipped( 'No Stomp compliant server available at "localhost"' ); |
27
|
|
|
} |
28
|
|
|
|
29
|
|
|
$queue->add( 'testmsg' ); |
|
|
|
|
30
|
|
|
$msg = $queue->get(); |
31
|
|
|
$queue->del( $msg ); |
32
|
|
|
|
33
|
|
|
$this->assertNull( $queue->get() ); |
34
|
|
|
} |
35
|
|
|
|
36
|
|
|
|
37
|
|
|
public function testGetQueueSingleConnection() |
38
|
|
|
{ |
39
|
|
|
$object = new \Aimeos\MW\MQueue\Stomp( array( 'host' => 'tcp://127.0.0.1:61616' ) ); |
|
|
|
|
40
|
|
|
} |
41
|
|
|
|
42
|
|
|
|
43
|
|
|
public function testGetQueueMultiConnection() |
44
|
|
|
{ |
45
|
|
|
$object = new \Aimeos\MW\MQueue\Stomp( array( 'host' => array( 'tcp://127.0.0.1:61616', 'tcp://127.0.0.1:61617' ) ) ); |
|
|
|
|
46
|
|
|
} |
47
|
|
|
|
48
|
|
|
|
49
|
|
View Code Duplication |
public function testGetQueue() |
|
|
|
|
50
|
|
|
{ |
51
|
|
|
$client = $this->getMockBuilder( '\Stomp' ) |
52
|
|
|
->disableOriginalConstructor() |
53
|
|
|
->getMock(); |
54
|
|
|
|
55
|
|
|
$object = $this->getMockBuilder( '\Aimeos\MW\MQueue\Stomp' ) |
56
|
|
|
->setMethods( array( 'connect' ) ) |
57
|
|
|
->disableOriginalConstructor() |
58
|
|
|
->getMock(); |
59
|
|
|
|
60
|
|
|
$object->expects( $this->once() )->method( 'connect' ) |
61
|
|
|
->will( $this->returnValue( $client ) ); |
62
|
|
|
|
63
|
|
|
$this->assertInstanceOf( '\Aimeos\MW\MQueue\Queue\Iface', $object->getQueue( 'test' ) ); |
64
|
|
|
} |
65
|
|
|
} |
66
|
|
|
|
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.
You can also find more detailed suggestions in the “Code” section of your repository.