/**
  * @param bool $withGroupNameProvider
  * @return GroupingChainWidgetProvider
  */
 protected function getChainProvider($withGroupNameProvider = false)
 {
     $groupNameProvider = null;
     if ($withGroupNameProvider) {
         $groupNameProvider = $this->getMock('Oro\\Bundle\\UIBundle\\Provider\\LabelProviderInterface');
         $groupNameProvider->expects($this->any())->method('getLabel')->will($this->returnCallback(function ($parameters) {
             return $parameters['groupName'] . ' - ' . $parameters['entityClass'];
         }));
     }
     $chainProvider = new GroupingChainWidgetProvider($groupNameProvider);
     $chainProvider->addProvider($this->lowPriorityProvider);
     $chainProvider->addProvider($this->highPriorityProvider);
     $chainProvider->addProvider($this->unsupportedProvider);
     return $chainProvider;
 }
 /**
  * @param bool $withGroupNameProvider
  * @param bool $setEventDispatcher
  * @return GroupingChainWidgetProvider
  */
 protected function getChainProvider($withGroupNameProvider = false, $setEventDispatcher = true)
 {
     $groupNameProvider = null;
     if ($withGroupNameProvider) {
         /** @var \PHPUnit_Framework_MockObject_MockObject|LabelProviderInterface $groupNameProvider */
         $groupNameProvider = $this->getMock('Oro\\Bundle\\UIBundle\\Provider\\LabelProviderInterface');
         $groupNameProvider->expects($this->any())->method('getLabel')->will($this->returnCallback(function ($parameters) {
             return $parameters['groupName'] . ' - ' . $parameters['entityClass'];
         }));
     }
     if ($setEventDispatcher) {
         /** @var \PHPUnit_Framework_MockObject_MockObject|EventDispatcherInterface $eventDispatcher */
         $eventDispatcher = $this->getMock('\\Symfony\\Component\\EventDispatcher\\EventDispatcherInterface');
         $eventDispatcher->expects($this->once())->method('dispatch');
     }
     $chainProvider = new GroupingChainWidgetProvider($groupNameProvider, isset($eventDispatcher) ? $eventDispatcher : null);
     $chainProvider->addProvider($this->lowPriorityProvider);
     $chainProvider->addProvider($this->highPriorityProvider);
     $chainProvider->addProvider($this->unsupportedProvider);
     return $chainProvider;
 }