Skip to content

Commit 4b654ae

Browse files
committed
add tests.
1 parent ae1e4d1 commit 4b654ae

File tree

6 files changed

+141
-0
lines changed

6 files changed

+141
-0
lines changed

pkg/amqp-bunny/Tests/AmqpContextTest.php

+16
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,11 @@
55
use Bunny\Channel;
66
use Bunny\Protocol\MethodQueueDeclareOkFrame;
77
use Enqueue\AmqpBunny\AmqpContext;
8+
use Enqueue\AmqpBunny\AmqpSubscriptionConsumer;
89
use Interop\Amqp\Impl\AmqpBind;
910
use Interop\Amqp\Impl\AmqpQueue;
1011
use Interop\Amqp\Impl\AmqpTopic;
12+
use Interop\Queue\PsrSubscriptionConsumerAwareContext;
1113
use PHPUnit\Framework\TestCase;
1214

1315
class AmqpContextTest extends TestCase
@@ -235,6 +237,20 @@ public function testShouldSetQos()
235237
$context->setQos(123, 456, true);
236238
}
237239

240+
public function testShouldImplementPsrSubscriptionConsumerAwareInterface()
241+
{
242+
$rc = new \ReflectionClass(AmqpContext::class);
243+
244+
$this->assertTrue($rc->implementsInterface(PsrSubscriptionConsumerAwareContext::class));
245+
}
246+
247+
public function testShouldReturnExpectedSubscriptionConsumerInstance()
248+
{
249+
$context = new AmqpContext($this->createChannelMock());
250+
251+
$this->assertInstanceOf(AmqpSubscriptionConsumer::class, $context->createSubscriptionConsumer());
252+
}
253+
238254
/**
239255
* @return \PHPUnit_Framework_MockObject_MockObject|Channel
240256
*/
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
<?php
2+
3+
namespace Enqueue\AmqpBunny\Tests;
4+
5+
use Enqueue\AmqpBunny\AmqpContext;
6+
use Enqueue\AmqpBunny\AmqpSubscriptionConsumer;
7+
use Interop\Queue\PsrSubscriptionConsumer;
8+
use PHPUnit\Framework\TestCase;
9+
10+
class AmqpSubscriptionConsumerTest extends TestCase
11+
{
12+
public function testShouldImplementPsrSubscriptionConsumerInterface()
13+
{
14+
$rc = new \ReflectionClass(AmqpSubscriptionConsumer::class);
15+
16+
$this->assertTrue($rc->implementsInterface(PsrSubscriptionConsumer::class));
17+
}
18+
19+
public function testCouldBeConstructedWithAmqpContextAsFirstArgument()
20+
{
21+
new AmqpSubscriptionConsumer($this->createAmqpContextMock());
22+
}
23+
24+
/**
25+
* @return AmqpContext|\PHPUnit_Framework_MockObject_MockObject
26+
*/
27+
private function createAmqpContextMock()
28+
{
29+
return $this->createMock(AmqpContext::class);
30+
}
31+
}

pkg/amqp-ext/Tests/AmqpContextTest.php

+16
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
use Enqueue\AmqpExt\AmqpConsumer;
66
use Enqueue\AmqpExt\AmqpContext;
77
use Enqueue\AmqpExt\AmqpProducer;
8+
use Enqueue\AmqpExt\AmqpSubscriptionConsumer;
89
use Enqueue\AmqpExt\Buffer;
910
use Enqueue\Null\NullQueue;
1011
use Enqueue\Null\NullTopic;
@@ -14,6 +15,7 @@
1415
use Interop\Amqp\Impl\AmqpTopic;
1516
use Interop\Queue\InvalidDestinationException;
1617
use Interop\Queue\PsrContext;
18+
use Interop\Queue\PsrSubscriptionConsumerAwareContext;
1719
use PHPUnit\Framework\TestCase;
1820

1921
class AmqpContextTest extends TestCase
@@ -248,6 +250,20 @@ public function testShouldClosePersistedConnection()
248250
$context->close();
249251
}
250252

253+
public function testShouldImplementPsrSubscriptionConsumerAwareInterface()
254+
{
255+
$rc = new \ReflectionClass(AmqpContext::class);
256+
257+
$this->assertTrue($rc->implementsInterface(PsrSubscriptionConsumerAwareContext::class));
258+
}
259+
260+
public function testShouldReturnExpectedSubscriptionConsumerInstance()
261+
{
262+
$context = new AmqpContext($this->createExtChannelMock(), 'basic_get');
263+
264+
$this->assertInstanceOf(AmqpSubscriptionConsumer::class, $context->createSubscriptionConsumer());
265+
}
266+
251267
/**
252268
* @return \PHPUnit_Framework_MockObject_MockObject|\AMQPChannel
253269
*/
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
<?php
2+
3+
namespace Enqueue\AmqpExt\Tests;
4+
5+
use Enqueue\AmqpExt\AmqpContext;
6+
use Enqueue\AmqpExt\AmqpSubscriptionConsumer;
7+
use Interop\Queue\PsrSubscriptionConsumer;
8+
use PHPUnit\Framework\TestCase;
9+
10+
class AmqpSubscriptionConsumerTest extends TestCase
11+
{
12+
public function testShouldImplementPsrSubscriptionConsumerInterface()
13+
{
14+
$rc = new \ReflectionClass(AmqpSubscriptionConsumer::class);
15+
16+
$this->assertTrue($rc->implementsInterface(PsrSubscriptionConsumer::class));
17+
}
18+
19+
public function testCouldBeConstructedWithAmqpContextAsFirstArgument()
20+
{
21+
new AmqpSubscriptionConsumer($this->createAmqpContextMock());
22+
}
23+
24+
/**
25+
* @return AmqpContext|\PHPUnit_Framework_MockObject_MockObject
26+
*/
27+
private function createAmqpContextMock()
28+
{
29+
return $this->createMock(AmqpContext::class);
30+
}
31+
}

pkg/amqp-lib/Tests/AmqpContextTest.php

+16
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,11 @@
33
namespace Enqueue\AmqpLib\Tests;
44

55
use Enqueue\AmqpLib\AmqpContext;
6+
use Enqueue\AmqpLib\AmqpSubscriptionConsumer;
67
use Interop\Amqp\Impl\AmqpBind;
78
use Interop\Amqp\Impl\AmqpQueue;
89
use Interop\Amqp\Impl\AmqpTopic;
10+
use Interop\Queue\PsrSubscriptionConsumerAwareContext;
911
use PhpAmqpLib\Channel\AMQPChannel;
1012
use PhpAmqpLib\Connection\AbstractConnection;
1113
use PhpAmqpLib\Wire\AMQPTable;
@@ -314,6 +316,20 @@ public function testShouldSetQos()
314316
$context->setQos(123, 456, true);
315317
}
316318

319+
public function testShouldImplementPsrSubscriptionConsumerAwareInterface()
320+
{
321+
$rc = new \ReflectionClass(AmqpContext::class);
322+
323+
$this->assertTrue($rc->implementsInterface(PsrSubscriptionConsumerAwareContext::class));
324+
}
325+
326+
public function testShouldReturnExpectedSubscriptionConsumerInstance()
327+
{
328+
$context = new AmqpContext($this->createConnectionMock());
329+
330+
$this->assertInstanceOf(AmqpSubscriptionConsumer::class, $context->createSubscriptionConsumer());
331+
}
332+
317333
/**
318334
* @return \PHPUnit_Framework_MockObject_MockObject|AbstractConnection
319335
*/
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
<?php
2+
3+
namespace Enqueue\AmqpLib\Tests;
4+
5+
use Enqueue\AmqpLib\AmqpContext;
6+
use Enqueue\AmqpLib\AmqpSubscriptionConsumer;
7+
use Interop\Queue\PsrSubscriptionConsumer;
8+
use PHPUnit\Framework\TestCase;
9+
10+
class AmqpSubscriptionConsumerTest extends TestCase
11+
{
12+
public function testShouldImplementPsrSubscriptionConsumerInterface()
13+
{
14+
$rc = new \ReflectionClass(AmqpSubscriptionConsumer::class);
15+
16+
$this->assertTrue($rc->implementsInterface(PsrSubscriptionConsumer::class));
17+
}
18+
19+
public function testCouldBeConstructedWithAmqpContextAsFirstArgument()
20+
{
21+
new AmqpSubscriptionConsumer($this->createAmqpContextMock());
22+
}
23+
24+
/**
25+
* @return AmqpContext|\PHPUnit_Framework_MockObject_MockObject
26+
*/
27+
private function createAmqpContextMock()
28+
{
29+
return $this->createMock(AmqpContext::class);
30+
}
31+
}

0 commit comments

Comments
 (0)