mirror of
https://github.com/silverstripe/silverstripe-dms
synced 2024-10-22 14:05:56 +02:00
BUGFIX: fixing DMS unit tests
This commit is contained in:
parent
e3c49aa775
commit
cb2f61c260
@ -176,8 +176,6 @@ class DMSDocument extends DataObject implements DMSDocumentInterface {
|
||||
$tags = $this->getTagsObjects($category, $value);
|
||||
|
||||
if ($tags->Count() > 0) {
|
||||
$tagsToDelete = array();
|
||||
|
||||
foreach($tags as $t) {
|
||||
$documentList = $t->Documents();
|
||||
|
||||
@ -187,13 +185,6 @@ class DMSDocument extends DataObject implements DMSDocumentInterface {
|
||||
//delete the entire tag if it has no relations left
|
||||
if ($documentList->Count() == 0) $t->delete();
|
||||
}
|
||||
|
||||
//TODO: remove this comment if unit tests work fine
|
||||
//delete after the loop, so it doesn't conflict with the loop of the $tags list
|
||||
// foreach($tagsToDelete as $tID) {
|
||||
// $tag = DataObject::get_by_id("DMSTag",$tID);
|
||||
// $tag->delete();
|
||||
// }
|
||||
}
|
||||
}
|
||||
|
||||
@ -202,20 +193,12 @@ class DMSDocument extends DataObject implements DMSDocumentInterface {
|
||||
* @return null
|
||||
*/
|
||||
function removeAllTags() {
|
||||
$tagsToDelete = array();
|
||||
$allTags = $this->Tags();
|
||||
foreach($allTags as $tag) {
|
||||
$documentlist = $tag->Documents();
|
||||
$documentlist->remove($this);
|
||||
if ($tag->Documents()->Count() == 0) $tag->delete();
|
||||
}
|
||||
|
||||
//TODO: remove this comment if unit tests work fine
|
||||
//delete after the loop, so it doesn't conflict with the loop of the $tags list
|
||||
// foreach($tagsToDelete as $tID) {
|
||||
// $tag = DataObject::get_by_id("DMSTag",$tID);
|
||||
// $tag->delete();
|
||||
// }
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -3,6 +3,17 @@ class DMSDocumentTest extends SapphireTest {
|
||||
|
||||
static $fixture_file = "dms/tests/dmstest.yml";
|
||||
|
||||
function tearDownOnce() {
|
||||
$d = DataObject::get("DMSDocument");
|
||||
foreach($d as $d1) {
|
||||
$d1->delete();
|
||||
}
|
||||
$t = DataObject::get("DMSTag");
|
||||
foreach($t as $t1) {
|
||||
$t1->delete();
|
||||
}
|
||||
}
|
||||
|
||||
function testPageRelations() {
|
||||
$s1 = $this->objFromFixture('SiteTree','s1');
|
||||
$s2 = $this->objFromFixture('SiteTree','s2');
|
||||
|
@ -3,6 +3,17 @@ class DMSTagTest extends SapphireTest {
|
||||
|
||||
//static $fixture_file = "dms/tests/dmstest.yml";
|
||||
|
||||
function tearDownOnce() {
|
||||
$d = DataObject::get("DMSDocument");
|
||||
foreach($d as $d1) {
|
||||
$d1->delete();
|
||||
}
|
||||
$t = DataObject::get("DMSTag");
|
||||
foreach($t as $t1) {
|
||||
$t1->delete();
|
||||
}
|
||||
}
|
||||
|
||||
function testAddingTags() {
|
||||
$doc = new DMSDocument();
|
||||
$doc->Filename = "test file";
|
||||
|
@ -19,6 +19,15 @@ class DMSTest extends SapphireTest {
|
||||
}
|
||||
|
||||
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::$dmsFolder);
|
||||
|
||||
@ -48,11 +57,9 @@ class DMSTest extends SapphireTest {
|
||||
|
||||
|
||||
function testDMSStorage() {
|
||||
$this->markTestIncomplete('DMS is WIP');
|
||||
|
||||
$dms = DMS::getDMSInstance();
|
||||
|
||||
$file = BASE_PATH . DIRECTORY_SEPARATOR . self::$testFile;
|
||||
$file = self::$testFile;
|
||||
$document = $dms->storeDocument($file);
|
||||
|
||||
$this->assertNotNull($document, "Document object created");
|
||||
@ -62,12 +69,10 @@ class DMSTest extends SapphireTest {
|
||||
}
|
||||
|
||||
function testDMSFolderSpanning() {
|
||||
$this->markTestIncomplete('DMS is WIP');
|
||||
|
||||
DMS::$dmsFolderSize = 5;
|
||||
$dms = DMS::getDMSInstance();
|
||||
|
||||
$file = BASE_PATH . DIRECTORY_SEPARATOR . self::$testFile;
|
||||
$file = self::$testFile;
|
||||
|
||||
$documents = array();
|
||||
for($i = 0; $i <= 16; $i++) {
|
||||
|
Loading…
Reference in New Issue
Block a user