public function testUnsettingInstanceDoesNotResetConstructors() { $object = new WikiaSuperFactoryTestClass('reinstantiate', 5); WikiaSuperFactory::setInstance('WikiaSuperFactoryTestClass', $object); $this->assertEquals($object, WikiaSuperFactory::build('WikiaSuperFactoryTestClass')); WikiaSuperFactory::unsetInstance('WikiaSuperFactoryTestClass'); $this->assertInstanceOf('WikiaSuperFactoryTestClass', WikiaSuperFactory::build('WikiaSuperFactoryTestClass', array(1))); $this->assertInstanceOf('WikiaSuperFactoryTestClass', WikiaSuperFactory::build('WikiaSuperFactoryTestClass', array(1, 2), 'newFromTypeAndBar')); WikiaSuperFactory::reset('WikiaSuperFactoryTestClass'); }
/** * reset factory configuration * @param string $className class name (optional) */ public static function reset($className = null) { if (!empty($className)) { unset(self::$constructors[$className]); unset(self::$setters[$className]); } else { // @codeCoverageIgnoreStart self::$constructors = array(); self::$setters = array(); // @codeCoverageIgnoreEnd } }