SyslogTest.php 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. <?php
  2. /**
  3. * Lithium: the most rad php framework
  4. *
  5. * @copyright Copyright 2013, Union of RAD (http://union-of-rad.org)
  6. * @license http://opensource.org/licenses/bsd-license.php The BSD License
  7. */
  8. namespace lithium\tests\cases\analysis\logger\adapter;
  9. use lithium\analysis\Logger;
  10. use lithium\analysis\logger\adapter\Syslog;
  11. /**
  12. * Syslog adapter test.
  13. */
  14. class SyslogTest extends \lithium\test\Unit {
  15. public function setUp() {
  16. $this->syslog = new Syslog();
  17. Logger::config(array('syslog' => array('adapter' => $this->syslog)));
  18. }
  19. public function testConfiguration() {
  20. $loggers = Logger::config();
  21. $result = isset($loggers['syslog']);
  22. $this->assertTrue($result);
  23. }
  24. public function testConstruct() {
  25. $expected = array(
  26. 'identity' => false,
  27. 'options' => LOG_ODELAY,
  28. 'facility' => LOG_USER,
  29. 'init' => true
  30. );
  31. $result = $this->syslog->_config;
  32. $this->assertEqual($expected, $result);
  33. $syslog = new Syslog(array(
  34. 'identity' => 'SyslogTest',
  35. 'priority' => LOG_DEBUG
  36. ));
  37. $expected = array(
  38. 'identity' => 'SyslogTest',
  39. 'options' => LOG_ODELAY,
  40. 'facility' => LOG_USER,
  41. 'priority' => LOG_DEBUG,
  42. 'init' => true
  43. );
  44. $result = $syslog->_config;
  45. $this->assertEqual($expected, $result);
  46. }
  47. public function testWrite() {
  48. $result = Logger::write('info', 'SyslogTest message...', array('name' => 'syslog'));
  49. $this->assertTrue($result);
  50. }
  51. }
  52. ?>