public function testIsApplicable() { $config = new Config(new EntityConfigId('comment', static::TEST_ENTITY_REFERENCE)); $config->set('enabled', true); $this->securityFacade->expects($this->once())->method('isGranted')->with('oro_comment_view')->willReturn(true); $this->commentConfigProvider->expects($this->once())->method('hasConfig')->with(static::TEST_ENTITY_REFERENCE)->will($this->returnValue(true)); $this->commentConfigProvider->expects($this->once())->method('getConfig')->with(static::TEST_ENTITY_REFERENCE)->will($this->returnValue($config)); $this->entityConfigProvider->expects($this->once())->method('hasConfig')->with(Comment::ENTITY_NAME, ExtendHelper::buildAssociationName(static::TEST_ENTITY_REFERENCE))->will($this->returnValue(true)); $this->assertTrue($this->filter->isApplicable(new TestEntity())); }
/** * @param mixed $entity * @param int $callsCount * @param int $callsProviderCount * @param bool $isApplicable * @param bool $isGranted * @param bool $expected * * @dataProvider commentProvider */ public function testIsApplicable($entity, $callsCount, $callsProviderCount, $isApplicable, $isGranted, $expected) { $config = $this->getMockBuilder('Oro\\Bundle\\EntityConfigBundle\\Config\\Config')->disableOriginalConstructor()->getMock(); $config->expects($this->exactly($callsProviderCount))->method('is')->will($this->returnValue($isApplicable)); $provider = $this->getMockBuilder('Oro\\Bundle\\EntityConfigBundle\\Provider\\ConfigProvider')->disableOriginalConstructor()->getMock(); $provider->expects($this->exactly($callsProviderCount))->method('getConfig')->will($this->returnValue($config)); $this->securityFacade->expects($this->any())->method('isGranted')->with('oro_comment_view')->will($this->returnValue($isGranted)); $this->configManager->expects($this->exactly($callsProviderCount))->method('getProvider')->will($this->returnValue($provider)); $this->configManager->expects($this->exactly($callsCount))->method('hasConfig')->will($this->returnValue(true)); $this->assertEquals($expected, $this->filter->isApplicable($entity)); }
public function testIsApplicableWithCommentAssociationEnabled() { $this->securityFacade->expects($this->once())->method('isGranted')->with('oro_comment_view')->willReturn(true); $this->commentAssociationHelper->expects($this->once())->method('isCommentAssociationEnabled')->with(static::TEST_ENTITY_REFERENCE)->will($this->returnValue(true)); $this->assertTrue($this->filter->isApplicable(new TestEntity())); }