public function setUp() { $filesystemMap = $this->getMockBuilder('Knp\\Bundle\\GaufretteBundle\\FilesystemMap')->disableOriginalConstructor()->getMock(); $this->filesystem = $this->getMockBuilder('Gaufrette\\Filesystem')->disableOriginalConstructor()->getMock(); $filesystemMap->expects($this->once())->method('get')->with('attachments')->will($this->returnValue($this->filesystem)); $this->router = $this->getMockBuilder('Symfony\\Bundle\\FrameworkBundle\\Routing\\Router')->disableOriginalConstructor()->getMock(); $ileIcons = ['default' => 'icon_default', 'txt' => 'icon_txt']; $this->attachment = new TestAttachment(); $this->attachment->setFilename('testFile.txt'); $this->attachment->setOriginalFilename('testFile.txt'); $serviceLink = $this->getMockBuilder('Oro\\Bundle\\EntityConfigBundle\\DependencyInjection\\Utils\\ServiceLink')->disableOriginalConstructor()->getMock(); $securityFacade = $this->getMockBuilder('Oro\\Bundle\\SecurityBundle\\SecurityFacade')->disableOriginalConstructor()->getMock(); $serviceLink->expects($this->any())->method('getService')->will($this->returnValue($securityFacade)); $securityFacade->expects($this->any())->method('getLoggedUser')->will($this->returnValue(null)); $this->attachmentManager = new AttachmentManager($filesystemMap, $this->router, $serviceLink, $ileIcons); }
public function getTestData() { $correctEntity = new TestAttachment(); $correctEntity->setId(1); $correctEntity->setFilename('test.doc'); $incorrectEntity = new File(); return ['correctEntity' => [$correctEntity, true], 'incorrectEntity' => [$incorrectEntity, false]]; }
public function testGetImageViewWIthIntegerAttachmentParameter() { $parentEntity = new TestClass(); $this->attachment->setFilename('test.doc'); $attachmentId = 1; $repo = $this->getMockBuilder('Doctrine\\Common\\Persistence\\ObjectRepository')->disableOriginalConstructor()->getMock(); $this->doctrine->expects($this->once())->method('getRepository')->will($this->returnValue($repo)); $repo->expects($this->once())->method('find')->with($attachmentId)->will($this->returnValue($this->attachment)); $environment = $this->getMockBuilder('\\Twig_Environment')->disableOriginalConstructor()->getMock(); $template = new TestTemplate(new \Twig_Environment()); $environment->expects($this->once())->method('loadTemplate')->will($this->returnValue($template)); $this->manager->expects($this->once())->method('getResizedImageUrl')->with($this->attachment, 16, 16); $this->manager->expects($this->once())->method('getFileUrl'); $this->extension->getImageView($environment, $parentEntity, $attachmentId); }