1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22: 23: 24: 25: 26: 27: 28: 29: 30: 31: 32: 33: 34: 35: 36: 37: 38: 39: 40: 41: 42: 43: 44: 45: 46: 47: 48: 49: 50: 51: 52: 53: 54: 55: 56: 57: 58: 59: 60: 61: 62: 63: 64: 65: 66: 67: 68: 69: 70: 71:
<?php
namespace Nethgui\Test\Unit\Nethgui\Log;
class SyslogTest extends \PHPUnit_Framework_TestCase
{
protected $object;
protected $php;
protected function setUp()
{
$this->php = $this->getMock('Nethgui\Utility\PhpWrapper', array('syslog'));
$this->object = new \Nethgui\Log\Syslog();
$this->object->setPhpWrapper($this->php);
}
public function testMessage()
{
$this->php->expects($this->at(0))
->method('syslog')
->with(LOG_NOTICE, $this->logicalAnd($this->stringContains('NOTICE'), $this->stringContains('HelloWorld')))
->will($this->returnValue($this->object));
$this->php->expects($this->at(1))
->method('syslog')
->with(LOG_WARNING, $this->logicalAnd($this->stringContains('WARNING'), $this->stringContains('WarningWorld')))
->will($this->returnValue($this->object));
$this->php->expects($this->at(2))
->method('syslog')
->with(LOG_ERR, $this->logicalAnd($this->stringContains('ERROR'), $this->stringContains('ErrorWorld')))
->will($this->returnValue($this->object));
$this->php->expects($this->at(3))
->method('syslog')
->with(LOG_ERR, $this->logicalAnd($this->stringContains('EXCEPTION'), $this->stringContains('Failure1')))
->will($this->returnValue($this->object));
$this->php->expects($this->at(4))
->method('syslog')
->with(LOG_ERR, $this->logicalAnd($this->stringContains('EXCEPTION'), $this->stringContains('Failure2')))
->will($this->returnValue($this->object));
$r = $this->object->notice('HelloWorld');
$this->assertSame($this->object, $r);
$r = $this->object->warning('WarningWorld');
$this->assertSame($this->object, $r);
$r = $this->object->error('ErrorWorld');
$this->assertSame($this->object, $r);
$r = $this->object->exception(new \Exception('Failure1', 1234), FALSE);
$this->assertSame($this->object, $r);
$r = $this->object->exception(new \Exception('Failure2', 1234), TRUE);
$this->assertSame($this->object, $r);
}
}