Changeset 1771
- Timestamp:
- 08/06/08 13:07:25 (4 months ago)
- Files:
-
- labs/incubator/src/main/php/net/stubbles/lang/mop/stubMetaClass.php (modified) (3 diffs)
- labs/incubator/src/test/php/net/stubbles/lang/LangTestSuite.php (modified) (1 diff)
- labs/incubator/src/test/php/net/stubbles/lang/mop/stubMetaClassTestCase.php (added)
- labs/incubator/src/test/php/net/stubbles/lang/mop/stubMetaObjectTestCase.php (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
labs/incubator/src/main/php/net/stubbles/lang/mop/stubMetaClass.php
r1770 r1771 13 13 ); 14 14 /** 15 * Meta Object15 * Meta Class 16 16 * 17 * @package stubbles _lang17 * @package stubbles 18 18 * @subpackage mop 19 19 */ … … 23 23 * register of specific meta methods name signature 24 24 * 25 * @var array <string>25 * @var array <string> 26 26 */ 27 27 protected $metaMethods = array(); 28 28 29 29 /** 30 * re turn only the specific supported meta methods30 * register of specific meta property names 31 31 * 32 * @return array 32 * @var array <string> 33 */ 34 protected $metaProperties = array(); 35 36 /** 37 * obtain a list of all meta properties available on this meta class 38 * 39 * @return array <string> 40 */ 41 public function getProperties() 42 { 43 if (empty($this->metaProperties)) { 44 foreach ($this->getClass()->getProperties() as $reflectionProperty) { 45 if ($reflectionProperty->isPublic() === true) { 46 $this->metaProperties[] = $reflectionProperty->getName(); 47 } 48 } 49 } 50 51 return $this->metaProperties; 52 } 53 54 /** 55 * return only the specific supported meta methods names 56 * 57 * @return array <string> 33 58 */ 34 59 public function getMethods() 35 60 { 61 if (empty($this->metaMethods)) { 62 foreach ($this->getClass()->getMethods() as $reflectionMethod) { 63 if ($reflectionMethod->isPublic() === true) { 64 $this->metaMethods[] = $reflectionMethod->getName(); 65 } 66 } 67 } 68 36 69 return $this->metaMethods; 37 70 } … … 71 104 throw new stubMethodNotSupportedException( 72 105 sprintf( 73 ' Notsupported meta class method: %s on: %s'106 'Invoke unsupported meta class method: %s on: %s' 74 107 , $method 75 , $receiver->getClass ()->getName()108 , $receiver->getClassName() 76 109 ) 77 110 ); 78 111 } 79 112 } 80 81 113 ?> labs/incubator/src/test/php/net/stubbles/lang/LangTestSuite.php
r1770 r1771 35 35 36 36 // lang::mop 37 $suite->addTestFile($dir . '/mop/stubMetaClassTestCase.php'); 37 38 $suite->addTestFile($dir . '/mop/stubMetaObjectTestCase.php'); 38 39 labs/incubator/src/test/php/net/stubbles/lang/mop/stubMetaObjectTestCase.php
r1770 r1771 41 41 { 42 42 $this->assertEquals('stubMetaClass', $this->stubMetaObject->getMetaClass()->getClass()->getName()); 43 $this->assertEquals('net::stubbles::lang::mop::stubMetaClass', $this->stubMetaObject->getMetaClass()->getClassName()); 43 44 } 44 45 … … 53 54 $this->stubMetaObject->unknownMethod(); 54 55 } 56 57 /** 58 * test if can change the meta class instance for meta object 59 * 60 * @test 61 */ 62 public function canChangeMetaClassInstance() 63 { 64 $mock = $this->getMock('stubMetaClass'); 65 $meta = $this->stubMetaObject->getMetaClass(); 66 67 $this->assertNotEquals($meta, $this->stubMetaObject->setMetaClass($mock)->getMetaClass()); 68 $this->assertEquals($mock, $this->stubMetaObject->getMetaClass()); 69 } 55 70 } 56 71 ?>
