Ejemplo n.º 1
0
 /**
  * {@inheritDoc}
  */
 public function setUp()
 {
     $this->serviceManager = Bootstrap::getServiceManager();
     $this->document = new Document();
     $this->document->setId(1);
     $this->document->setDocument('This is the document');
     $project = new Project();
     $project->setNumber('1234');
     $this->document->setProject($project);
     $contentType = new ContentType();
     $contentType->setExtension('.xyz');
     $this->document->setContentType($contentType);
     $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 = $this->serviceManager->get('viewhelpermanager')->get('documentlink');
 }
Ejemplo n.º 2
0
 /**
  * Load the Document
  *
  * @param ObjectManager $manager
  */
 public function load(ObjectManager $manager)
 {
     $document = new Document();
     $document->setContentType($manager->find("General\\Entity\\ContentType", 2));
     $document->setSize(1000);
     $document->setDocument('This is the testdocument for the merge');
     $document->setContact($manager->find("Contact\\Entity\\Contact", 1));
     $document->setProject($manager->find("Project\\Entity\\Project", 1));
     $document->setType($manager->find("Project\\Entity\\Document\\Type", 1));
     $documentObject = new Object();
     $documentObject->setObject(file_get_contents(__DIR__ . '/../../assets/doc/ITEA3_PO_Annex_template_Call1.docx'));
     $documentObject->setDocument($document);
     $manager->persist($documentObject);
     $manager->flush();
 }
Ejemplo n.º 3
0
 /**
  * @return \ZipArchive
  *
  * @throws \Exception
  */
 private function getZip()
 {
     if (is_null($this->zipArchive)) {
         $this->tempFile = '/tmp/wordreader_' . microtime() . '.zip';
         $fp = fopen($this->tempFile, 'w');
         fwrite($fp, stream_get_contents($this->document->getObject()->first()->object));
         fclose($fp);
         $this->zipArchive = new \ZipArchive();
         if (!$this->zipArchive->open($this->tempFile)) {
             throw new \Exception('Failed to open archive');
         }
     }
     return $this->zipArchive;
 }
Ejemplo n.º 4
0
 public function provider()
 {
     $projectTest = new ProjectTest();
     $contactTest = new ContactTest();
     $documentTypeTest = new TypeTest();
     $contentTypeTest = new ContentTypeTest();
     $document = new Document();
     $document->setDocument('This is a test-document');
     $document->setType(10000);
     $document->setContentType($contentTypeTest->provider()[0][0]);
     $document->setContact($contactTest->provider()[0][0]);
     $document->setProject($projectTest->provider()[0][0]);
     $document->setType($documentTypeTest->provider()[0][0]);
     return [[$document]];
 }
Ejemplo n.º 5
0
 /**
  * Returns true if a document can be merged.
  *
  * @return bool
  */
 public function canBeMerged()
 {
     return $this->document->getContentType()->getExtension() === 'docx' && in_array($this->document->getType()->getType(), $this->canBeMergedTypes);
 }