/** * {@inheritDoc} */ public function setUp() { $this->serviceManager = Bootstrap::getServiceManager(); $this->document = new Document(); $this->document->setId(1); $this->document->setDocument('This is the document'); $contentType = new ContentType(); $contentType->setExtension('.xyz'); $this->document->setContentType($contentType); $project = new Project(); $project->setId(1); $project->setNumber('1234'); $project->setProject('This is the number'); $workpackage = new Workpackage(); $workpackage->setSequence(1); $workpackage->setProject($project); $this->document->setWorkpackage($workpackage); $authorizeServiceMock = $this->getMockBuilder('BjyAuthorize\\View\\Helper\\IsAllowed')->disableOriginalConstructor()->getMock(); $authorizeServiceMock->expects($this->any())->method('__invoke')->will($this->returnValue(true)); $viewHelperManager = $this->serviceManager->get('viewhelpermanager'); $viewHelperManager->setService('isAllowed', $authorizeServiceMock); $urlViewHelperMock = $this->getMockBuilder(Url::class)->disableOriginalConstructor()->getMock(); $urlViewHelperMock->expects($this->any())->method('__invoke')->will($this->returnValue(true)); $viewHelperManager->setService('url', $urlViewHelperMock); $this->documentLink = $viewHelperManager->get('workpackageDocumentlink'); }
/** * @return array */ public function provider() { $contentType = new ContentType(); $contentType->setContentType('test/' . Rand::getString(12)); $contentType->setDescription('This is the description ' . Rand::getString(12)); $contentType->setExtension(Rand::getString(4)); return [[$contentType]]; }
/** * {@inheritDoc} */ public function setUp() { $this->serviceManager = Bootstrap::getServiceManager(); $this->ideaImage = $this->serviceManager->get('viewhelpermanager')->get('ideaImage'); $idea = new Idea(); $idea->setId(1); $idea->setIdea('This is the idea'); $this->image = new Image(); $this->image->setId(1); $this->image->setIdea($idea); $contentType = new ContentType(); $contentType->setExtension('jpg'); $this->image->setContentType($contentType); }
/** * @param ContentType $contentType * * @return string */ public function __invoke(ContentType $contentType) { switch (trim($contentType->getContentType())) { case 'image/jpeg': case 'image/tiff': case 'image/png': $class = " fa-file-image-o"; break; case 'application/pdf': case 'application/postscript': $class = "fa-file-pdf-o"; break; case 'application/zip': case 'application/x-zip-compressed': $class = "fa-file-archive-o"; break; case 'application/vnd.ms-excel': case 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet': case 'application/vnd.ms-excel.sheet.macroEnabled.12': $class = "fa-file-excel-o"; break; case 'application/mspowerpoint': case 'application/vnd.ms-powerpoint': case 'application/vnd.openxmlformats-officedocument.presentationml.presentation': case 'application/vnd.openxmlformats-officedocument.presentationml.template': $class = 'fa-file-powerpoint-o'; break; case 'application/vnd.openxmlformats-officedocument.wordprocessingml.document': case 'application/vnd.openxmlformats-officedocument.wordprocessingml.template': case 'application/msword': $class = "fa-file-word-o"; break; case 'application/octet-stream': case 'text/xml': $class = "fa-file-o"; break; case 'video/mp4': $class = "fa-file-video-o"; break; default: return sprintf('%s not found', $contentType->getContentType()); } return sprintf('<i class="fa %s" title="%s"></i> ', $class, $contentType->getDescription()); }
/** * Simple filename parser for a report item. * * @return string */ public function parseFileName() { return $this->item . '.' . $this->contentType->getExtension(); }