Example #1
0
 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'));
 }
Example #2
0
 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'));
 }