/** * @group issues * @ticket 9 */ public function testInstance() { $i = new Instantiator(__NAMESPACE__ . '\\StaticTest'); $i->setParam('factory', array(array())); $this->assertAttributeNotEmpty('staticMethodCalls', $i); $this->assertInstanceOf('DateTime', $i->getInstance()); }
public function testNestedInstantiators() { $i1 = new Instantiator('stdClass'); $i2 = new Instantiator('stdClass'); $i1->setParam('foo', $i2); $s = $i1->getInstance(); $this->assertEquals('stdClass', get_class($s->foo)); }
private function integrity() { if (is_null($this->reference)) { $this->reference = $this->reference(); Instantiator::initialise($this->reference); } }
public function testMagickInvoke() { $i1 = new Instantiator('stdClass'); $i2 = new Instantiator('stdClass'); $i1->setParam('foo', $i2); $s = $i1(); $this->assertEquals('stdClass', get_class($s->foo)); }
protected function loadObjectFromContext($name) { if (!array_key_exists($name, $this->context)) { throw new ApplicationContextException('Cannot load object, not found in context: ' . $name); } $objectContext = $this->context[$name]; $instantiator = new Instantiator($objectContext, $this); $newContext = $instantiator->getNewDefinition(); if ($newContext != $objectContext) { $this->addObjectContext($newContext); } $objectName = $objectContext['id']; $pattern = array_key_exists('scope', $objectContext) ? $objectContext['scope'] : 'Singleton'; $pClass = ucfirst($pattern . 'Pattern'); $cp = new ObjectService($objectName); $cp->setPattern(new $pClass($instantiator)); $this->addObject($cp); }
public function testInstantiate() { $in = new Instantiator(); $in->setReflectionClass(new \ReflectionClass('hanneskod\\classtools\\Instantiator\\Instantiator')); $this->assertInstanceOf('hanneskod\\classtools\\Instantiator\\Instantiator', $in->instantiate()); }