Completed
Push — master ( 6848dc...c0dc17 )
by
unknown
40:28
created
apps/files_trashbin/tests/TrashbinTest.php 1 patch
Spacing   +29 added lines, -29 removed lines patch added patch discarded remove patch
@@ -69,7 +69,7 @@  discard block
 block discarded – undo
69 69
 
70 70
 		$config = Server::get(IConfig::class);
71 71
 		//configure trashbin
72
-		self::$rememberRetentionObligation = (string)$config->getSystemValue('trashbin_retention_obligation', Expiration::DEFAULT_RETENTION_OBLIGATION);
72
+		self::$rememberRetentionObligation = (string) $config->getSystemValue('trashbin_retention_obligation', Expiration::DEFAULT_RETENTION_OBLIGATION);
73 73
 		/** @var Expiration $expiration */
74 74
 		$expiration = Server::get(Expiration::class);
75 75
 		$expiration->setRetentionObligation('auto, 2');
@@ -117,7 +117,7 @@  discard block
 block discarded – undo
117 117
 			->getMock();
118 118
 		$mockConfig->expects($this->any())
119 119
 			->method('getSystemValue')
120
-			->willReturnCallback(static function ($key, $default) use ($config) {
120
+			->willReturnCallback(static function($key, $default) use ($config) {
121 121
 				if ($key === 'filesystem_check_changes') {
122 122
 					return Watcher::CHECK_ONCE;
123 123
 				} else {
@@ -126,8 +126,8 @@  discard block
 block discarded – undo
126 126
 			});
127 127
 		$this->overwriteService(AllConfig::class, $mockConfig);
128 128
 
129
-		$this->trashRoot1 = '/' . self::TEST_TRASHBIN_USER1 . '/files_trashbin';
130
-		$this->trashRoot2 = '/' . self::TEST_TRASHBIN_USER2 . '/files_trashbin';
129
+		$this->trashRoot1 = '/'.self::TEST_TRASHBIN_USER1.'/files_trashbin';
130
+		$this->trashRoot2 = '/'.self::TEST_TRASHBIN_USER2.'/files_trashbin';
131 131
 		$this->rootView = new View();
132 132
 		self::loginHelper(self::TEST_TRASHBIN_USER1);
133 133
 	}
@@ -137,8 +137,8 @@  discard block
 block discarded – undo
137 137
 		// disable trashbin to be able to properly clean up
138 138
 		Server::get(IAppManager::class)->disableApp('files_trashbin');
139 139
 
140
-		$this->rootView->deleteAll('/' . self::TEST_TRASHBIN_USER1 . '/files');
141
-		$this->rootView->deleteAll('/' . self::TEST_TRASHBIN_USER2 . '/files');
140
+		$this->rootView->deleteAll('/'.self::TEST_TRASHBIN_USER1.'/files');
141
+		$this->rootView->deleteAll('/'.self::TEST_TRASHBIN_USER2.'/files');
142 142
 		$this->rootView->deleteAll($this->trashRoot1);
143 143
 		$this->rootView->deleteAll($this->trashRoot2);
144 144
 
@@ -206,15 +206,15 @@  discard block
 block discarded – undo
206 206
 	 */
207 207
 	public function testExpireOldFilesShared(): void {
208 208
 		$currentTime = time();
209
-		$folder = 'trashTest-' . $currentTime . '/';
209
+		$folder = 'trashTest-'.$currentTime.'/';
210 210
 		$expiredDate = $currentTime - 3 * 24 * 60 * 60;
211 211
 
212 212
 		// create some files
213 213
 		Filesystem::mkdir($folder);
214
-		Filesystem::file_put_contents($folder . 'user1-1.txt', 'file1');
215
-		Filesystem::file_put_contents($folder . 'user1-2.txt', 'file2');
216
-		Filesystem::file_put_contents($folder . 'user1-3.txt', 'file3');
217
-		Filesystem::file_put_contents($folder . 'user1-4.txt', 'file4');
214
+		Filesystem::file_put_contents($folder.'user1-1.txt', 'file1');
215
+		Filesystem::file_put_contents($folder.'user1-2.txt', 'file2');
216
+		Filesystem::file_put_contents($folder.'user1-3.txt', 'file3');
217
+		Filesystem::file_put_contents($folder.'user1-4.txt', 'file4');
218 218
 
219 219
 		//share user1-4.txt with user2
220 220
 		$node = \OC::$server->getUserFolder(self::TEST_TRASHBIN_USER1)->get($folder);
@@ -228,9 +228,9 @@  discard block
 block discarded – undo
228 228
 		Server::get(\OCP\Share\IManager::class)->acceptShare($share, self::TEST_TRASHBIN_USER2);
229 229
 
230 230
 		// delete them so that they end up in the trash bin
231
-		Filesystem::unlink($folder . 'user1-1.txt');
232
-		Filesystem::unlink($folder . 'user1-2.txt');
233
-		Filesystem::unlink($folder . 'user1-3.txt');
231
+		Filesystem::unlink($folder.'user1-1.txt');
232
+		Filesystem::unlink($folder.'user1-2.txt');
233
+		Filesystem::unlink($folder.'user1-3.txt');
234 234
 
235 235
 		$filesInTrash = Helper::getTrashFiles('/', self::TEST_TRASHBIN_USER1, 'name');
236 236
 		$this->assertSame(3, count($filesInTrash));
@@ -241,7 +241,7 @@  discard block
 block discarded – undo
241 241
 		// login as user2
242 242
 		self::loginHelper(self::TEST_TRASHBIN_USER2);
243 243
 
244
-		$this->assertTrue(Filesystem::file_exists($folder . 'user1-4.txt'));
244
+		$this->assertTrue(Filesystem::file_exists($folder.'user1-4.txt'));
245 245
 
246 246
 		// create some files
247 247
 		Filesystem::file_put_contents('user2-1.txt', 'file1');
@@ -257,7 +257,7 @@  discard block
 block discarded – undo
257 257
 		// every second file will get a date in the past so that it will get expired
258 258
 		$this->manipulateDeleteTime($filesInTrashUser2, $this->trashRoot2, $expiredDate);
259 259
 
260
-		Filesystem::unlink($folder . 'user1-4.txt');
260
+		Filesystem::unlink($folder.'user1-4.txt');
261 261
 
262 262
 		$this->runCommands();
263 263
 
@@ -292,7 +292,7 @@  discard block
 block discarded – undo
292 292
 			}
293 293
 			if (!$found) {
294 294
 				// if we didn't found the expected file, something went wrong
295
-				$this->assertTrue(false, "can't find expected file '" . $expectedFile . "' in trash bin");
295
+				$this->assertTrue(false, "can't find expected file '".$expectedFile."' in trash bin");
296 296
 			}
297 297
 		}
298 298
 	}
@@ -306,8 +306,8 @@  discard block
 block discarded – undo
306 306
 			// modify every second file
307 307
 			$counter = ($counter + 1) % 2;
308 308
 			if ($counter === 1) {
309
-				$source = $trashRoot . '/files/' . $file['name'] . '.d' . $file['mtime'];
310
-				$target = Filesystem::normalizePath($trashRoot . '/files/' . $file['name'] . '.d' . $expireDate);
309
+				$source = $trashRoot.'/files/'.$file['name'].'.d'.$file['mtime'];
310
+				$target = Filesystem::normalizePath($trashRoot.'/files/'.$file['name'].'.d'.$expireDate);
311 311
 				$this->rootView->rename($source, $target);
312 312
 				$file['mtime'] = $expireDate;
313 313
 			}
@@ -372,7 +372,7 @@  discard block
 block discarded – undo
372 372
 
373 373
 		$this->assertTrue(
374 374
 			Trashbin::restore(
375
-				'file1.txt.d' . $trashedFile->getMtime(),
375
+				'file1.txt.d'.$trashedFile->getMtime(),
376 376
 				$trashedFile->getName(),
377 377
 				$trashedFile->getMtime()
378 378
 			)
@@ -405,7 +405,7 @@  discard block
 block discarded – undo
405 405
 
406 406
 		$this->assertTrue(
407 407
 			Trashbin::restore(
408
-				'file1.txt.d' . $trashedFile->getMtime(),
408
+				'file1.txt.d'.$trashedFile->getMtime(),
409 409
 				$trashedFile->getName(),
410 410
 				$trashedFile->getMtime()
411 411
 			)
@@ -438,7 +438,7 @@  discard block
 block discarded – undo
438 438
 
439 439
 		$this->assertTrue(
440 440
 			Trashbin::restore(
441
-				'folder.d' . $trashedFolder->getMtime(),
441
+				'folder.d'.$trashedFolder->getMtime(),
442 442
 				$trashedFolder->getName(),
443 443
 				$trashedFolder->getMtime()
444 444
 			)
@@ -471,7 +471,7 @@  discard block
 block discarded – undo
471 471
 
472 472
 		$this->assertTrue(
473 473
 			Trashbin::restore(
474
-				'folder.d' . $trashedFile->getMtime() . '/file1.txt',
474
+				'folder.d'.$trashedFile->getMtime().'/file1.txt',
475 475
 				'file1.txt',
476 476
 				$trashedFile->getMtime()
477 477
 			)
@@ -508,7 +508,7 @@  discard block
 block discarded – undo
508 508
 
509 509
 		$this->assertTrue(
510 510
 			Trashbin::restore(
511
-				'file1.txt.d' . $trashedFile->getMtime(),
511
+				'file1.txt.d'.$trashedFile->getMtime(),
512 512
 				$trashedFile->getName(),
513 513
 				$trashedFile->getMtime()
514 514
 			)
@@ -545,7 +545,7 @@  discard block
 block discarded – undo
545 545
 
546 546
 		$this->assertTrue(
547 547
 			Trashbin::restore(
548
-				'file1.txt.d' . $trashedFile->getMtime(),
548
+				'file1.txt.d'.$trashedFile->getMtime(),
549 549
 				$trashedFile->getName(),
550 550
 				$trashedFile->getMtime()
551 551
 			)
@@ -586,7 +586,7 @@  discard block
 block discarded – undo
586 586
 
587 587
 		$this->assertTrue(
588 588
 			Trashbin::restore(
589
-				'file1.txt.d' . $trashedFile->getMtime(),
589
+				'file1.txt.d'.$trashedFile->getMtime(),
590 590
 				$trashedFile->getName(),
591 591
 				$trashedFile->getMtime()
592 592
 			)
@@ -635,7 +635,7 @@  discard block
 block discarded – undo
635 635
 		$trashedFile = $filesInTrash[0];
636 636
 
637 637
 		// delete source folder
638
-		[$storage, $internalPath] = $this->rootView->resolvePath('/' . self::TEST_TRASHBIN_USER1 . '/files/folder');
638
+		[$storage, $internalPath] = $this->rootView->resolvePath('/'.self::TEST_TRASHBIN_USER1.'/files/folder');
639 639
 		if ($storage instanceof Local) {
640 640
 			$folderAbsPath = $storage->getSourcePath($internalPath);
641 641
 			// make folder read-only
@@ -643,7 +643,7 @@  discard block
 block discarded – undo
643 643
 
644 644
 			$this->assertTrue(
645 645
 				Trashbin::restore(
646
-					'file1.txt.d' . $trashedFile->getMtime(),
646
+					'file1.txt.d'.$trashedFile->getMtime(),
647 647
 					$trashedFile->getName(),
648 648
 					$trashedFile->getMtime()
649 649
 				)
@@ -657,7 +657,7 @@  discard block
 block discarded – undo
657 657
 	}
658 658
 
659 659
 	public function testTrashSizePropagation(): void {
660
-		$view = new View('/' . self::TEST_TRASHBIN_USER1 . '/files_trashbin/files');
660
+		$view = new View('/'.self::TEST_TRASHBIN_USER1.'/files_trashbin/files');
661 661
 
662 662
 		$userFolder = Server::get(IRootFolder::class)->getUserFolder(self::TEST_TRASHBIN_USER1);
663 663
 		$file1 = $userFolder->newFile('foo.txt');
Please login to merge, or discard this patch.