forked from php-amqplib/RabbitMqBundle
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add DequeuerInterface to BaseConsumer.
- Loading branch information
1 parent
f2124c4
commit 26fdd2d
Showing
4 changed files
with
84 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
<?php | ||
|
||
namespace OldSound\RabbitMqBundle\RabbitMq; | ||
|
||
interface DequeuerAwareInterface | ||
{ | ||
public function setDequeuer(DequeuerInterface $dequeuer); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
<?php | ||
|
||
namespace OldSound\RabbitMqBundle\RabbitMq; | ||
|
||
interface DequeuerInterface | ||
{ | ||
/** | ||
* Stop dequeuing messages. | ||
* | ||
* @return void | ||
*/ | ||
public function forceStopConsumer(); | ||
|
||
/** | ||
* Set idle timeout | ||
* | ||
* @param $idleTimeout | ||
* | ||
* @return void | ||
*/ | ||
public function setIdleTimeout($idleTimeout); | ||
|
||
/** | ||
* Get current idle timeout | ||
* | ||
* @return int | ||
*/ | ||
public function getIdleTimeout(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
<?php | ||
|
||
namespace OldSound\RabbitMqBundle\Tests\RabbitMq; | ||
|
||
use OldSound\RabbitMqBundle\RabbitMq\BaseConsumer; | ||
|
||
class BaseConsumerTest extends \PHPUnit_Framework_TestCase | ||
{ | ||
/** @var BaseConsumer */ | ||
protected $consumer; | ||
|
||
protected function setUp() | ||
{ | ||
$amqpConnection = $this->getMockBuilder('\PhpAmqpLib\Connection\AMQPConnection') | ||
->disableOriginalConstructor() | ||
->getMock(); | ||
|
||
$this->consumer = $this->getMockBuilder('\OldSound\RabbitMqBundle\RabbitMq\BaseConsumer') | ||
->setConstructorArgs(array($amqpConnection)) | ||
->getMockForAbstractClass(); | ||
} | ||
|
||
public function testItExtendsBaseAmqpInterface() | ||
{ | ||
$this->assertInstanceOf('OldSound\RabbitMqBundle\RabbitMq\BaseAmqp', $this->consumer); | ||
} | ||
|
||
public function testItImplementsDequeuerInterface() | ||
{ | ||
$this->assertInstanceOf('OldSound\RabbitMqBundle\RabbitMq\DequeuerInterface', $this->consumer); | ||
} | ||
|
||
public function testItsIdleTimeoutIsMutable() | ||
{ | ||
$this->assertEquals(0, $this->consumer->getIdleTimeout()); | ||
$this->consumer->setIdleTimeout(42); | ||
$this->assertEquals(42, $this->consumer->getIdleTimeout()); | ||
} | ||
|
||
public function testForceStopConsumer() | ||
{ | ||
$this->assertAttributeEquals(false, 'forceStop', $this->consumer); | ||
$this->consumer->forceStopConsumer(); | ||
$this->assertAttributeEquals(true, 'forceStop', $this->consumer); | ||
} | ||
} |