ZendmonitorTest.php 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. <?php
  2. /**
  3. * Zend Framework
  4. *
  5. * LICENSE
  6. *
  7. * This source file is subject to the new BSD license that is bundled
  8. * with this package in the file LICENSE.txt.
  9. * It is also available through the world-wide-web at this URL:
  10. * http://framework.zend.com/license/new-bsd
  11. * If you did not receive a copy of the license and are unable to
  12. * obtain it through the world-wide-web, please send an email
  13. * to license@zend.com so we can send you a copy immediately.
  14. *
  15. * @category Zend
  16. * @package Zend_Application
  17. * @subpackage UnitTests
  18. * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
  19. * @license http://framework.zend.com/license/new-bsd New BSD License
  20. * @version $Id$
  21. */
  22. require_once dirname(__FILE__) . '/../../../TestHelper.php';
  23. /** Zend_Application_Resource_Resource */
  24. require_once 'Zend/Application/Resource/Resource.php';
  25. /** Zend_Application_Resource_ResourceAbstract */
  26. require_once 'Zend/Application/Resource/ResourceAbstract.php';
  27. /** Zend_Application_Resource_Zendmonitor */
  28. require_once 'Zend/Application/Resource/Zendmonitor.php';
  29. /** Zend_Log */
  30. require_once 'Zend/Log.php';
  31. /** Zend_Log_Writer_ZendMonitor */
  32. require_once 'Zend/Log/Writer/ZendMonitor.php';
  33. /** Zend_Log_Writer_Mock */
  34. require_once 'Zend/Log/Writer/Mock.php';
  35. /**
  36. * @category Zend
  37. * @package Zend_Application
  38. * @subpackage UnitTests
  39. * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
  40. * @license http://framework.zend.com/license/new-bsd New BSD License
  41. * @group Zend_Application_Resource
  42. */
  43. class Zend_Application_Resource_ZendmonitorTest extends PHPUnit_Framework_TestCase
  44. {
  45. public function setUp()
  46. {
  47. $this->resource = new Zend_Application_Resource_Zendmonitor();
  48. }
  49. public function testGetLogLazyLoadsLog()
  50. {
  51. $log = $this->resource->getLog();
  52. $this->assertTrue($log instanceof Zend_Log);
  53. }
  54. public function testInitReturnsLogInstance()
  55. {
  56. $log = $this->resource->init();
  57. $this->assertTrue($log instanceof Zend_Log);
  58. }
  59. public function testInitReturnsSameLogInstanceAsGetter()
  60. {
  61. $log = $this->resource->getLog();
  62. $this->assertSame($log, $this->resource->init());
  63. }
  64. public function testSetterWillOverwriteExistingLogInstance()
  65. {
  66. $existing = $this->resource->getLog();
  67. $this->resource->setLog($log = new Zend_Log(new Zend_Log_Writer_Mock()));
  68. $this->assertNotSame($existing, $this->resource->getLog());
  69. $this->assertSame($log, $this->resource->getLog());
  70. }
  71. }