OutputFrontendTest.php 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. <?php
  2. /**
  3. * @package Zend_Cache
  4. * @subpackage UnitTests
  5. */
  6. /**
  7. * Zend_Cache
  8. */
  9. require_once 'Zend/Cache.php';
  10. require_once 'Zend/Cache/Frontend/Output.php';
  11. require_once 'Zend/Cache/Backend/Test.php';
  12. /**
  13. * PHPUnit test case
  14. */
  15. require_once 'PHPUnit/Framework/TestCase.php';
  16. /**
  17. * @package Zend_Cache
  18. * @subpackage UnitTests
  19. */
  20. class Zend_Cache_OutputFrontendTest extends PHPUnit_Framework_TestCase {
  21. private $_instance;
  22. public function setUp()
  23. {
  24. if (!$this->_instance) {
  25. $this->_instance = new Zend_Cache_Frontend_Output(array());
  26. $this->_backend = new Zend_Cache_Backend_Test();
  27. $this->_instance->setBackend($this->_backend);
  28. }
  29. }
  30. public function tearDown()
  31. {
  32. unset($this->_instance);
  33. }
  34. public function testConstructorCorrectCall()
  35. {
  36. $test = new Zend_Cache_Frontend_Output(array('lifetime' => 3600, 'caching' => true));
  37. }
  38. public function testStartEndCorrectCall1()
  39. {
  40. ob_start();
  41. ob_implicit_flush(false);
  42. if (!($this->_instance->start('123'))) {
  43. echo('foobar');
  44. $this->_instance->end();
  45. }
  46. $data = ob_get_contents();
  47. ob_end_clean();
  48. ob_implicit_flush(true);
  49. $this->assertEquals('foo', $data);
  50. }
  51. public function testStartEndCorrectCall2()
  52. {
  53. ob_start();
  54. ob_implicit_flush(false);
  55. if (!($this->_instance->start('false'))) {
  56. echo('foobar');
  57. $this->_instance->end();
  58. }
  59. $data = ob_get_contents();
  60. ob_end_clean();
  61. ob_implicit_flush(true);
  62. $this->assertEquals('foobar', $data);
  63. }
  64. }