Code Duplication    Length = 10-10 lines in 4 locations

tests/lib/files/view.php 4 locations

@@ 1254-1263 (lines=10) @@
1251
	 * @param string $rootPath
1252
	 * @param string $pathPrefix
1253
	 */
1254
	public function testReadFromWriteLockedPath($rootPath, $pathPrefix) {
1255
		$rootPath = str_replace('{folder}', 'files', $rootPath);
1256
		$pathPrefix = str_replace('{folder}', 'files', $pathPrefix);
1257
1258
		$view = new \OC\Files\View($rootPath);
1259
		$storage = new Temporary(array());
1260
		\OC\Files\Filesystem::mount($storage, [], '/');
1261
		$this->assertTrue($view->lockFile($pathPrefix . '/foo/bar', ILockingProvider::LOCK_EXCLUSIVE));
1262
		$view->lockFile($pathPrefix . '/foo/bar/asd', ILockingProvider::LOCK_SHARED);
1263
	}
1264
1265
	/**
1266
	 * Reading from a files_encryption folder that's being renamed
@@ 1273-1282 (lines=10) @@
1270
	 * @param string $rootPath
1271
	 * @param string $pathPrefix
1272
	 */
1273
	public function testReadFromWriteUnlockablePath($rootPath, $pathPrefix) {
1274
		$rootPath = str_replace('{folder}', 'files_encryption', $rootPath);
1275
		$pathPrefix = str_replace('{folder}', 'files_encryption', $pathPrefix);
1276
1277
		$view = new \OC\Files\View($rootPath);
1278
		$storage = new Temporary(array());
1279
		\OC\Files\Filesystem::mount($storage, [], '/');
1280
		$this->assertFalse($view->lockFile($pathPrefix . '/foo/bar', ILockingProvider::LOCK_EXCLUSIVE));
1281
		$this->assertFalse($view->lockFile($pathPrefix . '/foo/bar/asd', ILockingProvider::LOCK_SHARED));
1282
	}
1283
1284
	/**
1285
	 * e.g. writing a file that's being downloaded
@@ 1294-1303 (lines=10) @@
1291
	 * @param string $rootPath
1292
	 * @param string $pathPrefix
1293
	 */
1294
	public function testWriteToReadLockedFile($rootPath, $pathPrefix) {
1295
		$rootPath = str_replace('{folder}', 'files', $rootPath);
1296
		$pathPrefix = str_replace('{folder}', 'files', $pathPrefix);
1297
1298
		$view = new \OC\Files\View($rootPath);
1299
		$storage = new Temporary(array());
1300
		\OC\Files\Filesystem::mount($storage, [], '/');
1301
		$this->assertTrue($view->lockFile($pathPrefix . '/foo/bar', ILockingProvider::LOCK_SHARED));
1302
		$view->lockFile($pathPrefix . '/foo/bar', ILockingProvider::LOCK_EXCLUSIVE);
1303
	}
1304
1305
	/**
1306
	 * Writing a file that's being downloaded
@@ 1313-1322 (lines=10) @@
1310
	 * @param string $rootPath
1311
	 * @param string $pathPrefix
1312
	 */
1313
	public function testWriteToReadUnlockableFile($rootPath, $pathPrefix) {
1314
		$rootPath = str_replace('{folder}', 'files_encryption', $rootPath);
1315
		$pathPrefix = str_replace('{folder}', 'files_encryption', $pathPrefix);
1316
1317
		$view = new \OC\Files\View($rootPath);
1318
		$storage = new Temporary(array());
1319
		\OC\Files\Filesystem::mount($storage, [], '/');
1320
		$this->assertFalse($view->lockFile($pathPrefix . '/foo/bar', ILockingProvider::LOCK_SHARED));
1321
		$this->assertFalse($view->lockFile($pathPrefix . '/foo/bar', ILockingProvider::LOCK_EXCLUSIVE));
1322
	}
1323
1324
	/**
1325
	 * Test that locks are on mount point paths instead of mount root