/** * Test to add an attribute factory to a factory and retrieve it again. * * @return void */ public function testAddTypeFactoryAndGetTypeFactory() { $factory = new AttributeFactory(); $this->assertNull($factory->getTypeFactory('test')); $attributeFactory = $this->mockAttributeFactory('test', true, false, false); $this->assertSame($factory, $factory->addTypeFactory($attributeFactory)); $this->assertSame($attributeFactory, $factory->getTypeFactory('test')); }
/** * Test the addFactoriesToFactory method. * * @return void * * @SuppressWarnings(PHPMD.Superglobals) * @SuppressWarnings(PHPMD.CamelCaseVariableName) */ public function testAddClassesToFactory() { $reflection = new \ReflectionClass('MetaModels\\Attribute\\LegacyAttributeTypeFactory'); $typeClassProp = $reflection->getProperty('typeClass'); $typeClassProp->setAccessible(true); foreach ($this->testFactories as $typeName => $instance) { $GLOBALS['METAMODELS']['attributes'][$typeName]['class'] = $typeClassProp->getValue($instance); } $factory = new AttributeFactory(); $factory->setServiceContainer($this->mockServiceContainer()); $this->assertEquals(array_keys($this->testFactories), $factory->getTypeNames()); foreach ($this->testFactories as $typeName => $instance) { $this->assertSame($typeClassProp->getValue($instance), $typeClassProp->getValue($factory->getTypeFactory($typeName))); $this->assertInstanceOf($typeClassProp->getValue($instance), $factory->createAttribute(array('type' => $typeName), null)); } unset($GLOBALS['METAMODELS']); }