Skip to content

Commit

Permalink
add tests.
Browse files Browse the repository at this point in the history
  • Loading branch information
makasim committed Aug 9, 2018
1 parent da099f9 commit 1dc3876
Show file tree
Hide file tree
Showing 6 changed files with 141 additions and 0 deletions.
16 changes: 16 additions & 0 deletions pkg/amqp-bunny/Tests/AmqpContextTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,11 @@
use Bunny\Channel;
use Bunny\Protocol\MethodQueueDeclareOkFrame;
use Enqueue\AmqpBunny\AmqpContext;
use Enqueue\AmqpBunny\AmqpSubscriptionConsumer;
use Interop\Amqp\Impl\AmqpBind;
use Interop\Amqp\Impl\AmqpQueue;
use Interop\Amqp\Impl\AmqpTopic;
use Interop\Queue\PsrSubscriptionConsumerAwareContext;
use PHPUnit\Framework\TestCase;

class AmqpContextTest extends TestCase
Expand Down Expand Up @@ -235,6 +237,20 @@ public function testShouldSetQos()
$context->setQos(123, 456, true);
}

public function testShouldImplementPsrSubscriptionConsumerAwareInterface()
{
$rc = new \ReflectionClass(AmqpContext::class);

$this->assertTrue($rc->implementsInterface(PsrSubscriptionConsumerAwareContext::class));
}

public function testShouldReturnExpectedSubscriptionConsumerInstance()
{
$context = new AmqpContext($this->createChannelMock());

$this->assertInstanceOf(AmqpSubscriptionConsumer::class, $context->createSubscriptionConsumer());
}

/**
* @return \PHPUnit_Framework_MockObject_MockObject|Channel
*/
Expand Down
31 changes: 31 additions & 0 deletions pkg/amqp-bunny/Tests/AmqpSubscriptionConsumerTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<?php

namespace Enqueue\AmqpBunny\Tests;

use Enqueue\AmqpBunny\AmqpContext;
use Enqueue\AmqpBunny\AmqpSubscriptionConsumer;
use Interop\Queue\PsrSubscriptionConsumer;
use PHPUnit\Framework\TestCase;

class AmqpSubscriptionConsumerTest extends TestCase
{
public function testShouldImplementPsrSubscriptionConsumerInterface()
{
$rc = new \ReflectionClass(AmqpSubscriptionConsumer::class);

$this->assertTrue($rc->implementsInterface(PsrSubscriptionConsumer::class));
}

public function testCouldBeConstructedWithAmqpContextAsFirstArgument()
{
new AmqpSubscriptionConsumer($this->createAmqpContextMock());
}

/**
* @return AmqpContext|\PHPUnit_Framework_MockObject_MockObject
*/
private function createAmqpContextMock()
{
return $this->createMock(AmqpContext::class);
}
}
16 changes: 16 additions & 0 deletions pkg/amqp-ext/Tests/AmqpContextTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
use Enqueue\AmqpExt\AmqpConsumer;
use Enqueue\AmqpExt\AmqpContext;
use Enqueue\AmqpExt\AmqpProducer;
use Enqueue\AmqpExt\AmqpSubscriptionConsumer;
use Enqueue\AmqpExt\Buffer;
use Enqueue\Null\NullQueue;
use Enqueue\Null\NullTopic;
Expand All @@ -14,6 +15,7 @@
use Interop\Amqp\Impl\AmqpTopic;
use Interop\Queue\InvalidDestinationException;
use Interop\Queue\PsrContext;
use Interop\Queue\PsrSubscriptionConsumerAwareContext;
use PHPUnit\Framework\TestCase;

class AmqpContextTest extends TestCase
Expand Down Expand Up @@ -248,6 +250,20 @@ public function testShouldClosePersistedConnection()
$context->close();
}

public function testShouldImplementPsrSubscriptionConsumerAwareInterface()
{
$rc = new \ReflectionClass(AmqpContext::class);

$this->assertTrue($rc->implementsInterface(PsrSubscriptionConsumerAwareContext::class));
}

public function testShouldReturnExpectedSubscriptionConsumerInstance()
{
$context = new AmqpContext($this->createExtChannelMock(), 'basic_get');

$this->assertInstanceOf(AmqpSubscriptionConsumer::class, $context->createSubscriptionConsumer());
}

/**
* @return \PHPUnit_Framework_MockObject_MockObject|\AMQPChannel
*/
Expand Down
31 changes: 31 additions & 0 deletions pkg/amqp-ext/Tests/AmqpSubscriptionConsumerTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<?php

namespace Enqueue\AmqpExt\Tests;

use Enqueue\AmqpExt\AmqpContext;
use Enqueue\AmqpExt\AmqpSubscriptionConsumer;
use Interop\Queue\PsrSubscriptionConsumer;
use PHPUnit\Framework\TestCase;

class AmqpSubscriptionConsumerTest extends TestCase
{
public function testShouldImplementPsrSubscriptionConsumerInterface()
{
$rc = new \ReflectionClass(AmqpSubscriptionConsumer::class);

$this->assertTrue($rc->implementsInterface(PsrSubscriptionConsumer::class));
}

public function testCouldBeConstructedWithAmqpContextAsFirstArgument()
{
new AmqpSubscriptionConsumer($this->createAmqpContextMock());
}

/**
* @return AmqpContext|\PHPUnit_Framework_MockObject_MockObject
*/
private function createAmqpContextMock()
{
return $this->createMock(AmqpContext::class);
}
}
16 changes: 16 additions & 0 deletions pkg/amqp-lib/Tests/AmqpContextTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,11 @@
namespace Enqueue\AmqpLib\Tests;

use Enqueue\AmqpLib\AmqpContext;
use Enqueue\AmqpLib\AmqpSubscriptionConsumer;
use Interop\Amqp\Impl\AmqpBind;
use Interop\Amqp\Impl\AmqpQueue;
use Interop\Amqp\Impl\AmqpTopic;
use Interop\Queue\PsrSubscriptionConsumerAwareContext;
use PhpAmqpLib\Channel\AMQPChannel;
use PhpAmqpLib\Connection\AbstractConnection;
use PhpAmqpLib\Wire\AMQPTable;
Expand Down Expand Up @@ -314,6 +316,20 @@ public function testShouldSetQos()
$context->setQos(123, 456, true);
}

public function testShouldImplementPsrSubscriptionConsumerAwareInterface()
{
$rc = new \ReflectionClass(AmqpContext::class);

$this->assertTrue($rc->implementsInterface(PsrSubscriptionConsumerAwareContext::class));
}

public function testShouldReturnExpectedSubscriptionConsumerInstance()
{
$context = new AmqpContext($this->createConnectionMock());

$this->assertInstanceOf(AmqpSubscriptionConsumer::class, $context->createSubscriptionConsumer());
}

/**
* @return \PHPUnit_Framework_MockObject_MockObject|AbstractConnection
*/
Expand Down
31 changes: 31 additions & 0 deletions pkg/amqp-lib/Tests/AmqpSubscriptionConsumerTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<?php

namespace Enqueue\AmqpLib\Tests;

use Enqueue\AmqpLib\AmqpContext;
use Enqueue\AmqpLib\AmqpSubscriptionConsumer;
use Interop\Queue\PsrSubscriptionConsumer;
use PHPUnit\Framework\TestCase;

class AmqpSubscriptionConsumerTest extends TestCase
{
public function testShouldImplementPsrSubscriptionConsumerInterface()
{
$rc = new \ReflectionClass(AmqpSubscriptionConsumer::class);

$this->assertTrue($rc->implementsInterface(PsrSubscriptionConsumer::class));
}

public function testCouldBeConstructedWithAmqpContextAsFirstArgument()
{
new AmqpSubscriptionConsumer($this->createAmqpContextMock());
}

/**
* @return AmqpContext|\PHPUnit_Framework_MockObject_MockObject
*/
private function createAmqpContextMock()
{
return $this->createMock(AmqpContext::class);
}
}

0 comments on commit 1dc3876

Please sign in to comment.