-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #3 from robcaw/feature-max-priority
Add max priority to queue
- Loading branch information
Showing
3 changed files
with
84 additions
and
0 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
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,60 @@ | ||
<?php | ||
|
||
namespace Radish\Broker; | ||
|
||
use AMQPQueue; | ||
use Mockery; | ||
use Mockery\Mock; | ||
use PHPUnit_Framework_TestCase; | ||
|
||
class QueueTest extends PHPUnit_Framework_TestCase | ||
{ | ||
/** | ||
* @var Queue | ||
*/ | ||
private $queue; | ||
/** | ||
* @var Mock|Connection | ||
*/ | ||
private $connection; | ||
/** | ||
* @var Mock|AMQPQueue | ||
*/ | ||
private $amqpQueue; | ||
|
||
public function setUp() | ||
{ | ||
$this->amqpQueue = Mockery::mock('AMQPQueue', [ | ||
'declareQueue' => null, | ||
'setName' => null, | ||
'setFlags' => null, | ||
]); | ||
|
||
$this->connection = Mockery::mock('Radish\Broker\Connection', [ | ||
'createQueue' => $this->amqpQueue, | ||
]); | ||
|
||
$this->queue = new Queue($this->connection, 'test_queue', true, []); | ||
} | ||
|
||
public function testDeclareQueueSetsMaxPriorityArgOnAmqpQueue() | ||
{ | ||
$this->queue->setMaxPriority(100); | ||
|
||
$this->amqpQueue->shouldReceive('setArgument') | ||
->with('x-max-priority', 100) | ||
->once(); | ||
|
||
$this->queue->declareQueue(); | ||
} | ||
|
||
public function testDeclareQueueDoesntSetMaxPriorityOnAmqpWhenNull() | ||
{ | ||
$this->queue->setMaxPriority(null); | ||
|
||
$this->amqpQueue->shouldReceive('setArgument') | ||
->never(); | ||
|
||
$this->queue->declareQueue(); | ||
} | ||
} |