/** * @dataProvider getTestData */ public function testLinkToScope($config, $managerCalls, $attachmentCalls) { $attachments = $this->getMockBuilder('Oro\\Bundle\\EmailBundle\\Entity\\EmailAttachment')->disableOriginalConstructor()->getMock(); $emailBody = $this->getMockBuilder('Oro\\Bundle\\EmailBundle\\Entity\\EmailBody')->disableOriginalConstructor()->getMock(); $email = $this->getMockBuilder('Oro\\Bundle\\EmailBundle\\Entity\\Email')->disableOriginalConstructor()->getMock(); $event = $this->getMockBuilder('Oro\\Bundle\\EmailBundle\\Event\\EmailBodyAdded')->disableOriginalConstructor()->getMock(); $configInterface = $this->getMockBuilder('Oro\\Bundle\\EntityConfigBundle\\Config\\ConfigInterface')->disableOriginalConstructor()->getMock(); $this->securityFacade->expects($this->once())->method('getToken')->willReturn(1); $this->securityFacade->expects($this->once())->method('isGranted')->willReturn(true); $this->activityListProvider->expects($this->once())->method('getTargetEntities')->willReturn([new SomeEntity()]); $configInterface->expects($this->once())->method('get')->will($this->returnValue($config)); $this->configProvider->expects($this->once())->method('getConfig')->will($this->returnValue($configInterface)); $this->emailAttachmentManager->expects($this->exactly($managerCalls))->method('linkEmailAttachmentToTargetEntity'); $emailBody->expects($this->exactly($attachmentCalls))->method('getAttachments')->will($this->returnValue([$attachments])); $email->expects($this->exactly($attachmentCalls))->method('getEmailBody')->will($this->returnValue($emailBody)); $event->expects($this->exactly(1))->method('getEmail')->will($this->returnValue($email)); $this->listener->linkToScope($event); }