public function testHasWidgetConfig() { $widgetName = 'test dashboard'; $config = array(ConfigProvider::NODE_WIDGET => array($widgetName => array('label' => 'test label'))); $configProvider = new ConfigProvider($config); $this->assertTrue($configProvider->hasWidgetConfig($widgetName)); $this->assertFalse($configProvider->hasWidgetConfig('incorrect widget')); }
public function testGetWidgetConfigShouldReturnConfigurationOfWidgetFromEvent() { $this->eventDispatcher->expects($this->once())->method('hasListeners')->with(WidgetConfigurationLoadEvent::EVENT_NAME)->will($this->returnValue(true)); $eventConfiguration = ['k12' => 'opt']; $this->eventDispatcher->expects($this->once())->method('dispatch')->will($this->returnCallback(function ($name, WidgetConfigurationLoadEvent $event) use($eventConfiguration) { $event->setConfiguration($eventConfiguration); return $event; })); $config = [ConfigProvider::NODE_WIDGET => ['widget' => []]]; $configProvider = new ConfigProvider($config, $this->eventDispatcher); $this->assertTrue($configProvider->hasWidgetConfig('widget')); $this->assertEquals($eventConfiguration, $configProvider->getWidgetConfig('widget')); }