2
0

OutputFrontendTest.php 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  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_Cache
  17. * @subpackage UnitTests
  18. * @copyright Copyright (c) 2005-2010 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. /**
  23. * Zend_Cache
  24. */
  25. require_once 'Zend/Cache.php';
  26. require_once 'Zend/Cache/Frontend/Output.php';
  27. require_once 'Zend/Cache/Backend/Test.php';
  28. /**
  29. * PHPUnit test case
  30. */
  31. require_once 'PHPUnit/Framework/TestCase.php';
  32. /**
  33. * @category Zend
  34. * @package Zend_Cache
  35. * @subpackage UnitTests
  36. * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
  37. * @license http://framework.zend.com/license/new-bsd New BSD License
  38. * @group Zend_Cache
  39. */
  40. class Zend_Cache_OutputFrontendTest extends PHPUnit_Framework_TestCase {
  41. private $_instance;
  42. public function setUp()
  43. {
  44. if (!$this->_instance) {
  45. $this->_instance = new Zend_Cache_Frontend_Output(array());
  46. $this->_backend = new Zend_Cache_Backend_Test();
  47. $this->_instance->setBackend($this->_backend);
  48. }
  49. }
  50. public function tearDown()
  51. {
  52. unset($this->_instance);
  53. }
  54. public function testConstructorCorrectCall()
  55. {
  56. $test = new Zend_Cache_Frontend_Output(array('lifetime' => 3600, 'caching' => true));
  57. }
  58. public function testStartEndCorrectCall1()
  59. {
  60. ob_start();
  61. ob_implicit_flush(false);
  62. if (!($this->_instance->start('123'))) {
  63. echo('foobar');
  64. $this->_instance->end();
  65. }
  66. $data = ob_get_contents();
  67. ob_end_clean();
  68. ob_implicit_flush(true);
  69. $this->assertEquals('foo', $data);
  70. }
  71. public function testStartEndCorrectCall2()
  72. {
  73. ob_start();
  74. ob_implicit_flush(false);
  75. if (!($this->_instance->start('false'))) {
  76. echo('foobar');
  77. $this->_instance->end();
  78. }
  79. $data = ob_get_contents();
  80. ob_end_clean();
  81. ob_implicit_flush(true);
  82. $this->assertEquals('foobar', $data);
  83. }
  84. }