Skip to content

Commit

Permalink
Merge pull request #59 from specialtactics/chore/update-testing-for-p…
Browse files Browse the repository at this point in the history
…hpunit8

Minor testing improvement
  • Loading branch information
KinaneD authored Oct 25, 2019
2 parents 1ddaa35 + 0c834e1 commit ea3911e
Show file tree
Hide file tree
Showing 2 changed files with 51 additions and 10 deletions.
44 changes: 42 additions & 2 deletions src/Connection.php
Original file line number Diff line number Diff line change
Expand Up @@ -172,9 +172,49 @@ public function fetchQueueConsumers($queueName, string $columns = 'consumer_deta
return $http->get($request)->json();
}

/**
* Clean up resources
*/
public function __destruct()
{
$this->channel->close();
$this->connection->close();
if ($this->channel) {
$this->channel->close();
}

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

/**
* @return int
*/
public function getConnectionTimeout()
{
return $this->connectionTimeout;
}

/**
* @return int
*/
public function getReadWriteTimeout()
{
return $this->readWriteTimeout;
}

/**
* @return int
*/
public function getHeartbeat()
{
return $this->heartbeat;
}

/**
* @return string
*/
public function getVhost()
{
return $this->vhost;
}
}
17 changes: 9 additions & 8 deletions tests/ConnectionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,17 +54,18 @@ public function test_set_default_configurations_values()
{
$mConnection = $this->getMockBuilder(Connection::class)
->disableOriginalConstructor()
->setMethods(null)
->getMock();

$this->app->bind(Connection::class, function () use ($mConnection) {
return $mConnection;
});
$connection = $this->app[Connection::class];

$this->assertAttributeEquals(15, 'heartbeat', $connection);
$this->assertAttributeEquals(30, 'readWriteTimeout', $connection);
$this->assertAttributeEquals(30, 'connectionTimeout', $connection);
$this->assertAttributeEquals('/', 'vhost', $connection);
$this->assertEquals(15, $connection->getHeartbeat());
$this->assertEquals(30, $connection->getReadWriteTimeout());
$this->assertEquals(30, $connection->getConnectionTimeout());
$this->assertEquals('/', $connection->getVhost());
}

public function test_set_altered_configurations_values()
Expand All @@ -88,9 +89,9 @@ public function test_set_altered_configurations_values()

$connection = $this->app[Connection::class];

$this->assertAttributeEquals(30, 'heartbeat', $connection);
$this->assertAttributeEquals(60, 'readWriteTimeout', $connection);
$this->assertAttributeEquals(60, 'connectionTimeout', $connection);
$this->assertAttributeEquals('/test-vhost', 'vhost', $connection);
$this->assertEquals(30, $connection->getHeartbeat());
$this->assertEquals(60, $connection->getReadWriteTimeout());
$this->assertEquals(60, $connection->getConnectionTimeout());
$this->assertEquals('/test-vhost', $connection->getVhost());
}
}

0 comments on commit ea3911e

Please sign in to comment.