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); }
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; }