コード例 #1
0
ファイル: JigConverterTest.php プロジェクト: danack/jig
 /**
  *
  */
 public function testCompileBlock()
 {
     $blockStartCallCount = 0;
     $blockEndCallCount = 0;
     $passedSegementText = null;
     $compileBlockStart = function (JigConverter $jigConverter, $segmentText) use(&$blockStartCallCount, &$passedSegementText) {
         $blockStartCallCount++;
         $jigConverter->addText("compileBlockStart");
         $jigConverter->addText($segmentText);
         $passedSegementText = $segmentText;
     };
     $compileBlockEnd = function (JigConverter $jigConverter) use(&$blockEndCallCount) {
         $blockEndCallCount++;
         $jigConverter->addText("compileBlockEnd");
     };
     $this->jigDispatcher->bindCompileBlock('compile', $compileBlockStart, $compileBlockEnd);
     $this->jigDispatcher->deleteCompiledFile('block/compileBlock');
     $contents = $this->jigDispatcher->renderTemplateFile('block/compileBlock');
     //Because the block is called when the template is compiled, and
     //as the template should only be compiled once (due to caching) each
     //block function should only be called once.
     $this->assertEquals('foo="bar"', $passedSegementText);
     $this->assertEquals($blockStartCallCount, 1);
     $this->assertEquals($blockEndCallCount, 1);
     $this->assertContains("This is in a compile time block", $contents);
     $this->assertContains("compileBlockStart", $contents);
     $this->assertContains("compileBlockEnd", $contents);
 }