Example #1
0
 public function testMultipleStackedForms()
 {
     $parserContext = $this->getParserContext();
     $this->assertNull($parserContext->popCurrentForm());
     // First form:
     // eq: {form name="thelia.empty"}
     $repeat = true;
     $this->plugin->generateForm(["name" => "thelia.empty"], "", $this->getMock("\\Smarty_Internal_Template", [], [], '', false), $repeat);
     $this->assertInstanceOf("Thelia\\Form\\EmptyForm", $parserContext->getCurrentForm());
     // Then next one:
     // eq: {form name="thelia.api.empty"}
     $repeat = true;
     $this->plugin->generateForm(["name" => "thelia.api.empty"], "", $this->getMock("\\Smarty_Internal_Template", [], [], '', false), $repeat);
     $this->assertInstanceOf("Thelia\\Form\\Api\\ApiEmptyForm", $parserContext->getCurrentForm());
     // Third form:
     // eq: {form name="thelia.empty.2"}
     $repeat = true;
     $this->plugin->generateForm(["name" => "thelia.empty.2"], "", $this->getMock("\\Smarty_Internal_Template", [], [], '', false), $repeat);
     $this->assertInstanceOf("Thelia\\Form\\EmptyForm", $parserContext->getCurrentForm());
     // Then, Let's close forms
     // eq: {/form} {* related to {form name="thelia.empty.2"} *}
     $repeat = false;
     $this->plugin->generateForm(["name" => "thelia.empty.2"], "", $this->getMock("\\Smarty_Internal_Template", [], [], '', false), $repeat);
     $this->assertInstanceOf("Thelia\\Form\\Api\\ApiEmptyForm", $parserContext->getCurrentForm());
     // Then, Let's close forms
     // eq: {/form} {* related to {form name="thelia.api.empty"} *}
     $repeat = false;
     $this->plugin->generateForm(["name" => "thelia.api.empty"], "", $this->getMock("\\Smarty_Internal_Template", [], [], '', false), $repeat);
     $this->assertInstanceOf("Thelia\\Form\\EmptyForm", $parserContext->getCurrentForm());
     // Then close the first form:
     // eq: {/form} {* related to {form name="thelia.empty"} *}
     $repeat = false;
     $this->plugin->generateForm(["name" => "thelia.empty"], "", $this->getMock("\\Smarty_Internal_Template", [], [], '', false), $repeat);
     // The exception
     $this->setExpectedException("TheliaSmarty\\Template\\Exception\\SmartyPluginException", "There is currently no defined form");
     $parserContext->getCurrentForm();
 }