/** * Test the icon retrieval. * * @return void */ public function testGetTypeIcon() { $factory = new AttributeFactory(); $typeFactory = $this->mockAttributeFactory('test', true, false, false, new \stdClass(), 'icon.png'); $factory->addTypeFactory($typeFactory); $this->assertEquals($typeFactory->getTypeIcon(), $factory->getIconForType('test')); }
/** * Test the addFactoriesToFactory method. * * @return void * * @SuppressWarnings(PHPMD.Superglobals) * @SuppressWarnings(PHPMD.CamelCaseVariableName) */ public function testGetTypeIconsFromFactory() { $reflection = new \ReflectionClass('MetaModels\\Attribute\\LegacyAttributeTypeFactory'); $typeClassProp = $reflection->getProperty('typeClass'); $typeIconProp = $reflection->getProperty('typeIcon'); $typeClassProp->setAccessible(true); $typeIconProp->setAccessible(true); foreach ($this->testFactories as $typeName => $instance) { $GLOBALS['METAMODELS']['attributes'][$typeName]['class'] = $typeClassProp->getValue($instance); $GLOBALS['METAMODELS']['attributes'][$typeName]['image'] = $typeIconProp->getValue($instance); } $factory = new AttributeFactory(); $factory->setServiceContainer($this->mockServiceContainer()); $this->assertEquals(array_keys($this->testFactories), $factory->getTypeNames()); foreach ($this->testFactories as $typeName => $instance) { $this->assertEquals($typeIconProp->getValue($instance), $factory->getIconForType($typeName)); } unset($GLOBALS['METAMODELS']); }