function testAddNodeDontChangeCursor() { $this->assertEqual($this->component->getChildren(), array()); $this->assertReference($this->component, $this->tree_builder->getCursor()); $child_component = new MockWactCompileTreeNode(); $child_component->expectOnce('preParse'); $this->tree_builder->addNode($child_component); $this->assertReference($this->component, $this->tree_builder->getCursor()); $children = $this->component->getChildren(); $this->assertReference($children[0], $child_component); }
function _createNode() { $this->tag_info = new WactTagInfo('test', 'WactRuntimeComponentHTMLTagTestVersion'); $component = new WactRuntimeComponentHTMLTagTestVersion($this->source_location, 'test', $this->tag_info); $component->setServerId('id001'); $component->hasClosingTag = TRUE; $MockParent = new MockWactCompileTreeNode(); $MockParent->setReturnValue('getComponentRefCode', '$root'); $MockParent->parent = null; $component->parent = $MockParent; return $component; }
function testGenerateConstructor() { $this->component->runtimeIncludeFile = 'testinclude.inc.php'; $this->component->runtimeComponentName = 'testname'; $MockCode = new WactCodeWriterTestVersion(); $MockCode->expectOnce('registerInclude', array('testinclude.inc.php')); $MockCode->setReturnValue('getTempVariable', 'AA'); $MockParent = new MockWactCompileTreeNode(); $MockParent->setReturnValue('getComponentRefCode', '$DataSpace'); $this->component->parent = $MockParent; $this->component->generateConstructor($MockCode); $this->assertEqual($MockCode->renderCode(), '<?php $AA = new testname(\'id001\');' . "\n" . '$components[\'AA\'] = $AA;' . "\n" . '$DataSpace->addChild($AA);' . "\n" . ' ?>'); }
function testGenerateFullCicleForPathDBE() { $code_writer = new WactCodeWriter(); $root = new WactCompileTreeRootNode(); $context = new MockWactCompileTreeNode(); $context->setReturnReference('getDataSource', $root); $DBE = new WactDataBindingExpressionNode('Test.item1.item2', $context); $DBE->generatePreStatement($code_writer); $DBE->generateExpression($code_writer); $DBE->generatePostStatement($code_writer); $this->assertEqual($code_writer->getCode(), '<?php $A= WactTemplate::getValue($root->datasource,\'Test\');' . '$B= WactTemplate::getValue($A,\'item1\');' . 'WactTemplate::getValue($B,\'item2\')'); }
function testGenerate() { $code_writer = new MockWactCodeWriter(); $child = new MockWactCompileTreeNode(); $child->expectCallCount('generate', 1); $this->component->addChild($child); $this->component->generate($code_writer); }