function testTypeCollector() { $collector = new TypeCollector($this->getContainerMock()); $collector->add('alias1', 'id1'); $collector->add('alias2', 'id2'); $type1 = $collector->getType('alias1'); $type2 = $collector->getType('alias2'); static::assertInstanceOf(TypeInterface::class, $type1); static::assertInstanceOf(TypeInterface::class, $type2); $this->assertEquals('alias1', $type1->getType('id1')); $this->assertEquals('alias2', $type2->getType('id2')); }
/** * Get a container with collector that contains passed widgets * * @param $widgets * @return \PHPUnit_Framework_MockObject_MockObject */ protected function getContainerWithCollectorMock($widgets) { $collector = new TypeCollector(); foreach ($widgets as $widget) { $collector->add($widget); } $container = $this->getMockBuilder('Symfony\\Component\\DependencyInjection\\ContainerInterface')->getMock(); $container->method('get')->willReturn($collector); return $container; }
/** * @expectedException Enhavo\Bundle\AppBundle\Exception\TypeNotFoundException */ function testGettingNonExistingType() { $collector = new TypeCollector(); $collector->add($this->buildTypeMock('type1')); $collector->getType('NonExistingType'); }