[ Index ]

PHP Cross Reference of Limb3

title

Body

[close]

/core/tests/cases/ -> lmbDecoratorTest.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  lmb_require('limb/core/src/lmbDecorator.class.php');
  10  
  11  interface DecoratorTestInterface
  12  {
  13    function set($value);
  14    function get();
  15    function typehint(DecoratorTestStub $value);
  16  }
  17  
  18  class DecoratorTestStub implements DecoratorTestInterface
  19  {
  20    var $value;
  21  
  22    function set($value)
  23    {
  24      $this->value = $value;
  25    }
  26  
  27    function get()
  28    {
  29      return $this->value;
  30    }
  31  
  32    function typehint(DecoratorTestStub $value){}
  33  }
  34  
  35  lmbDecorator :: generate('DecoratorTestStub', 'DecoratorTestStubDecorator');
  36  
  37  class lmbDecoratorTest extends UnitTestCase
  38  {
  39    function testDoubleDeclaration()
  40    {
  41      lmbDecorator :: generate('DecoratorTestStub', 'DecoratorTestStubDecorator');
  42      lmbDecorator :: generate('DecoratorTestStub', 'DecoratorTestStubDecorator');
  43    }
  44  
  45    function testImplementsInterface()
  46    {
  47      $refl = new ReflectionClass('DecoratorTestStubDecorator');
  48      $this->assertTrue($refl->implementsInterface('DecoratorTestInterface'));
  49    }
  50  
  51    function testHasMethods()
  52    {
  53      $decorator = new DecoratorTestStubDecorator(new DecoratorTestStub());
  54  
  55      foreach(get_class_methods('DecoratorTestStub') as $method)
  56        $this->assertTrue(method_exists($decorator, $method));
  57    }
  58  
  59    function testMethodArgumentsTypehinting()
  60    {
  61      $refl = new ReflectionClass('DecoratorTestStubDecorator');
  62      $params = $refl->getMethod('typehint')->getParameters();
  63      $this->assertEqual(sizeof($params), 1);
  64      $this->assertEqual($params[0]->getClass()->getName(), 'DecoratorTestStub');
  65    }
  66  
  67    function testCallsPassedToDecorated()
  68    {
  69      $decorator = new DecoratorTestStubDecorator(new DecoratorTestStub());
  70      $decorator->set('foo');
  71      $this->assertEqual($decorator->get(), 'foo');
  72    }
  73  }
  74  
  75  ?>


Generated: Sat Nov 22 03:48:54 2008 Cross-referenced by PHPXref 0.7