/** * Iterate round all the GraphObjectType supported Object names * and instantiate a new Object using the Factory::create method */ public function testObjectCreation() { foreach (GraphObjectType::members() as $graph_object) { /** @var GraphObjectType $graph_object */ $this->assertInstanceOf('ChrisNoden\\Facebook\\Graph\\GraphObjectType', $graph_object); $class_name = $graph_object->value(); $obj = ObjectFactory::create($class_name); $this->assertInstanceOf('ChrisNoden\\Facebook\\Graph\\Object\\ObjectAbstract', $obj); $this->assertInstanceOf('ChrisNoden\\Facebook\\Graph\\Object\\' . $class_name, $obj); $this->assertEquals($class_name, $obj->__toString()); // all objects have an ID field - if not then this will throw an InvalidArgumentException $obj->getFieldDetails('id'); // dispose of the object before next iteration $obj = null; unset($obj); } }