function tearDown()
 {
     $d = DataObject::get("DMSDocument");
     foreach ($d as $d1) {
         $d1->delete();
     }
     $t = DataObject::get("DMSTag");
     foreach ($t as $t1) {
         $t1->delete();
     }
     //delete the test folder after the test runs
     $this->delete(BASE_PATH . DIRECTORY_SEPARATOR . 'dms-assets-test-versions');
     parent::tearDown();
     //set the old DMS folder back again
     DMS::$dmsFolder = self::$dmsFolderOld;
     DMS::$dmsFolderSize = self::$dmsFolderSizeOld;
     DMSDocument_versions::$enable_versions = self::$dmsEnableVersionsOld;
 }
Пример #2
0
 function tearDown()
 {
     parent::tearDown();
     self::$is_running_test = true;
     $d = DataObject::get("DMSDocument");
     foreach ($d as $d1) {
         $d1->delete();
     }
     $t = DataObject::get("DMSTag");
     foreach ($t as $t1) {
         $t1->delete();
     }
     //delete the test folder after the test runs
     $this->delete(BASE_PATH . DIRECTORY_SEPARATOR . 'dms-assets-test-1234');
     //set the old DMS folder back again
     DMS::$dmsFolder = self::$dmsFolderOld;
     DMS::$dmsFolderSize = self::$dmsFolderSizeOld;
     self::$is_running_test = $this->originalIsRunningTest;
 }
Пример #3
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;
 }