/** * @param object|null $entity * @param int|null $pageType * @return bool */ public function isApplicable($entity = null, $pageType = null) { if ($this->isFrontendRoute()) { return false; } return $this->filter->isApplicable($entity, $pageType); }
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)); }
/** {@inheritdoc} */ public function isApplicable($entity = null, $pageType = null) { $entityClass = $this->doctrineHelper->getEntityClass($entity); if (TargetExcludeList::isExcluded($entityClass)) { return false; } return parent::isApplicable($entity, $pageType); }
public function testIsApplicable() { $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(10); $entity = new TestNonActiveTarget(123); $entityClass = get_class($entity); $activityClass = 'Test\\Activity'; $config = new Config(new EntityConfigId('activity', $entityClass)); $config->set(ActivityScope::SHOW_ON_PAGE, '\\Oro\\Bundle\\ActivityBundle\\EntityConfig\\ActivityScope::VIEW_PAGE'); $config->set('activities', [$activityClass]); $this->configManager->expects($this->once())->method('hasConfig')->with($entityClass)->willReturn(true); $this->configManager->expects($this->once())->method('getEntityConfig')->with('activity', $entityClass)->willReturn($config); $this->activityListProvider->expects($this->once())->method('getSupportedActivities')->willReturn([$activityClass]); $this->activityListProvider->expects($this->exactly(1))->method('isApplicableTarget')->with($entityClass, $activityClass)->willReturn(true); $this->assertTrue($this->filter->isApplicable($entity, ActivityScope::VIEW_PAGE)); }