/** * @param array $definitions * @param bool $expects * * @dataProvider definitionDataProvider */ public function testOnKernelRequest(array $definitions, $expects) { /** @var GetResponseEvent $event */ $event = $this->getMockBuilder('Symfony\\Component\\HttpKernel\\Event\\GetResponseEvent')->disableOriginalConstructor()->getMock(); $this->widgetDefinitionsRegistry->expects($this->once())->method('getWidgetDefinitions')->will($this->returnValue(new ArrayCollection($definitions))); if ($expects) { $this->assetHelper->expects($this->exactly($expects))->method('getUrl')->with($this->isType('string')); } $this->handler->onKernelRequest($event); }
public function testGetWidgetDefinitions() { $placement = 'left'; $title = 'Foo'; $definitions = new ArrayCollection(); $definitions->set('test', array('title' => $title, 'icon' => 'test.ico', 'module' => 'widget/foo', 'placement' => 'left')); $this->widgetDefinitionsRegistry->expects($this->once())->method('getWidgetDefinitionsByPlacement')->with($placement)->will($this->returnValue($definitions)); $this->translator->expects($this->once())->method('trans')->with($title)->will($this->returnValue('trans' . $title)); $expected = array('test' => array('title' => 'transFoo', 'icon' => 'test.ico', 'module' => 'widget/foo', 'placement' => 'left')); $this->assertEquals($expected, $this->extension->getWidgetDefinitions($placement)); }