/**
  * @param boolean $return
  * @dataProvider configResultProvider
  */
 public function testIsAttachmentAssociationEnabled($return)
 {
     $entity = $this->getMock('\\stdClass');
     $this->attachmentConfig->expects($this->once())->method('isAttachmentAssociationEnabled')->with($entity)->willReturn($return);
     $actual = $this->filter->isAttachmentAssociationEnabled($entity);
     $this->assertEquals($return, $actual);
 }
Esempio n. 2
0
 /**
  * @param null|object $entity
  * @param bool        $attachmentConfigReturn
  * @param bool        $isNewRecord
  * @param bool        $isManaged
  * @param bool        $expected
  * @dataProvider configResultProvider
  */
 public function testIsAttachmentAssociationEnabled($entity, $attachmentConfigReturn, $isNewRecord, $isManaged, $expected)
 {
     $this->attachmentConfig->expects(is_object($entity) && !$isNewRecord ? $this->once() : $this->never())->method('isAttachmentAssociationEnabled')->with($entity)->willReturn($attachmentConfigReturn);
     $this->doctrineHelper->expects(is_object($entity) && $isManaged ? $this->once() : $this->never())->method('isNewEntity')->willReturn($isNewRecord);
     $this->doctrineHelper->expects(is_object($entity) ? $this->once() : $this->never())->method('isManageableEntity')->willReturn($isManaged);
     $actual = $this->filter->isAttachmentAssociationEnabled($entity);
     $this->assertEquals($expected, $actual);
 }
 public function testIsAttachmentAssociationEnabled()
 {
     $config = new Config(new EntityConfigId('attachment', 'stdClass'));
     $config->set('enabled', true);
     $this->attachmentConfigProvider->expects($this->once())->method('hasConfig')->with('stdClass')->will($this->returnValue(true));
     $this->attachmentConfigProvider->expects($this->once())->method('getConfig')->with('stdClass')->will($this->returnValue($config));
     $this->entityConfigProvider->expects($this->once())->method('hasConfig')->with(AttachmentScope::ATTACHMENT, ExtendHelper::buildAssociationName('stdClass'))->will($this->returnValue(true));
     $this->assertTrue($this->filter->isAttachmentAssociationEnabled(new \stdClass()));
 }