예제 #1
0
 public function testPropertiesMethods()
 {
     $properties = array($prop1 = new Property('prop1'), $prop2 = new Property('prop2'), $prop3 = new Property('prop3'));
     $this->class->setProperties($properties);
     $this->assertEquals($properties, $this->class->getProperties(), 'Set And Get Properties test');
     $this->class->addProperty($prop4 = new Property('prop4'));
     $this->assertEquals(array($prop1, $prop2, $prop3, $prop4), $this->class->getProperties(), 'AddProperty method test');
     $this->class->removeProperty('prop2');
     $this->assertEquals(array($prop1, $prop3, $prop4), \array_values($this->class->getProperties()), 'Remove property test');
     $this->assertEquals($this->class->getProperty('prop1'), $prop1, 'GetProperty Test');
     $this->setExpectedException('InvalidArgumentException');
     $this->class->getProperty('prop2');
 }
예제 #2
0
 /**
  * @param \ReflectionClass $class
  * @return MetaClass
  */
 public function metaClass(\ReflectionClass $class)
 {
     $phpyClass = new MetaClass($class->getName());
     $phpyClass->setAbstract($class->isAbstract());
     if ($parent = $class->getParentClass()) {
         $phpyClass->setParent($this->metaClass($parent));
     }
     $phpyClass->setInterfaces($class->getInterfaceNames());
     foreach ($class->getProperties() as $refProperty) {
         $phpyClass->addProperty($this->property($refProperty));
     }
     foreach ($class->getMethods() as $refMethod) {
         $phpyClass->addMethod($this->method($refMethod));
     }
     return $phpyClass;
 }