Exemplo n.º 1
0
 function testBasicEmbargo()
 {
     $oldDMSFolder = DMS::$dmsFolder;
     DMS::$dmsFolder = DMS_DIR;
     //sneakily setting the DMS folder to the folder where the test file lives
     $doc = new DMSDocument();
     $doc->Filename = "DMS-test-lorum-file.pdf";
     $doc->Folder = "tests";
     $docID = $doc->write();
     //fake a request for a document
     $controller = new DMSDocument_Controller();
     DMSDocument_Controller::$testMode = true;
     $result = $controller->index($this->createFakeHTTPRequest($docID));
     $this->assertEquals($doc->getFullPath(), $result, "Correct underlying file returned (in test mode)");
     $doc->embargoIndefinitely();
     $result = $controller->index($this->createFakeHTTPRequest($docID));
     $this->assertNotEquals($doc->getFullPath(), $result, "File no longer returned (in test mode)");
     DMS::$dmsFolder = $oldDMSFolder;
 }
 function testBasicEmbargo()
 {
     $oldDMSFolder = DMS::$dmsFolder;
     DMS::$dmsFolder = DMS_DIR;
     //sneakily setting the DMS folder to the folder where the test file lives
     $doc = new DMSDocument();
     $doc->Filename = "DMS-test-lorum-file.pdf";
     $doc->Folder = "tests";
     $docID = $doc->write();
     //fake a request for a document
     $controller = new DMSDocument_Controller();
     DMSDocument_Controller::$testMode = true;
     $result = $controller->index($this->createFakeHTTPRequest($docID));
     $this->assertEquals($doc->getFullPath(), $result, "Correct underlying file returned (in test mode)");
     $doc->embargoIndefinitely();
     $this->logInWithPermission('ADMIN');
     $result = $controller->index($this->createFakeHTTPRequest($docID));
     $this->assertEquals($doc->getFullPath(), $result, "Admins can still download embargoed files");
     $this->logInWithPermission('random-user-group');
     $result = $controller->index($this->createFakeHTTPRequest($docID));
     $this->assertNotEquals($doc->getFullPath(), $result, "File no longer returned (in test mode) when switching to other user group");
     DMS::$dmsFolder = $oldDMSFolder;
 }