Skip to content

Commit

Permalink
tests cleanup
Browse files Browse the repository at this point in the history
AMQPCollectionTest cleanup

AMQPDecimalTest cleanup

separating concerns in Protocol091Test

separating concerns in Protocol091Test

Protocol091Test cleanup

AMQPMessageTest cleanup

AMQPWriterTest cleanup

WireTest cleanup

Functional tests cleanup

ChannelTest cleanup

AMQPChannelTest is removed -- no assertions

data providers cleanup

MiscHelperTest cleanup

AMQPCollectionTest cleanup

exceptions are handled through annotations

WireTest cleanup

data providers are used in WireTest

data providers cleanup

MiscHelperTest cleanup

ordering methods according to boilerplate

the splat operator is removed for travis to pass the tests -- PHP 5.4 and PHP 5.5

T_IS_EQUAL is removed for travis to pass PHP 5.4 and 5.5

SocketIOTest cleanup

SocketIOTest cleanup -- error messages disabled in connect_with_invalid_credentials

fail is removed from tests expecting exceptions to be thrown

array is replaced with square brackets

Channel tests refactored
  • Loading branch information
programarivm authored and lukebakken committed Oct 8, 2018
1 parent b3bb388 commit c01c7d5
Show file tree
Hide file tree
Showing 21 changed files with 1,799 additions and 1,363 deletions.
134 changes: 0 additions & 134 deletions tests/Functional/AbstractPublishConsumeTest.php

This file was deleted.

@@ -1,6 +1,6 @@
<?php

namespace PhpAmqpLib\Tests\Functional;
namespace PhpAmqpLib\Tests\Functional\Bug;

use PhpAmqpLib\Channel\AMQPChannel;
use PhpAmqpLib\Connection\AMQPConnection;
Expand All @@ -12,44 +12,20 @@

class Bug256Test extends TestCase
{
/**
* @var string
*/
protected $exchangeName = 'test_exchange';

/**
* @var string
*/
protected $queueName = null;

/**
* @var int
*/
protected $messageCount = 100;

/**
* @var int
*/
protected $consumedCount = 0;

/**
* @var AMQPConnection
*/
protected $connection;

/**
* @var AMQPConnection
*/
protected $connection2;

/**
* @var AMQPChannel
*/
protected $channel;

/**
* @var AMQPChannel
*/
protected $channel2;

public function setUp()
Expand All @@ -66,10 +42,30 @@ public function setUp()
$this->channel2->queue_bind($this->queueName, $this->exchangeName, $this->queueName);
}

public function testFrameOrder()
public function tearDown()
{
if ($this->channel) {
$this->channel->exchange_delete($this->exchangeName);
$this->channel->close();
}
if ($this->connection) {
$this->connection->close();
}
if ($this->channel2) {
$this->channel2->close();
}
if ($this->connection2) {
$this->connection2->close();
}
}

/**
* @test
*/
public function frame_order()
{
$msg = new AMQPMessage('');
$hdrs = new AMQPTable(array('x-foo' => 'bar'));
$hdrs = new AMQPTable(['x-foo' => 'bar']);
$msg->set('application_headers', $hdrs);

for ($i = 0; $i < $this->messageCount; $i++) {
Expand All @@ -83,7 +79,7 @@ public function testFrameOrder()
true,
false,
false,
array($this, 'processMessage')
[$this, 'processMessage']
);

while (count($this->channel2->callbacks)) {
Expand All @@ -95,31 +91,11 @@ public function processMessage(AMQPMessage $message)
{
$this->consumedCount++;

$this->assertEquals(array('x-foo' => 'bar'), $message->get('application_headers')->getNativeData());
$this->assertEquals(['x-foo' => 'bar'], $message->get('application_headers')->getNativeData());

if ($this->consumedCount >= $this->messageCount) {
$delivery_info = $message->delivery_info;
$delivery_info['channel']->basic_cancel($delivery_info['consumer_tag']);
}
}

public function tearDown()
{
if ($this->channel) {
$this->channel->exchange_delete($this->exchangeName);
$this->channel->close();
}

if ($this->connection) {
$this->connection->close();
}

if ($this->channel2) {
$this->channel2->close();
}

if ($this->connection2) {
$this->connection2->close();
}
}
}
@@ -1,6 +1,6 @@
<?php

namespace PhpAmqpLib\Tests\Functional;
namespace PhpAmqpLib\Tests\Functional\Bug;

use PhpAmqpLib\Channel\AMQPChannel;
use PhpAmqpLib\Connection\AMQPConnection;
Expand All @@ -9,39 +9,18 @@

class Bug40Test extends TestCase
{
/**
* @var string
*/
protected $exchangeName = 'test_exchange';

/**
* @var string
*/
protected $queueName1 = null;

/**
* @var string
*/
protected $queueName2 = null;

/**
* @var int
*/
protected $queue1Messages = 0;

/**
* @var AMQPConnection
*/
protected $connection;

/**
* @var AMQPChannel
*/
protected $channel;

/**
* @var AMQPChannel
*/
protected $channel2;

public function setUp()
Expand All @@ -57,7 +36,21 @@ public function setUp()
$this->channel->queue_bind($this->queueName2, $this->exchangeName, $this->queueName2);
}

public function testFrameOrder()
public function tearDown()
{
if ($this->channel) {
$this->channel->exchange_delete($this->exchangeName);
$this->channel->close();
}
if ($this->connection) {
$this->connection->close();
}
}

/**
* @test
*/
public function frame_order()
{
$msg = new AMQPMessage('test message');
$this->channel->basic_publish($msg, $this->exchangeName, $this->queueName1);
Expand All @@ -71,7 +64,7 @@ public function testFrameOrder()
true,
false,
false,
array($this, 'processMessage1')
[$this, 'processMessage1']
);

while (count($this->channel->callbacks)) {
Expand All @@ -92,7 +85,7 @@ public function processMessage1($msg)
true,
false,
false,
array($this, 'processMessage2')
[$this, 'processMessage2']
);
}

Expand All @@ -103,24 +96,11 @@ public function processMessage1($msg)
if ($this->queue1Messages == 2) {
$delivery_info['channel']->basic_cancel($delivery_info['consumer_tag']);
}

}

public function processMessage2($msg)
{
$delivery_info = $msg->delivery_info;
$delivery_info['channel']->basic_cancel($delivery_info['consumer_tag']);
}

public function tearDown()
{
if ($this->channel) {
$this->channel->exchange_delete($this->exchangeName);
$this->channel->close();
}

if ($this->connection) {
$this->connection->close();
}
}
}

0 comments on commit c01c7d5

Please sign in to comment.