public function testMethodsMethods() { $methods = array($method1 = new Method('method1'), $method2 = new Method('method2'), $method3 = new Method('method3')); $this->class->setMethods($methods); $this->assertEquals($methods, $this->class->getMethods(), 'Set And Get Methods test'); $this->class->addMethod($method4 = new Method('method4')); $this->assertEquals(array($method1, $method2, $method3, $method4), $this->class->getMethods(), 'AddMethod method test'); $this->class->removeMethod('method2'); $this->assertEquals(array($method1, $method3, $method4), \array_values($this->class->getMethods()), 'Remove method test'); $this->assertEquals($this->class->getMethod('method1'), $method1, 'GetMethod Test'); $this->setExpectedException('InvalidArgumentException'); $this->class->getMethod('method2'); }
/** * @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; }