1
0
mirror of https://github.com/Seldaek/monolog.git synced 2025-08-12 08:04:02 +02:00

Do away with this horrible mock class

This commit is contained in:
Jordi Boggiano
2013-12-26 14:24:17 +01:00
parent b265bbd70d
commit e92cb54c24
2 changed files with 13 additions and 45 deletions

View File

@@ -32,7 +32,19 @@ class AmqpHandlerTest extends TestCase
public function testHandle()
{
$exchange = $this->getExchange();
$messages = array();
$exchange = $this->getMock('AMQPExchange', array('publish', 'setName'), array(), '', false);
$exchange->expects($this->once())
->method('setName')
->with('log')
;
$exchange->expects($this->any())
->method('publish')
->will($this->returnCallback(function ($message, $routing_key, $flags = 0, $attributes = array()) use (&$messages) {
$messages[] = array($message, $routing_key, $flags, $attributes);
}))
;
$handler = new AmqpHandler($exchange, 'log');
@@ -60,15 +72,9 @@ class AmqpHandlerTest extends TestCase
$handler->handle($record);
$messages = $exchange->getMessages();
$this->assertCount(1, $messages);
$messages[0][0] = json_decode($messages[0][0], true);
unset($messages[0][0]['datetime']);
$this->assertEquals($expected, $messages[0]);
}
protected function getExchange()
{
return new AmqpExchangeMock();
}
}