Commit 3291ad63 authored by dbourdere's avatar dbourdere 🤠

add test

parent 2a275ffb
<?php
/**
* Created by PhpStorm.
* User: henri
* Date: 7/27/18
* Time: 9:35 AM
*/
namespace Test;
use Aboutgoods\RabbitMQ\Client;
class ClientTest extends TestCase
{
public function testSend()
{
$client = new Client(null, null, null, null);
$client->setConnection($this->MockAMQPLib());
$response = $client->connectToChannel("a", true, true, false, true);
$sent = $client->send("test");
$this->assertTrue($sent);
$this->assertCount(3, $response);
}
}
\ No newline at end of file
<?php
namespace Test;
use PhpAmqpLib\Channel\AMQPChannel;
use PhpAmqpLib\Connection\AMQPStreamConnection;
class TestCase extends \PHPUnit\Framework\TestCase
{
protected function MockAMQPLib()
{
$channel = $this->getMockBuilder(AMQPChannel::class)
->disableOriginalConstructor()
->setMethods(["close", "basic_publish", "queue_declare"])
->getMock()
;
$connector = $this->getMockBuilder(AMQPStreamConnection::class)
->disableOriginalConstructor()
->setMethods(["channel", "close"])
->getMock()
;
$channel->method("basic_publish")->willReturn(null);
$channel->method("close")->willReturn(true);
$channel->method("queue_declare")->willReturn(["queue", 30, 0]);
$connector->method("close")->willReturn(true);
$connector->method("channel")->willReturn($channel);
return $connector;
}
}
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment