Code Duplication    Length = 29-29 lines in 2 locations

apps/files_versions/tests/versions.php 2 locations

@@ 242-270 (lines=29) @@
239
		);
240
	}
241
242
	public function testRename() {
243
244
		\OC\Files\Filesystem::file_put_contents("test.txt", "test file");
245
246
		$t1 = time();
247
		// second version is two weeks older, this way we make sure that no
248
		// version will be expired
249
		$t2 = $t1 - 60 * 60 * 24 * 14;
250
251
		// create some versions
252
		$v1 = self::USERS_VERSIONS_ROOT . '/test.txt.v' . $t1;
253
		$v2 = self::USERS_VERSIONS_ROOT . '/test.txt.v' . $t2;
254
		$v1Renamed = self::USERS_VERSIONS_ROOT . '/test2.txt.v' . $t1;
255
		$v2Renamed = self::USERS_VERSIONS_ROOT . '/test2.txt.v' . $t2;
256
257
		$this->rootView->file_put_contents($v1, 'version1');
258
		$this->rootView->file_put_contents($v2, 'version2');
259
260
		// execute rename hook of versions app
261
		\OC\Files\Filesystem::rename("test.txt", "test2.txt");
262
263
		$this->runCommands();
264
265
		$this->assertFalse($this->rootView->file_exists($v1));
266
		$this->assertFalse($this->rootView->file_exists($v2));
267
268
		$this->assertTrue($this->rootView->file_exists($v1Renamed));
269
		$this->assertTrue($this->rootView->file_exists($v2Renamed));
270
	}
271
272
	public function testRenameInSharedFolder() {
273
@@ 487-515 (lines=29) @@
484
		$this->assertFalse($this->rootView->file_exists($v2Renamed));
485
	}
486
487
	public function testCopy() {
488
489
		\OC\Files\Filesystem::file_put_contents("test.txt", "test file");
490
491
		$t1 = time();
492
		// second version is two weeks older, this way we make sure that no
493
		// version will be expired
494
		$t2 = $t1 - 60 * 60 * 24 * 14;
495
496
		// create some versions
497
		$v1 = self::USERS_VERSIONS_ROOT . '/test.txt.v' . $t1;
498
		$v2 = self::USERS_VERSIONS_ROOT . '/test.txt.v' . $t2;
499
		$v1Copied = self::USERS_VERSIONS_ROOT . '/test2.txt.v' . $t1;
500
		$v2Copied = self::USERS_VERSIONS_ROOT . '/test2.txt.v' . $t2;
501
502
		$this->rootView->file_put_contents($v1, 'version1');
503
		$this->rootView->file_put_contents($v2, 'version2');
504
505
		// execute copy hook of versions app
506
		\OC\Files\Filesystem::copy("test.txt", "test2.txt");
507
508
		$this->runCommands();
509
510
		$this->assertTrue($this->rootView->file_exists($v1));
511
		$this->assertTrue($this->rootView->file_exists($v2));
512
513
		$this->assertTrue($this->rootView->file_exists($v1Copied));
514
		$this->assertTrue($this->rootView->file_exists($v2Copied));
515
	}
516
517
	/**
518
	 * test if we find all versions and if the versions array contain