public function testRequestPublishedDocWithAccessibleFile()
 {
     $this->markTestIncomplete('build breaks when running this test on ci system -- it seems that phpunit does not allow to test for file downloads');
     // create test file test.pdf in file system
     $config = Zend_Registry::get('Zend_Config');
     $path = $config->workspacePath . DIRECTORY_SEPARATOR . uniqid();
     mkdir($path, 0777, true);
     $filepath = $path . DIRECTORY_SEPARATOR . 'test.pdf';
     touch($filepath);
     $doc = $this->createTestDocument();
     $doc->setServerState('published');
     $file = new Opus_File();
     $file->setVisibleInOai(true);
     $file->setPathName('test.pdf');
     $file->setTempFile($filepath);
     $doc->addFile($file);
     $doc->store();
     $this->dispatch('/oai/container/index/docId/' . $doc->getId());
     // cleanup
     $file->delete();
     Opus_Util_File::deleteDirectory($path);
     $this->assertResponseCode(200);
 }
 public function testDocumentWithNonExistentFile()
 {
     $doc = $this->createTestDocument();
     $doc->setServerState('published');
     $file = new Opus_File();
     $file->setPathName('test.pdf');
     $file->setVisibleInOai(true);
     $doc->addFile($file);
     $doc->store();
     $model = new Oai_Model_Container($doc->getId());
     $tarball = null;
     try {
         $tarball = $model->getFileHandle();
     } catch (Oai_Model_Exception $e) {
         $this->assertEquals('requested document does not have any associated readable files', $e->getMessage());
     }
     $this->assertTrue(is_null($tarball));
 }
 /**
  *  Regression Test for OPUSVIER-3072 (was Regression test for OPUSVIER-2509 and OPUSVIER-2510)
  */
 public function testForDDCSubjectTypeForXMetaDiss()
 {
     $collection = new Opus_Collection(112);
     $doc = $this->createTestDocument();
     $doc->setServerState('published');
     $doc->setType('doctoralthesis');
     // xMetaDiss liefert nur Doktorarbeiten und Habilitationen aus
     $doc->addCollection($collection);
     // fixing test for OPUSVIER-3142
     $visibleFile = new Opus_File();
     $visibleFile->setPathName('visible_file.txt');
     $visibleFile->setVisibleInOai(true);
     $doc->addFile($visibleFile);
     $this->docIds[] = $doc->store();
     $this->dispatch('/oai?verb=ListRecords&metadataPrefix=xMetaDiss&set=ddc:000');
     $body = $this->getResponse()->getBody();
     $this->assertNotContains('<dc:subject xsi:type="dcterms:DDC">000</dc:subject>', $body);
     $this->assertContains('<dc:subject xsi:type="xMetaDiss:DDC-SG">000</dc:subject>', $body);
 }
 protected function createTestFile($filename)
 {
     if (is_null($this->testFiles)) {
         $this->testFiles = array();
     }
     $config = Zend_Registry::get('Zend_Config');
     if (!isset($config->workspacePath)) {
         throw new Exception("config key 'workspacePath' not defined in config file");
     }
     $path = $config->workspacePath . DIRECTORY_SEPARATOR . uniqid();
     mkdir($path, 0777, true);
     $filepath = $path . DIRECTORY_SEPARATOR . $filename;
     touch($filepath);
     $this->assertTrue(is_readable($filepath));
     $file = new Opus_File();
     $file->setPathName(basename($filepath));
     $file->setTempFile($filepath);
     if (array_key_exists($filename, $this->testFiles)) {
         throw Exception('filenames should be unique');
     }
     $this->testFiles[$filename] = $filepath;
     return $file;
 }