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 testGenerateExpressionWithContextModifierAndNoFieldName() { $context = new WactCompileTreeRootNode(); $child1 = new MockWactCompileTreeNode(); $child1->setReturnValue('isDataSource', true); $child1->setReturnValue('getServerId', 'child1'); $child1->setReturnValue('getComponentRefCode', '$components["A"]'); $context->addChild($child1); $DBE = new WactDataBindingExpressionNode('[child1]', $context); $DBE->analyzeExpression(); $this->assertFalse($DBE->isConstant()); $this->assertFalse($DBE->getFieldName()); $code_writer = new WactCodeWriter(); $DBE->generateExpression($code_writer); $this->assertEqual($code_writer->getCode(), '<?php $components["A"]'); }
function testgetComponentRefCode() { $parent = new MockWactCompileTreeNode(); $parent->setReturnValue('getComponentRefCode', 'Test'); $this->component->parent = $parent; $this->assertEqual($this->component->getComponentRefCode(), 'Test'); }