Code Duplication    Length = 4-7 lines in 10 locations

tests/filesystem/FileTest.php 3 locations

@@ 425-428 (lines=4) @@
422
423
		/* Create a test folders for each of the fixture references */
424
		$folderIDs = $this->allFixtureIDs('Folder');
425
		foreach($folderIDs as $folderID) {
426
			$folder = DataObject::get_by_id('Folder', $folderID);
427
			if(!file_exists(BASE_PATH."/$folder->Filename")) mkdir(BASE_PATH."/$folder->Filename");
428
		}
429
430
		/* Create a test files for each of the fixture references */
431
		$fileIDs = $this->allFixtureIDs('File');
@@ 455-458 (lines=4) @@
452
453
		/* Remove the test files that we've created */
454
		$fileIDs = $this->allFixtureIDs('File');
455
		foreach($fileIDs as $fileID) {
456
			$file = DataObject::get_by_id('File', $fileID);
457
			if($file && file_exists(BASE_PATH."/$file->Filename")) unlink(BASE_PATH."/$file->Filename");
458
		}
459
460
		/* Remove the test folders that we've crated */
461
		$folderIDs = $this->allFixtureIDs('Folder');
@@ 462-467 (lines=6) @@
459
460
		/* Remove the test folders that we've crated */
461
		$folderIDs = $this->allFixtureIDs('Folder');
462
		foreach($folderIDs as $folderID) {
463
			$folder = DataObject::get_by_id('Folder', $folderID);
464
			if($folder && file_exists(BASE_PATH."/$folder->Filename")) {
465
				Filesystem::removeFolder(BASE_PATH."/$folder->Filename");
466
			}
467
		}
468
469
		// Remove left over folders and any files that may exist
470
		if(file_exists('../assets/FileTest')) Filesystem::removeFolder('../assets/FileTest');

tests/filesystem/FolderTest.php 3 locations

@@ 262-265 (lines=4) @@
259
260
		// Create a test folders for each of the fixture references
261
		$folderIDs = $this->allFixtureIDs('Folder');
262
		foreach($folderIDs as $folderID) {
263
			$folder = DataObject::get_by_id('Folder', $folderID);
264
			if(!file_exists(BASE_PATH."/$folder->Filename")) mkdir(BASE_PATH."/$folder->Filename");
265
		}
266
267
		// Create a test files for each of the fixture references
268
		$fileIDs = $this->allFixtureIDs('File');
@@ 283-286 (lines=4) @@
280
281
		/* Remove the test files that we've created */
282
		$fileIDs = $this->allFixtureIDs('File');
283
		foreach($fileIDs as $fileID) {
284
			$file = DataObject::get_by_id('File', $fileID);
285
			if($file && file_exists(BASE_PATH."/$file->Filename")) unlink(BASE_PATH."/$file->Filename");
286
		}
287
288
		// Remove the test folders that we've crated
289
		$folderIDs = $this->allFixtureIDs('Folder');
@@ 290-296 (lines=7) @@
287
288
		// Remove the test folders that we've crated
289
		$folderIDs = $this->allFixtureIDs('Folder');
290
		foreach($folderIDs as $folderID) {
291
			$folder = DataObject::get_by_id('Folder', $folderID);
292
			// Might have been removed during test
293
			if($folder && file_exists(BASE_PATH."/$folder->Filename")) {
294
				Filesystem::removeFolder(BASE_PATH."/$folder->Filename");
295
			}
296
		}
297
298
		parent::tearDown();
299
	}

tests/forms/uploadfield/UploadFieldTest.php 2 locations

@@ 1002-1005 (lines=4) @@
999
1000
		/* Remove the test files that we've created */
1001
		$fileIDs = $this->allFixtureIDs('File');
1002
		foreach($fileIDs as $fileID) {
1003
			$file = DataObject::get_by_id('File', $fileID);
1004
			if($file && file_exists(BASE_PATH."/$file->Filename")) unlink(BASE_PATH."/$file->Filename");
1005
		}
1006
1007
		/* Remove the test folders that we've crated */
1008
		$folderIDs = $this->allFixtureIDs('Folder');
@@ 1009-1014 (lines=6) @@
1006
1007
		/* Remove the test folders that we've crated */
1008
		$folderIDs = $this->allFixtureIDs('Folder');
1009
		foreach($folderIDs as $folderID) {
1010
			$folder = DataObject::get_by_id('Folder', $folderID);
1011
			if($folder && file_exists(BASE_PATH."/$folder->Filename")) {
1012
				Filesystem::removeFolder(BASE_PATH."/$folder->Filename");
1013
			}
1014
		}
1015
1016
		// Remove left over folders and any files that may exist
1017
		if(file_exists(ASSETS_PATH.'/UploadFieldTest')) {

tests/model/ImageTest.php 2 locations

@@ 28-32 (lines=5) @@
25
		// Create a test folders for each of the fixture references
26
		$folderIDs = $this->allFixtureIDs('Folder');
27
28
		foreach($folderIDs as $folderID) {
29
			$folder = DataObject::get_by_id('Folder', $folderID);
30
31
			if(!file_exists(BASE_PATH."/$folder->Filename")) mkdir(BASE_PATH."/$folder->Filename");
32
		}
33
34
		// Copy test images for each of the fixture references
35
		$imageIDs = $this->allFixtureIDs('Image');
@@ 51-54 (lines=4) @@
48
49
		// Remove the test files that we've created
50
		$fileIDs = $this->allFixtureIDs('Image');
51
		foreach($fileIDs as $fileID) {
52
			$file = DataObject::get_by_id('Image', $fileID);
53
			if($file && file_exists(BASE_PATH."/$file->Filename")) unlink(BASE_PATH."/$file->Filename");
54
		}
55
56
		// Remove the test folders that we've created
57
		$folderIDs = $this->allFixtureIDs('Folder');