Completed
Push — master ( 38c8ea...c9712b )
by Joas
40:21
created
tests/lib/Files/AppData/AppDataTest.php 1 patch
Indentation   +55 added lines, -55 removed lines patch added patch discarded remove patch
@@ -16,79 +16,79 @@
 block discarded – undo
16 16
 use OCP\Files\SimpleFS\ISimpleFolder;
17 17
 
18 18
 class AppDataTest extends \Test\TestCase {
19
-	/** @var IRootFolder|\PHPUnit\Framework\MockObject\MockObject */
20
-	private $rootFolder;
19
+    /** @var IRootFolder|\PHPUnit\Framework\MockObject\MockObject */
20
+    private $rootFolder;
21 21
 
22
-	/** @var SystemConfig|\PHPUnit\Framework\MockObject\MockObject */
23
-	private $systemConfig;
22
+    /** @var SystemConfig|\PHPUnit\Framework\MockObject\MockObject */
23
+    private $systemConfig;
24 24
 
25
-	/** @var IAppData */
26
-	private $appData;
25
+    /** @var IAppData */
26
+    private $appData;
27 27
 
28
-	protected function setUp(): void {
29
-		parent::setUp();
28
+    protected function setUp(): void {
29
+        parent::setUp();
30 30
 
31
-		$this->rootFolder = $this->createMock(IRootFolder::class);
32
-		$this->systemConfig = $this->createMock(SystemConfig::class);
33
-		$this->appData = new AppData($this->rootFolder, $this->systemConfig, 'myApp');
31
+        $this->rootFolder = $this->createMock(IRootFolder::class);
32
+        $this->systemConfig = $this->createMock(SystemConfig::class);
33
+        $this->appData = new AppData($this->rootFolder, $this->systemConfig, 'myApp');
34 34
 
35
-		$this->systemConfig->expects($this->any())
36
-			->method('getValue')
37
-			->with('instanceid', null)
38
-			->willReturn('iid');
39
-	}
35
+        $this->systemConfig->expects($this->any())
36
+            ->method('getValue')
37
+            ->with('instanceid', null)
38
+            ->willReturn('iid');
39
+    }
40 40
 
41
-	private function setupAppFolder() {
42
-		$appFolder = $this->createMock(Folder::class);
41
+    private function setupAppFolder() {
42
+        $appFolder = $this->createMock(Folder::class);
43 43
 
44
-		$this->rootFolder->expects($this->any())
45
-			->method('get')
46
-			->with($this->equalTo('appdata_iid/myApp'))
47
-			->willReturn($appFolder);
44
+        $this->rootFolder->expects($this->any())
45
+            ->method('get')
46
+            ->with($this->equalTo('appdata_iid/myApp'))
47
+            ->willReturn($appFolder);
48 48
 
49
-		return $appFolder;
50
-	}
49
+        return $appFolder;
50
+    }
51 51
 
52
-	public function testGetFolder(): void {
53
-		$folder = $this->createMock(Folder::class);
52
+    public function testGetFolder(): void {
53
+        $folder = $this->createMock(Folder::class);
54 54
 
55
-		$this->rootFolder->expects($this->once())
56
-			->method('get')
57
-			->with($this->equalTo('appdata_iid/myApp/folder'))
58
-			->willReturn($folder);
55
+        $this->rootFolder->expects($this->once())
56
+            ->method('get')
57
+            ->with($this->equalTo('appdata_iid/myApp/folder'))
58
+            ->willReturn($folder);
59 59
 
60
-		$result = $this->appData->getFolder('folder');
61
-		$this->assertInstanceOf(ISimpleFolder::class, $result);
62
-	}
60
+        $result = $this->appData->getFolder('folder');
61
+        $this->assertInstanceOf(ISimpleFolder::class, $result);
62
+    }
63 63
 
64
-	public function testNewFolder(): void {
65
-		$appFolder = $this->setupAppFolder();
64
+    public function testNewFolder(): void {
65
+        $appFolder = $this->setupAppFolder();
66 66
 
67
-		$folder = $this->createMock(Folder::class);
67
+        $folder = $this->createMock(Folder::class);
68 68
 
69
-		$appFolder->expects($this->once())
70
-			->method('newFolder')
71
-			->with($this->equalTo('folder'))
72
-			->willReturn($folder);
69
+        $appFolder->expects($this->once())
70
+            ->method('newFolder')
71
+            ->with($this->equalTo('folder'))
72
+            ->willReturn($folder);
73 73
 
74
-		$result = $this->appData->newFolder('folder');
75
-		$this->assertInstanceOf(ISimpleFolder::class, $result);
76
-	}
74
+        $result = $this->appData->newFolder('folder');
75
+        $this->assertInstanceOf(ISimpleFolder::class, $result);
76
+    }
77 77
 
78
-	public function testGetDirectoryListing(): void {
79
-		$appFolder = $this->setupAppFolder();
78
+    public function testGetDirectoryListing(): void {
79
+        $appFolder = $this->setupAppFolder();
80 80
 
81
-		$file = $this->createMock(File::class);
82
-		$folder = $this->createMock(Folder::class);
83
-		$node = $this->createMock(Node::class);
81
+        $file = $this->createMock(File::class);
82
+        $folder = $this->createMock(Folder::class);
83
+        $node = $this->createMock(Node::class);
84 84
 
85
-		$appFolder->expects($this->once())
86
-			->method('getDirectoryListing')
87
-			->willReturn([$file, $folder, $node]);
85
+        $appFolder->expects($this->once())
86
+            ->method('getDirectoryListing')
87
+            ->willReturn([$file, $folder, $node]);
88 88
 
89
-		$result = $this->appData->getDirectoryListing();
89
+        $result = $this->appData->getDirectoryListing();
90 90
 
91
-		$this->assertCount(1, $result);
92
-		$this->assertInstanceOf(ISimpleFolder::class, $result[0]);
93
-	}
91
+        $this->assertCount(1, $result);
92
+        $this->assertInstanceOf(ISimpleFolder::class, $result[0]);
93
+    }
94 94
 }
Please login to merge, or discard this patch.
tests/lib/Files/Mount/ObjectStorePreviewCacheMountProviderTest.php 1 patch
Indentation   +59 added lines, -59 removed lines patch added patch discarded remove patch
@@ -22,74 +22,74 @@
 block discarded – undo
22 22
  * The DB permission is needed for the fake root storage initialization
23 23
  */
24 24
 class ObjectStorePreviewCacheMountProviderTest extends \Test\TestCase {
25
-	/** @var ObjectStorePreviewCacheMountProvider */
26
-	protected $provider;
25
+    /** @var ObjectStorePreviewCacheMountProvider */
26
+    protected $provider;
27 27
 
28
-	/** @var LoggerInterface|MockObject */
29
-	protected $logger;
30
-	/** @var IConfig|MockObject */
31
-	protected $config;
32
-	/** @var IStorageFactory|MockObject */
33
-	protected $loader;
28
+    /** @var LoggerInterface|MockObject */
29
+    protected $logger;
30
+    /** @var IConfig|MockObject */
31
+    protected $config;
32
+    /** @var IStorageFactory|MockObject */
33
+    protected $loader;
34 34
 
35 35
 
36
-	protected function setUp(): void {
37
-		parent::setUp();
36
+    protected function setUp(): void {
37
+        parent::setUp();
38 38
 
39
-		$this->logger = $this->createMock(LoggerInterface::class);
40
-		$this->config = $this->createMock(IConfig::class);
41
-		$this->loader = $this->createMock(StorageFactory::class);
39
+        $this->logger = $this->createMock(LoggerInterface::class);
40
+        $this->config = $this->createMock(IConfig::class);
41
+        $this->loader = $this->createMock(StorageFactory::class);
42 42
 
43
-		$this->provider = new ObjectStorePreviewCacheMountProvider($this->logger, $this->config);
44
-	}
43
+        $this->provider = new ObjectStorePreviewCacheMountProvider($this->logger, $this->config);
44
+    }
45 45
 
46
-	public function testNoMultibucketObjectStorage(): void {
47
-		$this->config->expects($this->once())
48
-			->method('getSystemValue')
49
-			->with('objectstore_multibucket')
50
-			->willReturn(null);
46
+    public function testNoMultibucketObjectStorage(): void {
47
+        $this->config->expects($this->once())
48
+            ->method('getSystemValue')
49
+            ->with('objectstore_multibucket')
50
+            ->willReturn(null);
51 51
 
52
-		$this->assertEquals([], $this->provider->getRootMounts($this->loader));
53
-	}
52
+        $this->assertEquals([], $this->provider->getRootMounts($this->loader));
53
+    }
54 54
 
55
-	public function testMultibucketObjectStorage(): void {
56
-		$objectstoreConfig = [
57
-			'class' => S3::class,
58
-			'arguments' => [
59
-				'bucket' => 'abc',
60
-				'num_buckets' => 64,
61
-				'key' => 'KEY',
62
-				'secret' => 'SECRET',
63
-				'hostname' => 'IP',
64
-				'port' => 'PORT',
65
-				'use_ssl' => false,
66
-				'use_path_style' => true,
67
-			],
68
-		];
69
-		$this->config->expects($this->any())
70
-			->method('getSystemValue')
71
-			->willReturnCallback(function ($config) use ($objectstoreConfig) {
72
-				if ($config === 'objectstore_multibucket') {
73
-					return $objectstoreConfig;
74
-				} elseif ($config === 'objectstore.multibucket.preview-distribution') {
75
-					return true;
76
-				}
77
-				return null;
78
-			});
79
-		$this->config->expects($this->once())
80
-			->method('getSystemValueString')
81
-			->with('instanceid')
82
-			->willReturn('INSTANCEID');
55
+    public function testMultibucketObjectStorage(): void {
56
+        $objectstoreConfig = [
57
+            'class' => S3::class,
58
+            'arguments' => [
59
+                'bucket' => 'abc',
60
+                'num_buckets' => 64,
61
+                'key' => 'KEY',
62
+                'secret' => 'SECRET',
63
+                'hostname' => 'IP',
64
+                'port' => 'PORT',
65
+                'use_ssl' => false,
66
+                'use_path_style' => true,
67
+            ],
68
+        ];
69
+        $this->config->expects($this->any())
70
+            ->method('getSystemValue')
71
+            ->willReturnCallback(function ($config) use ($objectstoreConfig) {
72
+                if ($config === 'objectstore_multibucket') {
73
+                    return $objectstoreConfig;
74
+                } elseif ($config === 'objectstore.multibucket.preview-distribution') {
75
+                    return true;
76
+                }
77
+                return null;
78
+            });
79
+        $this->config->expects($this->once())
80
+            ->method('getSystemValueString')
81
+            ->with('instanceid')
82
+            ->willReturn('INSTANCEID');
83 83
 
84
-		$mounts = $this->provider->getRootMounts($this->loader);
84
+        $mounts = $this->provider->getRootMounts($this->loader);
85 85
 
86
-		// 256 mounts for the subfolders and 1 for the fake root
87
-		$this->assertCount(257, $mounts);
86
+        // 256 mounts for the subfolders and 1 for the fake root
87
+        $this->assertCount(257, $mounts);
88 88
 
89
-		// do some sanity checks if they have correct mount point paths
90
-		$this->assertEquals('/appdata_INSTANCEID/preview/0/0/', $mounts[0]->getMountPoint());
91
-		$this->assertEquals('/appdata_INSTANCEID/preview/2/5/', $mounts[37]->getMountPoint());
92
-		// also test the path of the fake bucket
93
-		$this->assertEquals('/appdata_INSTANCEID/preview/old-multibucket/', $mounts[256]->getMountPoint());
94
-	}
89
+        // do some sanity checks if they have correct mount point paths
90
+        $this->assertEquals('/appdata_INSTANCEID/preview/0/0/', $mounts[0]->getMountPoint());
91
+        $this->assertEquals('/appdata_INSTANCEID/preview/2/5/', $mounts[37]->getMountPoint());
92
+        // also test the path of the fake bucket
93
+        $this->assertEquals('/appdata_INSTANCEID/preview/old-multibucket/', $mounts[256]->getMountPoint());
94
+    }
95 95
 }
Please login to merge, or discard this patch.
tests/lib/Files/Mount/CacheMountProviderTest.php 1 patch
Indentation   +53 added lines, -53 removed lines patch added patch discarded remove patch
@@ -17,76 +17,76 @@
 block discarded – undo
17 17
 use Test\TestCase;
18 18
 
19 19
 class CacheMountProviderTestStream {
20
-	public static $statCounter = 0;
21
-	public static $mkdirCounter = 0;
20
+    public static $statCounter = 0;
21
+    public static $mkdirCounter = 0;
22 22
 
23
-	public $context;
23
+    public $context;
24 24
 
25
-	public function mkdir(string $path, int $mode, int $options): bool {
26
-		self::$mkdirCounter++;
27
-		return true;
28
-	}
25
+    public function mkdir(string $path, int $mode, int $options): bool {
26
+        self::$mkdirCounter++;
27
+        return true;
28
+    }
29 29
 
30
-	public function url_stat(string $path, int $flags): array|false {
31
-		self::$statCounter++;
32
-		return false;
33
-	}
30
+    public function url_stat(string $path, int $flags): array|false {
31
+        self::$statCounter++;
32
+        return false;
33
+    }
34 34
 }
35 35
 
36 36
 class CacheMountProviderTest extends TestCase {
37
-	private IConfig $config;
38
-	private IUser $user;
39
-	private IStorageFactory $storageFactory;
37
+    private IConfig $config;
38
+    private IUser $user;
39
+    private IStorageFactory $storageFactory;
40 40
 
41
-	protected function setUp(): void {
42
-		$this->config = $this->createMock(IConfig::class);
43
-		$this->user = $this->createMock(IUser::class);
44
-		$this->storageFactory = new StorageFactory();
45
-		stream_wrapper_register('cachemountprovidertest', CacheMountProviderTestStream::class);
46
-	}
41
+    protected function setUp(): void {
42
+        $this->config = $this->createMock(IConfig::class);
43
+        $this->user = $this->createMock(IUser::class);
44
+        $this->storageFactory = new StorageFactory();
45
+        stream_wrapper_register('cachemountprovidertest', CacheMountProviderTestStream::class);
46
+    }
47 47
 
48
-	protected function tearDown(): void {
49
-		stream_wrapper_unregister('cachemountprovidertest');
50
-	}
48
+    protected function tearDown(): void {
49
+        stream_wrapper_unregister('cachemountprovidertest');
50
+    }
51 51
 
52
-	public function testGetMountsForUser(): void {
53
-		$provider = new CacheMountProvider($this->config);
52
+    public function testGetMountsForUser(): void {
53
+        $provider = new CacheMountProvider($this->config);
54 54
 
55
-		$this->assertCount(0, $provider->getMountsForUser($this->user, $this->storageFactory));
56
-	}
55
+        $this->assertCount(0, $provider->getMountsForUser($this->user, $this->storageFactory));
56
+    }
57 57
 
58
-	public function testGetMountsForUserCacheDir(): void {
59
-		$this->config->expects($this->exactly(1))
60
-			->method('getSystemValueString')
61
-			->willReturnMap([
62
-				['cache_path', '', 'cachemountprovidertest:////cache_path'],
63
-			]);
64
-		$this->user->method('getUID')
65
-			->willReturn('bob');
58
+    public function testGetMountsForUserCacheDir(): void {
59
+        $this->config->expects($this->exactly(1))
60
+            ->method('getSystemValueString')
61
+            ->willReturnMap([
62
+                ['cache_path', '', 'cachemountprovidertest:////cache_path'],
63
+            ]);
64
+        $this->user->method('getUID')
65
+            ->willReturn('bob');
66 66
 
67
-		$provider = new CacheMountProvider($this->config);
68
-		$mounts = $provider->getMountsForUser($this->user, $this->storageFactory);
67
+        $provider = new CacheMountProvider($this->config);
68
+        $mounts = $provider->getMountsForUser($this->user, $this->storageFactory);
69 69
 
70
-		$this->assertCount(2, $mounts);
71
-		$this->assertEquals(1, CacheMountProviderTestStream::$statCounter);
72
-		$this->assertEquals(2, CacheMountProviderTestStream::$mkdirCounter);
70
+        $this->assertCount(2, $mounts);
71
+        $this->assertEquals(1, CacheMountProviderTestStream::$statCounter);
72
+        $this->assertEquals(2, CacheMountProviderTestStream::$mkdirCounter);
73 73
 
74
-		$cacheMountProvider = $mounts[0];
75
-		$this->assertEquals('/bob/cache/', $cacheMountProvider->getMountPoint());
74
+        $cacheMountProvider = $mounts[0];
75
+        $this->assertEquals('/bob/cache/', $cacheMountProvider->getMountPoint());
76 76
 
77
-		$cacheStorage = $cacheMountProvider->getStorage();
78
-		$this->assertEquals('local::cachemountprovidertest://cache_path/bob/', $cacheStorage->getId());
77
+        $cacheStorage = $cacheMountProvider->getStorage();
78
+        $this->assertEquals('local::cachemountprovidertest://cache_path/bob/', $cacheStorage->getId());
79 79
 
80
-		$uploadsMountProvider = $mounts[1];
81
-		$this->assertEquals('/bob/uploads/', $uploadsMountProvider->getMountPoint());
80
+        $uploadsMountProvider = $mounts[1];
81
+        $this->assertEquals('/bob/uploads/', $uploadsMountProvider->getMountPoint());
82 82
 
83
-		$uploadsStorage = $uploadsMountProvider->getStorage();
84
-		$this->assertEquals('local::cachemountprovidertest://cache_path/bob/uploads/', $uploadsStorage->getId());
83
+        $uploadsStorage = $uploadsMountProvider->getStorage();
84
+        $this->assertEquals('local::cachemountprovidertest://cache_path/bob/uploads/', $uploadsStorage->getId());
85 85
 
86
-		$cacheStorage->mkdir('foobar');
87
-		$this->assertEquals(3, CacheMountProviderTestStream::$mkdirCounter);
86
+        $cacheStorage->mkdir('foobar');
87
+        $this->assertEquals(3, CacheMountProviderTestStream::$mkdirCounter);
88 88
 
89
-		$uploadsStorage->mkdir('foobar');
90
-		$this->assertEquals(4, CacheMountProviderTestStream::$mkdirCounter);
91
-	}
89
+        $uploadsStorage->mkdir('foobar');
90
+        $this->assertEquals(4, CacheMountProviderTestStream::$mkdirCounter);
91
+    }
92 92
 }
Please login to merge, or discard this patch.
tests/lib/Files/ObjectStore/ObjectStoreStorageOverwrite.php 1 patch
Indentation   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -15,15 +15,15 @@
 block discarded – undo
15 15
  * Allow overwriting the object store instance for test purposes
16 16
  */
17 17
 class ObjectStoreStorageOverwrite extends ObjectStoreStorage {
18
-	public function setObjectStore(IObjectStore $objectStore): void {
19
-		$this->objectStore = $objectStore;
20
-	}
18
+    public function setObjectStore(IObjectStore $objectStore): void {
19
+        $this->objectStore = $objectStore;
20
+    }
21 21
 
22
-	public function getObjectStore(): IObjectStore {
23
-		return $this->objectStore;
24
-	}
22
+    public function getObjectStore(): IObjectStore {
23
+        return $this->objectStore;
24
+    }
25 25
 
26
-	public function setValidateWrites(bool $validate): void {
27
-		$this->validateWrites = $validate;
28
-	}
26
+    public function setValidateWrites(bool $validate): void {
27
+        $this->validateWrites = $validate;
28
+    }
29 29
 }
Please login to merge, or discard this patch.
tests/lib/Files/ObjectStore/ObjectStoreScannerTest.php 1 patch
Indentation   +44 added lines, -44 removed lines patch added patch discarded remove patch
@@ -17,62 +17,62 @@
 block discarded – undo
17 17
  * @group DB
18 18
  */
19 19
 class ObjectStoreScannerTest extends TestCase {
20
-	private IStorage $storage;
21
-	private ICache $cache;
22
-	private ObjectStoreScanner $scanner;
23
-	private Scanner $realScanner;
20
+    private IStorage $storage;
21
+    private ICache $cache;
22
+    private ObjectStoreScanner $scanner;
23
+    private Scanner $realScanner;
24 24
 
25
-	protected function setUp(): void {
26
-		parent::setUp();
25
+    protected function setUp(): void {
26
+        parent::setUp();
27 27
 
28
-		$this->storage = new Temporary([]);
29
-		$this->cache = $this->storage->getCache();
30
-		$this->scanner = new ObjectStoreScanner($this->storage);
31
-		$this->realScanner = new Scanner($this->storage);
32
-	}
28
+        $this->storage = new Temporary([]);
29
+        $this->cache = $this->storage->getCache();
30
+        $this->scanner = new ObjectStoreScanner($this->storage);
31
+        $this->realScanner = new Scanner($this->storage);
32
+    }
33 33
 
34
-	public function testFile(): void {
35
-		$data = "dummy file data\n";
36
-		$this->storage->file_put_contents('foo.txt', $data);
34
+    public function testFile(): void {
35
+        $data = "dummy file data\n";
36
+        $this->storage->file_put_contents('foo.txt', $data);
37 37
 
38
-		$this->assertNull($this->scanner->scanFile('foo.txt'),
39
-			'Asserting that no error occurred while scanFile()'
40
-		);
41
-	}
38
+        $this->assertNull($this->scanner->scanFile('foo.txt'),
39
+            'Asserting that no error occurred while scanFile()'
40
+        );
41
+    }
42 42
 
43
-	private function fillTestFolders() {
44
-		$textData = "dummy file data\n";
45
-		$imgData = file_get_contents(\OC::$SERVERROOT . '/core/img/logo/logo.png');
46
-		$this->storage->mkdir('folder');
47
-		$this->storage->file_put_contents('foo.txt', $textData);
48
-		$this->storage->file_put_contents('foo.png', $imgData);
49
-		$this->storage->file_put_contents('folder/bar.txt', $textData);
50
-	}
43
+    private function fillTestFolders() {
44
+        $textData = "dummy file data\n";
45
+        $imgData = file_get_contents(\OC::$SERVERROOT . '/core/img/logo/logo.png');
46
+        $this->storage->mkdir('folder');
47
+        $this->storage->file_put_contents('foo.txt', $textData);
48
+        $this->storage->file_put_contents('foo.png', $imgData);
49
+        $this->storage->file_put_contents('folder/bar.txt', $textData);
50
+    }
51 51
 
52
-	public function testFolder(): void {
53
-		$this->fillTestFolders();
52
+    public function testFolder(): void {
53
+        $this->fillTestFolders();
54 54
 
55
-		$this->assertNull(
56
-			$this->scanner->scan(''),
57
-			'Asserting that no error occurred while scan()'
58
-		);
59
-	}
55
+        $this->assertNull(
56
+            $this->scanner->scan(''),
57
+            'Asserting that no error occurred while scan()'
58
+        );
59
+    }
60 60
 
61
-	public function testBackgroundScan(): void {
62
-		$this->fillTestFolders();
63
-		$this->storage->mkdir('folder2');
64
-		$this->storage->file_put_contents('folder2/bar.txt', 'foobar');
61
+    public function testBackgroundScan(): void {
62
+        $this->fillTestFolders();
63
+        $this->storage->mkdir('folder2');
64
+        $this->storage->file_put_contents('folder2/bar.txt', 'foobar');
65 65
 
66
-		$this->realScanner->scan('');
66
+        $this->realScanner->scan('');
67 67
 
68
-		$this->assertEquals(6, $this->cache->get('folder2')->getSize());
68
+        $this->assertEquals(6, $this->cache->get('folder2')->getSize());
69 69
 
70
-		$this->cache->put('folder2', ['size' => -1]);
70
+        $this->cache->put('folder2', ['size' => -1]);
71 71
 
72
-		$this->assertEquals(-1, $this->cache->get('folder2')->getSize());
72
+        $this->assertEquals(-1, $this->cache->get('folder2')->getSize());
73 73
 
74
-		$this->scanner->backgroundScan();
74
+        $this->scanner->backgroundScan();
75 75
 
76
-		$this->assertEquals(6, $this->cache->get('folder2')->getSize());
77
-	}
76
+        $this->assertEquals(6, $this->cache->get('folder2')->getSize());
77
+    }
78 78
 }
Please login to merge, or discard this patch.
tests/lib/Files/Cache/PropagatorTest.php 1 patch
Indentation   +116 added lines, -116 removed lines patch added patch discarded remove patch
@@ -16,120 +16,120 @@
 block discarded – undo
16 16
  * @group DB
17 17
  */
18 18
 class PropagatorTest extends TestCase {
19
-	/** @var IStorage */
20
-	private $storage;
21
-
22
-	protected function setUp(): void {
23
-		parent::setUp();
24
-		$this->storage = new Temporary();
25
-		$this->storage->mkdir('foo/bar');
26
-		$this->storage->file_put_contents('foo/bar/file.txt', 'bar');
27
-		$this->storage->getScanner()->scan('');
28
-	}
29
-
30
-	/**
31
-	 * @param $paths
32
-	 * @return ICacheEntry[]
33
-	 */
34
-	private function getFileInfos($paths) {
35
-		$values = array_map(function ($path) {
36
-			return $this->storage->getCache()->get($path);
37
-		}, $paths);
38
-		return array_combine($paths, $values);
39
-	}
40
-
41
-	public function testEtagPropagation(): void {
42
-		$paths = ['', 'foo', 'foo/bar'];
43
-		$oldInfos = $this->getFileInfos($paths);
44
-		$this->storage->getPropagator()->propagateChange('foo/bar/file.txt', time());
45
-		$newInfos = $this->getFileInfos($paths);
46
-
47
-		foreach ($oldInfos as $i => $oldInfo) {
48
-			$this->assertNotEquals($oldInfo->getEtag(), $newInfos[$i]->getEtag());
49
-		}
50
-	}
51
-
52
-	public function testTimePropagation(): void {
53
-		$paths = ['', 'foo', 'foo/bar'];
54
-		$oldTime = time() - 200;
55
-		$targetTime = time() - 100;
56
-		$now = time();
57
-		$cache = $this->storage->getCache();
58
-		$cache->put('', ['mtime' => $now]);
59
-		$cache->put('foo', ['mtime' => $now]);
60
-		$cache->put('foo/bar', ['mtime' => $oldTime]);
61
-		$cache->put('foo/bar/file.txt', ['mtime' => $oldTime]);
62
-		$this->storage->getPropagator()->propagateChange('foo/bar/file.txt', $targetTime);
63
-		$newInfos = $this->getFileInfos($paths);
64
-
65
-		$this->assertEquals($targetTime, $newInfos['foo/bar']->getMTime());
66
-
67
-		// dont lower mtimes
68
-		$this->assertEquals($now, $newInfos['foo']->getMTime());
69
-		$this->assertEquals($now, $newInfos['']->getMTime());
70
-	}
71
-
72
-	public function testSizePropagation(): void {
73
-		$paths = ['', 'foo', 'foo/bar'];
74
-		$oldInfos = $this->getFileInfos($paths);
75
-		$this->storage->getPropagator()->propagateChange('foo/bar/file.txt', time(), 10);
76
-		$newInfos = $this->getFileInfos($paths);
77
-
78
-		foreach ($oldInfos as $i => $oldInfo) {
79
-			$this->assertEquals($oldInfo->getSize() + 10, $newInfos[$i]->getSize());
80
-		}
81
-	}
82
-
83
-	public function testSizePropagationNoNegative(): void {
84
-		$paths = ['', 'foo', 'foo/bar'];
85
-		$oldInfos = $this->getFileInfos($paths);
86
-		$this->storage->getPropagator()->propagateChange('foo/bar/file.txt', time(), -100);
87
-		$newInfos = $this->getFileInfos($paths);
88
-
89
-		foreach ($oldInfos as $i => $oldInfo) {
90
-			$this->assertEquals(-1, $newInfos[$i]->getSize());
91
-		}
92
-	}
93
-
94
-	public function testBatchedPropagation(): void {
95
-		$this->storage->mkdir('foo/baz');
96
-		$this->storage->mkdir('asd');
97
-		$this->storage->file_put_contents('asd/file.txt', 'bar');
98
-		$this->storage->file_put_contents('foo/baz/file.txt', 'bar');
99
-		$this->storage->getScanner()->scan('');
100
-
101
-		$paths = ['', 'foo', 'foo/bar', 'asd', 'foo/baz'];
102
-
103
-		$oldInfos = $this->getFileInfos($paths);
104
-		$propagator = $this->storage->getPropagator();
105
-
106
-		$propagator->beginBatch();
107
-		$propagator->propagateChange('asd/file.txt', time(), 10);
108
-		$propagator->propagateChange('foo/bar/file.txt', time(), 2);
109
-
110
-		$newInfos = $this->getFileInfos($paths);
111
-
112
-		// no changes until we finish the batch
113
-		foreach ($oldInfos as $i => $oldInfo) {
114
-			$this->assertEquals($oldInfo->getSize(), $newInfos[$i]->getSize());
115
-			$this->assertEquals($oldInfo->getEtag(), $newInfos[$i]->getEtag());
116
-			$this->assertEquals($oldInfo->getMTime(), $newInfos[$i]->getMTime());
117
-		}
118
-
119
-		$propagator->commitBatch();
120
-
121
-		$newInfos = $this->getFileInfos($paths);
122
-
123
-		foreach ($oldInfos as $i => $oldInfo) {
124
-			if ($oldInfo->getPath() !== 'foo/baz') {
125
-				$this->assertNotEquals($oldInfo->getEtag(), $newInfos[$i]->getEtag(), "etag for {$oldInfo->getPath()} not updated");
126
-			}
127
-		}
128
-
129
-		$this->assertEquals($oldInfos['']->getSize() + 12, $newInfos['']->getSize());
130
-		$this->assertEquals($oldInfos['asd']->getSize() + 10, $newInfos['asd']->getSize());
131
-		$this->assertEquals($oldInfos['foo']->getSize() + 2, $newInfos['foo']->getSize());
132
-		$this->assertEquals($oldInfos['foo/bar']->getSize() + 2, $newInfos['foo/bar']->getSize());
133
-		$this->assertEquals($oldInfos['foo/baz']->getSize(), $newInfos['foo/baz']->getSize());
134
-	}
19
+    /** @var IStorage */
20
+    private $storage;
21
+
22
+    protected function setUp(): void {
23
+        parent::setUp();
24
+        $this->storage = new Temporary();
25
+        $this->storage->mkdir('foo/bar');
26
+        $this->storage->file_put_contents('foo/bar/file.txt', 'bar');
27
+        $this->storage->getScanner()->scan('');
28
+    }
29
+
30
+    /**
31
+     * @param $paths
32
+     * @return ICacheEntry[]
33
+     */
34
+    private function getFileInfos($paths) {
35
+        $values = array_map(function ($path) {
36
+            return $this->storage->getCache()->get($path);
37
+        }, $paths);
38
+        return array_combine($paths, $values);
39
+    }
40
+
41
+    public function testEtagPropagation(): void {
42
+        $paths = ['', 'foo', 'foo/bar'];
43
+        $oldInfos = $this->getFileInfos($paths);
44
+        $this->storage->getPropagator()->propagateChange('foo/bar/file.txt', time());
45
+        $newInfos = $this->getFileInfos($paths);
46
+
47
+        foreach ($oldInfos as $i => $oldInfo) {
48
+            $this->assertNotEquals($oldInfo->getEtag(), $newInfos[$i]->getEtag());
49
+        }
50
+    }
51
+
52
+    public function testTimePropagation(): void {
53
+        $paths = ['', 'foo', 'foo/bar'];
54
+        $oldTime = time() - 200;
55
+        $targetTime = time() - 100;
56
+        $now = time();
57
+        $cache = $this->storage->getCache();
58
+        $cache->put('', ['mtime' => $now]);
59
+        $cache->put('foo', ['mtime' => $now]);
60
+        $cache->put('foo/bar', ['mtime' => $oldTime]);
61
+        $cache->put('foo/bar/file.txt', ['mtime' => $oldTime]);
62
+        $this->storage->getPropagator()->propagateChange('foo/bar/file.txt', $targetTime);
63
+        $newInfos = $this->getFileInfos($paths);
64
+
65
+        $this->assertEquals($targetTime, $newInfos['foo/bar']->getMTime());
66
+
67
+        // dont lower mtimes
68
+        $this->assertEquals($now, $newInfos['foo']->getMTime());
69
+        $this->assertEquals($now, $newInfos['']->getMTime());
70
+    }
71
+
72
+    public function testSizePropagation(): void {
73
+        $paths = ['', 'foo', 'foo/bar'];
74
+        $oldInfos = $this->getFileInfos($paths);
75
+        $this->storage->getPropagator()->propagateChange('foo/bar/file.txt', time(), 10);
76
+        $newInfos = $this->getFileInfos($paths);
77
+
78
+        foreach ($oldInfos as $i => $oldInfo) {
79
+            $this->assertEquals($oldInfo->getSize() + 10, $newInfos[$i]->getSize());
80
+        }
81
+    }
82
+
83
+    public function testSizePropagationNoNegative(): void {
84
+        $paths = ['', 'foo', 'foo/bar'];
85
+        $oldInfos = $this->getFileInfos($paths);
86
+        $this->storage->getPropagator()->propagateChange('foo/bar/file.txt', time(), -100);
87
+        $newInfos = $this->getFileInfos($paths);
88
+
89
+        foreach ($oldInfos as $i => $oldInfo) {
90
+            $this->assertEquals(-1, $newInfos[$i]->getSize());
91
+        }
92
+    }
93
+
94
+    public function testBatchedPropagation(): void {
95
+        $this->storage->mkdir('foo/baz');
96
+        $this->storage->mkdir('asd');
97
+        $this->storage->file_put_contents('asd/file.txt', 'bar');
98
+        $this->storage->file_put_contents('foo/baz/file.txt', 'bar');
99
+        $this->storage->getScanner()->scan('');
100
+
101
+        $paths = ['', 'foo', 'foo/bar', 'asd', 'foo/baz'];
102
+
103
+        $oldInfos = $this->getFileInfos($paths);
104
+        $propagator = $this->storage->getPropagator();
105
+
106
+        $propagator->beginBatch();
107
+        $propagator->propagateChange('asd/file.txt', time(), 10);
108
+        $propagator->propagateChange('foo/bar/file.txt', time(), 2);
109
+
110
+        $newInfos = $this->getFileInfos($paths);
111
+
112
+        // no changes until we finish the batch
113
+        foreach ($oldInfos as $i => $oldInfo) {
114
+            $this->assertEquals($oldInfo->getSize(), $newInfos[$i]->getSize());
115
+            $this->assertEquals($oldInfo->getEtag(), $newInfos[$i]->getEtag());
116
+            $this->assertEquals($oldInfo->getMTime(), $newInfos[$i]->getMTime());
117
+        }
118
+
119
+        $propagator->commitBatch();
120
+
121
+        $newInfos = $this->getFileInfos($paths);
122
+
123
+        foreach ($oldInfos as $i => $oldInfo) {
124
+            if ($oldInfo->getPath() !== 'foo/baz') {
125
+                $this->assertNotEquals($oldInfo->getEtag(), $newInfos[$i]->getEtag(), "etag for {$oldInfo->getPath()} not updated");
126
+            }
127
+        }
128
+
129
+        $this->assertEquals($oldInfos['']->getSize() + 12, $newInfos['']->getSize());
130
+        $this->assertEquals($oldInfos['asd']->getSize() + 10, $newInfos['asd']->getSize());
131
+        $this->assertEquals($oldInfos['foo']->getSize() + 2, $newInfos['foo']->getSize());
132
+        $this->assertEquals($oldInfos['foo/bar']->getSize() + 2, $newInfos['foo/bar']->getSize());
133
+        $this->assertEquals($oldInfos['foo/baz']->getSize(), $newInfos['foo/baz']->getSize());
134
+    }
135 135
 }
Please login to merge, or discard this patch.
tests/lib/Files/FileInfoTest.php 1 patch
Indentation   +39 added lines, -39 removed lines patch added patch discarded remove patch
@@ -17,43 +17,43 @@
 block discarded – undo
17 17
 use Test\Traits\UserTrait;
18 18
 
19 19
 class FileInfoTest extends TestCase {
20
-	use UserTrait;
21
-
22
-	private $config;
23
-
24
-	protected function setUp(): void {
25
-		parent::setUp();
26
-		$this->createUser('foo', 'foo');
27
-		$this->config = $this->getMockBuilder(IConfig::class)->getMock();
28
-	}
29
-
30
-	public function testIsMountedHomeStorage(): void {
31
-		$user = $this->createMock(IUser::class);
32
-		$user->method('getUID')
33
-			->willReturn('foo');
34
-		$user->method('getHome')
35
-			->willReturn('foo');
36
-		$storage = new Home(['user' => $user]);
37
-
38
-		$fileInfo = new FileInfo(
39
-			'',
40
-			$storage,
41
-			'',
42
-			[],
43
-			new HomeMountPoint($user, $storage, '/foo/files')
44
-		);
45
-		$this->assertFalse($fileInfo->isMounted());
46
-	}
47
-
48
-	public function testIsMountedNonHomeStorage(): void {
49
-		$storage = new Temporary();
50
-		$fileInfo = new FileInfo(
51
-			'',
52
-			$storage,
53
-			'',
54
-			[],
55
-			new MountPoint($storage, '/foo/files/bar')
56
-		);
57
-		$this->assertTrue($fileInfo->isMounted());
58
-	}
20
+    use UserTrait;
21
+
22
+    private $config;
23
+
24
+    protected function setUp(): void {
25
+        parent::setUp();
26
+        $this->createUser('foo', 'foo');
27
+        $this->config = $this->getMockBuilder(IConfig::class)->getMock();
28
+    }
29
+
30
+    public function testIsMountedHomeStorage(): void {
31
+        $user = $this->createMock(IUser::class);
32
+        $user->method('getUID')
33
+            ->willReturn('foo');
34
+        $user->method('getHome')
35
+            ->willReturn('foo');
36
+        $storage = new Home(['user' => $user]);
37
+
38
+        $fileInfo = new FileInfo(
39
+            '',
40
+            $storage,
41
+            '',
42
+            [],
43
+            new HomeMountPoint($user, $storage, '/foo/files')
44
+        );
45
+        $this->assertFalse($fileInfo->isMounted());
46
+    }
47
+
48
+    public function testIsMountedNonHomeStorage(): void {
49
+        $storage = new Temporary();
50
+        $fileInfo = new FileInfo(
51
+            '',
52
+            $storage,
53
+            '',
54
+            [],
55
+            new MountPoint($storage, '/foo/files/bar')
56
+        );
57
+        $this->assertTrue($fileInfo->isMounted());
58
+    }
59 59
 }
Please login to merge, or discard this patch.
tests/lib/Files/Storage/Wrapper/KnownMtimeTest.php 1 patch
Indentation   +41 added lines, -41 removed lines patch added patch discarded remove patch
@@ -16,53 +16,53 @@
 block discarded – undo
16 16
  * @group DB
17 17
  */
18 18
 class KnownMtimeTest extends Storage {
19
-	/** @var Temporary */
20
-	private $sourceStorage;
19
+    /** @var Temporary */
20
+    private $sourceStorage;
21 21
 
22
-	/** @var ClockInterface|MockObject */
23
-	private $clock;
24
-	private int $fakeTime = 0;
22
+    /** @var ClockInterface|MockObject */
23
+    private $clock;
24
+    private int $fakeTime = 0;
25 25
 
26
-	protected function setUp(): void {
27
-		parent::setUp();
28
-		$this->fakeTime = 0;
29
-		$this->sourceStorage = new Temporary([]);
30
-		$this->clock = $this->createMock(ClockInterface::class);
31
-		$this->clock->method('now')->willReturnCallback(function () {
32
-			if ($this->fakeTime) {
33
-				return new \DateTimeImmutable("@{$this->fakeTime}");
34
-			} else {
35
-				return new \DateTimeImmutable();
36
-			}
37
-		});
38
-		$this->instance = $this->getWrappedStorage();
39
-	}
26
+    protected function setUp(): void {
27
+        parent::setUp();
28
+        $this->fakeTime = 0;
29
+        $this->sourceStorage = new Temporary([]);
30
+        $this->clock = $this->createMock(ClockInterface::class);
31
+        $this->clock->method('now')->willReturnCallback(function () {
32
+            if ($this->fakeTime) {
33
+                return new \DateTimeImmutable("@{$this->fakeTime}");
34
+            } else {
35
+                return new \DateTimeImmutable();
36
+            }
37
+        });
38
+        $this->instance = $this->getWrappedStorage();
39
+    }
40 40
 
41
-	protected function tearDown(): void {
42
-		$this->sourceStorage->cleanUp();
43
-		parent::tearDown();
44
-	}
41
+    protected function tearDown(): void {
42
+        $this->sourceStorage->cleanUp();
43
+        parent::tearDown();
44
+    }
45 45
 
46
-	protected function getWrappedStorage() {
47
-		return new KnownMtime([
48
-			'storage' => $this->sourceStorage,
49
-			'clock' => $this->clock,
50
-		]);
51
-	}
46
+    protected function getWrappedStorage() {
47
+        return new KnownMtime([
48
+            'storage' => $this->sourceStorage,
49
+            'clock' => $this->clock,
50
+        ]);
51
+    }
52 52
 
53
-	public function testNewerKnownMtime(): void {
54
-		$future = time() + 1000;
55
-		$this->fakeTime = $future;
53
+    public function testNewerKnownMtime(): void {
54
+        $future = time() + 1000;
55
+        $this->fakeTime = $future;
56 56
 
57
-		$this->instance->file_put_contents('foo.txt', 'bar');
57
+        $this->instance->file_put_contents('foo.txt', 'bar');
58 58
 
59
-		// fuzzy match since the clock might have ticked
60
-		$this->assertLessThan(2, abs(time() - $this->sourceStorage->filemtime('foo.txt')));
61
-		$this->assertEquals($this->sourceStorage->filemtime('foo.txt'), $this->sourceStorage->stat('foo.txt')['mtime']);
62
-		$this->assertEquals($this->sourceStorage->filemtime('foo.txt'), $this->sourceStorage->getMetaData('foo.txt')['mtime']);
59
+        // fuzzy match since the clock might have ticked
60
+        $this->assertLessThan(2, abs(time() - $this->sourceStorage->filemtime('foo.txt')));
61
+        $this->assertEquals($this->sourceStorage->filemtime('foo.txt'), $this->sourceStorage->stat('foo.txt')['mtime']);
62
+        $this->assertEquals($this->sourceStorage->filemtime('foo.txt'), $this->sourceStorage->getMetaData('foo.txt')['mtime']);
63 63
 
64
-		$this->assertEquals($future, $this->instance->filemtime('foo.txt'));
65
-		$this->assertEquals($future, $this->instance->stat('foo.txt')['mtime']);
66
-		$this->assertEquals($future, $this->instance->getMetaData('foo.txt')['mtime']);
67
-	}
64
+        $this->assertEquals($future, $this->instance->filemtime('foo.txt'));
65
+        $this->assertEquals($future, $this->instance->stat('foo.txt')['mtime']);
66
+        $this->assertEquals($future, $this->instance->getMetaData('foo.txt')['mtime']);
67
+    }
68 68
 }
Please login to merge, or discard this patch.
tests/lib/Settings/SectionTest.php 1 patch
Indentation   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -10,13 +10,13 @@
 block discarded – undo
10 10
 use Test\TestCase;
11 11
 
12 12
 class SectionTest extends TestCase {
13
-	public function testGetID(): void {
14
-		$this->assertSame('ldap', (new Section('ldap', 'name', 1))->getID());
15
-	}
16
-	public function testGetName(): void {
17
-		$this->assertSame('name', (new Section('ldap', 'name', 1))->getName());
18
-	}
19
-	public function testGetPriority(): void {
20
-		$this->assertSame(1, (new Section('ldap', 'name', 1))->getPriority());
21
-	}
13
+    public function testGetID(): void {
14
+        $this->assertSame('ldap', (new Section('ldap', 'name', 1))->getID());
15
+    }
16
+    public function testGetName(): void {
17
+        $this->assertSame('name', (new Section('ldap', 'name', 1))->getName());
18
+    }
19
+    public function testGetPriority(): void {
20
+        $this->assertSame(1, (new Section('ldap', 'name', 1))->getPriority());
21
+    }
22 22
 }
Please login to merge, or discard this patch.