[ Index ]

PHP Cross Reference of Limb3

title

Body

[close]

/wact/tests/cases/compiler/tag_node/ -> WactRuntimeComponentTagTest.class.php (source)

   1  <?php
   2  /*
   3   * Limb PHP Framework
   4   *
   5   * @link http://limb-project.com 
   6   * @copyright  Copyright &copy; 2004-2007 BIT(http://bit-creative.com)
   7   * @license    LGPL http://www.gnu.org/copyleft/lesser.html 
   8   */
   9  
  10  require_once('limb/wact/tests/cases/compiler/tag_node/WactCompilerTagTest.class.php');
  11  
  12  class WactRuntimeComponentTagTestVersion extends WactRuntimeComponentTag
  13  {
  14    public $runtimeIncludeFile = 'testinclude.inc.php';
  15    public $runtimeComponentName = 'testcomponent';
  16  }
  17  
  18  Mock :: generatePartial('WactCodeWriter', 'WactCodeWriterTestVersion', array('getTempVariable',
  19                                                                               'registerInclude'));
  20  
  21  class WactRuntimeComponentTagTest extends WactCompilerTagTest
  22  {
  23    function _createNode()
  24    {
  25      $component =  new WactRuntimeComponentTagTestVersion($this->source_location, 'test', $this->tag_info);
  26      $component->setServerId('id001');
  27      return $component;
  28    }
  29  
  30    function testGetServerId()
  31    {
  32      $this->assertEqual($this->component->getServerId(),'id001');
  33    }
  34  
  35    function testGetServerIdAttribute()
  36    {
  37      $this->assertEqual($this->component->getServerId(),'id001');
  38    }
  39  
  40    function testGetComponentRefCode()
  41    {
  42      $Mock = new MockWactCompileTreeNode();
  43      $Mock->setReturnValue('getComponentRefCode','$DataSpace');
  44      $this->component->parent = $Mock;
  45  
  46      $code_writer = new WactCodeWriterTestVersion();
  47      $code_writer->setReturnValue('getTempVariable', 'AA');
  48  
  49      $this->component->generateUniqueId($code_writer);
  50  
  51      $this->assertEqual($this->component->getComponentRefCode(),'$components[\'AA\']');
  52    }
  53  
  54    function testGetServerIdFromId()
  55    {
  56      $this->assertEqual($this->component->getServerId(), 'id001');
  57    }
  58  
  59    function testGetServerIdFromWactId()
  60    {
  61      $this->assertEqual($this->component->getServerId(), 'id001');
  62    }
  63  
  64    function testGenerateConstructor()
  65    {
  66      $this->component->runtimeIncludeFile = 'testinclude.inc.php';
  67      $this->component->runtimeComponentName = 'testname';
  68  
  69      $MockCode = new WactCodeWriterTestVersion();
  70      $MockCode->expectOnce('registerInclude', array('testinclude.inc.php'));
  71      $MockCode->setReturnValue('getTempVariable', 'AA');
  72  
  73      $MockParent = new MockWactCompileTreeNode();
  74      $MockParent->setReturnValue('getComponentRefCode','$DataSpace');
  75  
  76      $this->component->parent = $MockParent;
  77      $this->component->generateConstructor($MockCode);
  78  
  79      $this->assertEqual($MockCode->renderCode(),
  80                         '<?php $AA = new testname(\'id001\');'. "\n" .
  81                         '$components[\'AA\'] = $AA;'. "\n" .
  82                         '$DataSpace->addChild($AA);'. "\n" . ' ?>');
  83    }
  84  }
  85  
  86  ?>


Generated: Thu Jan 8 04:06:23 2009 Cross-referenced by PHPXref 0.7