Exemplo n.º 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');
 }
Exemplo n.º 2
0
 public function testMetaClass()
 {
     $class = $this->phpyClass;
     $props = $this->phpyClass->getProperties();
     $methods = $this->phpyClass->getMethods();
     $this->assertEquals('DummyClass', $class->getName());
     $this->assertTrue($class->isAbstract());
     $this->assertEquals('Phpy\\Test\\Reflection', $class->getNamespace());
     $this->assertTrue($class->implementsInterface('Phpy\\Test\\Reflection\\DummyInterface'));
     $this->assertEquals($props, $this->phpyProps);
     $this->assertEquals($methods, $this->phpyMethods);
     $this->assertEquals('stdClass', $this->phpyExtendedClass->getParent()->getName());
 }
Exemplo n.º 3
0
 /**
  * Realize the set of properties
  *
  * @param MetaClass $class
  * @return string
  */
 private function realizeProperties(MetaClass $class)
 {
     $realizedProps = array();
     foreach ($class->getProperties() as $prop) {
         $realizedProps[] = $this->propertyRealizer->realize($prop);
     }
     return $realizedProps ? implode(';' . PHP_EOL . PHP_EOL, $realizedProps) . ';' : '';
 }