public function testEchoConstruct()
 {
     $type = new ezcTemplateLiteralAstNode("text");
     $outputList = array($type);
     $construct = new ezcTemplateEchoAstNode($outputList);
     self::assertSame($outputList, $construct->getOutputList());
     try {
         $construct->validate();
     } catch (Exception $e) {
         self::fail("Echo construct with output parameters should not fail validation.");
     }
     $construct = new ezcTemplateEchoAstNode();
     $construct->appendOutput($type);
     self::assertSame($outputList, $construct->getOutputList());
     try {
         $construct->validate();
     } catch (Exception $e) {
         self::fail("Echo construct with appended output parameter should not fail validation.");
     }
     $construct = new ezcTemplateEchoAstNode();
     $failed = false;
     try {
         $construct->validate();
         $failed = true;
     } catch (Exception $e) {
     }
     if ($failed) {
         self::fail("Echo construct without output parameters should fail validation.");
     }
 }
示例#2
0
 /**
  * Visits a code element containing echo construct.
  *
  * @param ezcTemplateEchoAstNode $echo The code element containing the echo construct.
  * @return void
  */
 public function visitEchoAstNode(ezcTemplateEchoAstNode $echo)
 {
     $outputList = $echo->getOutputList();
     $this->write("echo ");
     foreach ($outputList as $i => $output) {
         if ($i > 0) {
             $this->write(",");
         }
         $output->accept($this);
     }
     $this->write(";\n");
 }