Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Adding two Opt_View tests for caching.

  • Loading branch information...
commit 7d46caf6e759009a9210e19ce817217b42a88e9f 1 parent eeb278c
@zyxist zyxist authored
Showing with 60 additions and 0 deletions.
  1. +56 −0 tests/Package/ViewTest.php
  2. +4 −0 tests/Package/templates/dummy.tpl
View
56 tests/Package/ViewTest.php
@@ -298,4 +298,60 @@ public function testNoNoticesOnUnexistingVars()
ob_end_clean();
} // end testNoNoticesOnUnexistingVars();
+ /**
+ * @covers Opt_View::setCache
+ * @covers Opt_View::getCache
+ * @covers Opt_View::_parse
+ */
+ public function testCacheRebuild()
+ {
+ $view = new Opt_View('dummy.tpl');
+
+ $mock = $this->getMock('Opt_Caching_Interface');
+ $mock->expects($this->once())
+ ->method('templateCacheStart')
+ ->with($view)
+ ->will($this->returnValue(false));
+ $mock->expects($this->once())
+ ->method('templateCacheStop')
+ ->with($view);
+
+ $view->setCache($mock);
+ $this->assertSame($mock, $view->getCache());
+
+ $output = $this->getMock('Opt_Output_Interface');
+ ob_start();
+ $view->_parse($output);
+ ob_end_clean();
+ } // end testCacheRebuild();
+
+ /**
+ * @covers Opt_View::setCache
+ * @covers Opt_View::getCache
+ * @covers Opt_View::_parse
+ */
+ public function testCacheRestore()
+ {
+ $view = new Opt_View('dummy.tpl');
+ file_put_contents('./Cache/cache.txt', 'DUPA');
+
+ $mock = $this->getMock('Opt_Caching_Interface');
+ $mock->expects($this->once())
+ ->method('templateCacheStart')
+ ->with($view)
+ ->will($this->returnValue('./Cache/cache.txt'));
+ $mock->expects($this->never())
+ ->method('templateCacheStop');
+
+ $view->setCache($mock);
+ $this->assertSame($mock, $view->getCache());
+
+ $output = $this->getMock('Opt_Output_Interface');
+ ob_start();
+ $view->_parse($output);
+ $data = ob_get_clean();
+
+ $this->assertEquals('DUPA', $data);
+ } // end testCacheRestore();
+
} // end Package_ViewTest;
View
4 tests/Package/templates/dummy.tpl
@@ -0,0 +1,4 @@
+<?xml version="1.0" ?>
+<opt:root xmlns:opt="http://xml.invenzzia.org/opt">
+DUMMY
+</opt:root>
Please sign in to comment.
Something went wrong with that request. Please try again.