public function testIsApplicableOnNonSupportedTarget()
 {
     $repo = $this->getMockBuilder('Oro\\Bundle\\ActivityListBundle\\Entity\\Repository\\ActivityListRepository')->disableOriginalConstructor()->getMock();
     $this->doctrine->expects($this->any())->method('getRepository')->will($this->returnValue($repo));
     $repo->expects($this->any())->method('getRecordsCountForTargetClassAndId')->with('Oro\\Bundle\\ActivityListBundle\\Tests\\Unit\\Placeholder\\Fixture\\TestNonActiveTarget', 123)->willReturn(true);
     $entity = new TestNonActiveTarget(123);
     $this->assertTrue($this->filter->isApplicable($entity));
 }
 /**
  * @param BeforeGroupingChainWidgetEvent $event
  */
 public function isAllowedButton(BeforeGroupingChainWidgetEvent $event)
 {
     if ($this->isFrontendRoute()) {
         // Clear allowed widgets
         $event->setWidgets([]);
         $event->stopPropagation();
     } else {
         $this->filter->isAllowedButton($event);
     }
 }
 public function testIsAllowedButton()
 {
     /** @var \PHPUnit_Framework_MockObject_MockObject|BeforeGroupingChainWidgetEvent $event */
     $event = $this->getMockBuilder('Oro\\Bundle\\UIBundle\\Event\\BeforeGroupingChainWidgetEvent')->disableOriginalConstructor()->getMock();
     $this->assertIsFrontendRouteCall(true);
     $event->expects($this->once())->method('setWidgets')->with([]);
     $event->expects($this->once())->method('stopPropagation');
     $this->basicFilter->expects($this->never())->method('isAllowedButton');
     $this->filter->isAllowedButton($event);
 }
Beispiel #4
0
 /** {@inheritdoc} */
 public function isApplicable($entity = null, $pageType = null)
 {
     $entityClass = $this->doctrineHelper->getEntityClass($entity);
     if (TargetExcludeList::isExcluded($entityClass)) {
         return false;
     }
     return parent::isApplicable($entity, $pageType);
 }
 /**
  * @dataProvider isAllowedButtonProvider
  * @param int      $pageType
  * @param array    $widgets
  * @param object   $entity
  * @param int|null $configProviderSetting
  * @param array    $expected
  */
 public function testIsAllowedButton($pageType, $widgets, $entity, $configProviderSetting, $expected)
 {
     if ($configProviderSetting !== null) {
         $this->setConfigProviderEntitySupport($entity, $configProviderSetting);
     }
     $event = new BeforeGroupingChainWidgetEvent($pageType, $widgets, $entity);
     $this->filter->isAllowedButton($event);
     $this->assertEquals($expected, $event->getWidgets());
 }
 /**
  * @dataProvider   isAllowedButtonProvider
  *
  * @param int      $pageType
  * @param array    $widgets
  * @param object   $entity
  * @param int|null $configProviderSetting
  * @param array    $expected
  */
 public function testIsAllowedButton($pageType, $widgets, $entity, $configProviderSetting, $expected)
 {
     $this->configManager->expects($this->once())->method('hasConfig')->with(get_class($entity))->willReturn(true);
     if ($configProviderSetting !== null) {
         $config = new Config(new EntityConfigId('activity', get_class($entity)));
         $config->set(ActivityScope::SHOW_ON_PAGE, $configProviderSetting);
         $this->configManager->expects($this->once())->method('getEntityConfig')->with('activity', get_class($entity))->willReturn($config);
     }
     $event = new BeforeGroupingChainWidgetEvent($pageType, $widgets, $entity);
     $this->filter->isAllowedButton($event);
     $this->assertEquals($expected, $event->getWidgets());
 }