Completed
Push — master ( a96350...d0f819 )
by
unknown
29:59
created
tests/lib/Lockdown/LockdownManagerTest.php 1 patch
Indentation   +30 added lines, -30 removed lines patch added patch discarded remove patch
@@ -13,34 +13,34 @@
 block discarded – undo
13 13
 use Test\TestCase;
14 14
 
15 15
 class LockdownManagerTest extends TestCase {
16
-	private $sessionCallback;
17
-
18
-	protected function setUp(): void {
19
-		parent::setUp();
20
-
21
-		$this->sessionCallback = function () {
22
-			return $this->createMock(ISession::class);
23
-		};
24
-	}
25
-
26
-	public function testCanAccessFilesystemDisabled(): void {
27
-		$manager = new LockdownManager($this->sessionCallback);
28
-		$this->assertTrue($manager->canAccessFilesystem());
29
-	}
30
-
31
-	public function testCanAccessFilesystemAllowed(): void {
32
-		$token = new PublicKeyToken();
33
-		$token->setScope([IToken::SCOPE_FILESYSTEM => true]);
34
-		$manager = new LockdownManager($this->sessionCallback);
35
-		$manager->setToken($token);
36
-		$this->assertTrue($manager->canAccessFilesystem());
37
-	}
38
-
39
-	public function testCanAccessFilesystemNotAllowed(): void {
40
-		$token = new PublicKeyToken();
41
-		$token->setScope([IToken::SCOPE_FILESYSTEM => false]);
42
-		$manager = new LockdownManager($this->sessionCallback);
43
-		$manager->setToken($token);
44
-		$this->assertFalse($manager->canAccessFilesystem());
45
-	}
16
+    private $sessionCallback;
17
+
18
+    protected function setUp(): void {
19
+        parent::setUp();
20
+
21
+        $this->sessionCallback = function () {
22
+            return $this->createMock(ISession::class);
23
+        };
24
+    }
25
+
26
+    public function testCanAccessFilesystemDisabled(): void {
27
+        $manager = new LockdownManager($this->sessionCallback);
28
+        $this->assertTrue($manager->canAccessFilesystem());
29
+    }
30
+
31
+    public function testCanAccessFilesystemAllowed(): void {
32
+        $token = new PublicKeyToken();
33
+        $token->setScope([IToken::SCOPE_FILESYSTEM => true]);
34
+        $manager = new LockdownManager($this->sessionCallback);
35
+        $manager->setToken($token);
36
+        $this->assertTrue($manager->canAccessFilesystem());
37
+    }
38
+
39
+    public function testCanAccessFilesystemNotAllowed(): void {
40
+        $token = new PublicKeyToken();
41
+        $token->setScope([IToken::SCOPE_FILESYSTEM => false]);
42
+        $manager = new LockdownManager($this->sessionCallback);
43
+        $manager->setToken($token);
44
+        $this->assertFalse($manager->canAccessFilesystem());
45
+    }
46 46
 }
Please login to merge, or discard this patch.
tests/lib/Lockdown/Filesystem/NullStorageTest.php 1 patch
Indentation   +154 added lines, -154 removed lines patch added patch discarded remove patch
@@ -15,214 +15,214 @@
 block discarded – undo
15 15
 use Test\TestCase;
16 16
 
17 17
 class NullStorageTest extends TestCase {
18
-	/** @var NullStorage */
19
-	private $storage;
18
+    /** @var NullStorage */
19
+    private $storage;
20 20
 
21
-	protected function setUp(): void {
22
-		parent::setUp();
21
+    protected function setUp(): void {
22
+        parent::setUp();
23 23
 
24
-		$this->storage = new NullStorage([]);
25
-	}
24
+        $this->storage = new NullStorage([]);
25
+    }
26 26
 
27
-	public function testGetId(): void {
28
-		$this->assertSame('null', $this->storage->getId());
29
-	}
27
+    public function testGetId(): void {
28
+        $this->assertSame('null', $this->storage->getId());
29
+    }
30 30
 
31
-	public function testMkdir(): void {
32
-		$this->expectException(ForbiddenException::class);
33
-		$this->expectExceptionMessage('This request is not allowed to access the filesystem');
31
+    public function testMkdir(): void {
32
+        $this->expectException(ForbiddenException::class);
33
+        $this->expectExceptionMessage('This request is not allowed to access the filesystem');
34 34
 
35
-		$this->storage->mkdir('foo');
36
-	}
35
+        $this->storage->mkdir('foo');
36
+    }
37 37
 
38
-	public function testRmdir(): void {
39
-		$this->expectException(ForbiddenException::class);
40
-		$this->expectExceptionMessage('This request is not allowed to access the filesystem');
38
+    public function testRmdir(): void {
39
+        $this->expectException(ForbiddenException::class);
40
+        $this->expectExceptionMessage('This request is not allowed to access the filesystem');
41 41
 
42
-		$this->storage->rmdir('foo');
43
-	}
42
+        $this->storage->rmdir('foo');
43
+    }
44 44
 
45
-	public function testOpendir(): void {
46
-		$this->assertInstanceOf(IteratorDirectory::class, $this->storage->opendir('foo'));
47
-	}
45
+    public function testOpendir(): void {
46
+        $this->assertInstanceOf(IteratorDirectory::class, $this->storage->opendir('foo'));
47
+    }
48 48
 
49
-	public function testIs_dir(): void {
50
-		$this->assertTrue($this->storage->is_dir(''));
51
-		$this->assertFalse($this->storage->is_dir('foo'));
52
-	}
49
+    public function testIs_dir(): void {
50
+        $this->assertTrue($this->storage->is_dir(''));
51
+        $this->assertFalse($this->storage->is_dir('foo'));
52
+    }
53 53
 
54
-	public function testIs_file(): void {
55
-		$this->assertFalse($this->storage->is_file('foo'));
56
-	}
54
+    public function testIs_file(): void {
55
+        $this->assertFalse($this->storage->is_file('foo'));
56
+    }
57 57
 
58
-	public function testStat(): void {
59
-		$this->expectException(ForbiddenException::class);
60
-		$this->expectExceptionMessage('This request is not allowed to access the filesystem');
58
+    public function testStat(): void {
59
+        $this->expectException(ForbiddenException::class);
60
+        $this->expectExceptionMessage('This request is not allowed to access the filesystem');
61 61
 
62
-		$this->storage->stat('foo');
63
-	}
62
+        $this->storage->stat('foo');
63
+    }
64 64
 
65
-	public function testFiletype(): void {
66
-		$this->assertSame('dir', $this->storage->filetype(''));
67
-		$this->assertFalse($this->storage->filetype('foo'));
68
-	}
65
+    public function testFiletype(): void {
66
+        $this->assertSame('dir', $this->storage->filetype(''));
67
+        $this->assertFalse($this->storage->filetype('foo'));
68
+    }
69 69
 
70
-	public function testFilesize(): void {
71
-		$this->expectException(ForbiddenException::class);
72
-		$this->expectExceptionMessage('This request is not allowed to access the filesystem');
70
+    public function testFilesize(): void {
71
+        $this->expectException(ForbiddenException::class);
72
+        $this->expectExceptionMessage('This request is not allowed to access the filesystem');
73 73
 
74
-		$this->storage->filesize('foo');
75
-	}
74
+        $this->storage->filesize('foo');
75
+    }
76 76
 
77
-	public function testIsCreatable(): void {
78
-		$this->assertFalse($this->storage->isCreatable('foo'));
79
-	}
77
+    public function testIsCreatable(): void {
78
+        $this->assertFalse($this->storage->isCreatable('foo'));
79
+    }
80 80
 
81
-	public function testIsReadable(): void {
82
-		$this->assertTrue($this->storage->isReadable(''));
83
-		$this->assertFalse($this->storage->isReadable('foo'));
84
-	}
81
+    public function testIsReadable(): void {
82
+        $this->assertTrue($this->storage->isReadable(''));
83
+        $this->assertFalse($this->storage->isReadable('foo'));
84
+    }
85 85
 
86
-	public function testIsUpdatable(): void {
87
-		$this->assertFalse($this->storage->isUpdatable('foo'));
88
-	}
86
+    public function testIsUpdatable(): void {
87
+        $this->assertFalse($this->storage->isUpdatable('foo'));
88
+    }
89 89
 
90
-	public function testIsDeletable(): void {
91
-		$this->assertFalse($this->storage->isDeletable('foo'));
92
-	}
90
+    public function testIsDeletable(): void {
91
+        $this->assertFalse($this->storage->isDeletable('foo'));
92
+    }
93 93
 
94
-	public function testIsSharable(): void {
95
-		$this->assertFalse($this->storage->isSharable('foo'));
96
-	}
94
+    public function testIsSharable(): void {
95
+        $this->assertFalse($this->storage->isSharable('foo'));
96
+    }
97 97
 
98
-	public function testGetPermissions(): void {
99
-		$this->assertEquals(0, $this->storage->getPermissions('foo'));
100
-	}
98
+    public function testGetPermissions(): void {
99
+        $this->assertEquals(0, $this->storage->getPermissions('foo'));
100
+    }
101 101
 
102
-	public function testFile_exists(): void {
103
-		$this->assertTrue($this->storage->file_exists(''));
104
-		$this->assertFalse($this->storage->file_exists('foo'));
105
-	}
102
+    public function testFile_exists(): void {
103
+        $this->assertTrue($this->storage->file_exists(''));
104
+        $this->assertFalse($this->storage->file_exists('foo'));
105
+    }
106 106
 
107
-	public function testFilemtime(): void {
108
-		$this->assertFalse($this->storage->filemtime('foo'));
109
-	}
107
+    public function testFilemtime(): void {
108
+        $this->assertFalse($this->storage->filemtime('foo'));
109
+    }
110 110
 
111
-	public function testFile_get_contents(): void {
112
-		$this->expectException(ForbiddenException::class);
113
-		$this->expectExceptionMessage('This request is not allowed to access the filesystem');
111
+    public function testFile_get_contents(): void {
112
+        $this->expectException(ForbiddenException::class);
113
+        $this->expectExceptionMessage('This request is not allowed to access the filesystem');
114 114
 
115
-		$this->storage->file_get_contents('foo');
116
-	}
115
+        $this->storage->file_get_contents('foo');
116
+    }
117 117
 
118
-	public function testFile_put_contents(): void {
119
-		$this->expectException(ForbiddenException::class);
120
-		$this->expectExceptionMessage('This request is not allowed to access the filesystem');
118
+    public function testFile_put_contents(): void {
119
+        $this->expectException(ForbiddenException::class);
120
+        $this->expectExceptionMessage('This request is not allowed to access the filesystem');
121 121
 
122
-		$this->storage->file_put_contents('foo', 'bar');
123
-	}
122
+        $this->storage->file_put_contents('foo', 'bar');
123
+    }
124 124
 
125
-	public function testUnlink(): void {
126
-		$this->expectException(ForbiddenException::class);
127
-		$this->expectExceptionMessage('This request is not allowed to access the filesystem');
125
+    public function testUnlink(): void {
126
+        $this->expectException(ForbiddenException::class);
127
+        $this->expectExceptionMessage('This request is not allowed to access the filesystem');
128 128
 
129
-		$this->storage->unlink('foo');
130
-	}
129
+        $this->storage->unlink('foo');
130
+    }
131 131
 
132
-	public function testRename(): void {
133
-		$this->expectException(ForbiddenException::class);
134
-		$this->expectExceptionMessage('This request is not allowed to access the filesystem');
132
+    public function testRename(): void {
133
+        $this->expectException(ForbiddenException::class);
134
+        $this->expectExceptionMessage('This request is not allowed to access the filesystem');
135 135
 
136
-		$this->storage->rename('foo', 'bar');
137
-	}
136
+        $this->storage->rename('foo', 'bar');
137
+    }
138 138
 
139
-	public function testCopy(): void {
140
-		$this->expectException(ForbiddenException::class);
141
-		$this->expectExceptionMessage('This request is not allowed to access the filesystem');
139
+    public function testCopy(): void {
140
+        $this->expectException(ForbiddenException::class);
141
+        $this->expectExceptionMessage('This request is not allowed to access the filesystem');
142 142
 
143
-		$this->storage->copy('foo', 'bar');
144
-	}
143
+        $this->storage->copy('foo', 'bar');
144
+    }
145 145
 
146
-	public function testFopen(): void {
147
-		$this->expectException(ForbiddenException::class);
148
-		$this->expectExceptionMessage('This request is not allowed to access the filesystem');
146
+    public function testFopen(): void {
147
+        $this->expectException(ForbiddenException::class);
148
+        $this->expectExceptionMessage('This request is not allowed to access the filesystem');
149 149
 
150
-		$this->storage->fopen('foo', 'R');
151
-	}
150
+        $this->storage->fopen('foo', 'R');
151
+    }
152 152
 
153
-	public function testGetMimeType(): void {
154
-		$this->expectException(ForbiddenException::class);
155
-		$this->expectExceptionMessage('This request is not allowed to access the filesystem');
153
+    public function testGetMimeType(): void {
154
+        $this->expectException(ForbiddenException::class);
155
+        $this->expectExceptionMessage('This request is not allowed to access the filesystem');
156 156
 
157
-		$this->storage->getMimeType('foo');
158
-	}
157
+        $this->storage->getMimeType('foo');
158
+    }
159 159
 
160
-	public function testHash(): void {
161
-		$this->expectException(ForbiddenException::class);
162
-		$this->expectExceptionMessage('This request is not allowed to access the filesystem');
160
+    public function testHash(): void {
161
+        $this->expectException(ForbiddenException::class);
162
+        $this->expectExceptionMessage('This request is not allowed to access the filesystem');
163 163
 
164
-		$this->storage->hash('md5', 'foo', true);
165
-	}
164
+        $this->storage->hash('md5', 'foo', true);
165
+    }
166 166
 
167
-	public function testFree_space(): void {
168
-		$this->assertSame(FileInfo::SPACE_UNKNOWN, $this->storage->free_space('foo'));
169
-	}
167
+    public function testFree_space(): void {
168
+        $this->assertSame(FileInfo::SPACE_UNKNOWN, $this->storage->free_space('foo'));
169
+    }
170 170
 
171
-	public function testTouch(): void {
172
-		$this->expectException(ForbiddenException::class);
173
-		$this->expectExceptionMessage('This request is not allowed to access the filesystem');
171
+    public function testTouch(): void {
172
+        $this->expectException(ForbiddenException::class);
173
+        $this->expectExceptionMessage('This request is not allowed to access the filesystem');
174 174
 
175
-		$this->storage->touch('foo');
176
-	}
175
+        $this->storage->touch('foo');
176
+    }
177 177
 
178
-	public function testGetLocalFile(): void {
179
-		$this->assertFalse($this->storage->getLocalFile('foo'));
180
-	}
178
+    public function testGetLocalFile(): void {
179
+        $this->assertFalse($this->storage->getLocalFile('foo'));
180
+    }
181 181
 
182
-	public function testHasUpdated(): void {
183
-		$this->assertFalse($this->storage->hasUpdated('foo', 42));
184
-	}
182
+    public function testHasUpdated(): void {
183
+        $this->assertFalse($this->storage->hasUpdated('foo', 42));
184
+    }
185 185
 
186
-	public function testGetETag(): void {
187
-		$this->assertSame('', $this->storage->getETag('foo'));
188
-	}
186
+    public function testGetETag(): void {
187
+        $this->assertSame('', $this->storage->getETag('foo'));
188
+    }
189 189
 
190
-	public function testIsLocal(): void {
191
-		$this->assertFalse($this->storage->isLocal());
192
-	}
190
+    public function testIsLocal(): void {
191
+        $this->assertFalse($this->storage->isLocal());
192
+    }
193 193
 
194
-	public function testGetDirectDownload(): void {
195
-		$this->assertFalse($this->storage->getDirectDownload('foo'));
196
-	}
194
+    public function testGetDirectDownload(): void {
195
+        $this->assertFalse($this->storage->getDirectDownload('foo'));
196
+    }
197 197
 
198
-	public function testCopyFromStorage(): void {
199
-		$sourceStorage = $this->createMock(IStorage::class);
198
+    public function testCopyFromStorage(): void {
199
+        $sourceStorage = $this->createMock(IStorage::class);
200 200
 
201
-		$this->expectException(ForbiddenException::class);
202
-		$this->expectExceptionMessage('This request is not allowed to access the filesystem');
201
+        $this->expectException(ForbiddenException::class);
202
+        $this->expectExceptionMessage('This request is not allowed to access the filesystem');
203 203
 
204
-		$this->storage->copyFromStorage($sourceStorage, 'foo', 'bar');
205
-	}
204
+        $this->storage->copyFromStorage($sourceStorage, 'foo', 'bar');
205
+    }
206 206
 
207
-	public function testMoveFromStorage(): void {
208
-		$sourceStorage = $this->createMock(IStorage::class);
207
+    public function testMoveFromStorage(): void {
208
+        $sourceStorage = $this->createMock(IStorage::class);
209 209
 
210
-		$this->expectException(ForbiddenException::class);
211
-		$this->expectExceptionMessage('This request is not allowed to access the filesystem');
210
+        $this->expectException(ForbiddenException::class);
211
+        $this->expectExceptionMessage('This request is not allowed to access the filesystem');
212 212
 
213
-		$this->storage->moveFromStorage($sourceStorage, 'foo', 'bar');
214
-	}
213
+        $this->storage->moveFromStorage($sourceStorage, 'foo', 'bar');
214
+    }
215 215
 
216
-	public function testTest() {
217
-		$this->assertTrue($this->storage->test());
218
-		return true;
219
-	}
216
+    public function testTest() {
217
+        $this->assertTrue($this->storage->test());
218
+        return true;
219
+    }
220 220
 
221
-	public function testGetOwner(): void {
222
-		$this->assertFalse($this->storage->getOwner('foo'));
223
-	}
221
+    public function testGetOwner(): void {
222
+        $this->assertFalse($this->storage->getOwner('foo'));
223
+    }
224 224
 
225
-	public function testGetCache(): void {
226
-		$this->assertInstanceOf(NullCache::class, $this->storage->getCache('foo'));
227
-	}
225
+    public function testGetCache(): void {
226
+        $this->assertInstanceOf(NullCache::class, $this->storage->getCache('foo'));
227
+    }
228 228
 }
Please login to merge, or discard this patch.
tests/lib/AppScriptSortTest.php 1 patch
Indentation   +102 added lines, -102 removed lines patch added patch discarded remove patch
@@ -18,106 +18,106 @@
 block discarded – undo
18 18
  * @group DB
19 19
  */
20 20
 class AppScriptSortTest extends \Test\TestCase {
21
-	private $logger;
22
-
23
-	protected function setUp(): void {
24
-		$this->logger = $this->getMockBuilder(LoggerInterface::class)
25
-			->disableOriginalConstructor()
26
-			->getMock();
27
-
28
-		parent::setUp();
29
-	}
30
-
31
-	public function testSort(): void {
32
-		$scripts = [
33
-			'first' => ['myFirstJSFile'],
34
-			'core' => [
35
-				'core/js/myFancyJSFile1',
36
-				'core/js/myFancyJSFile4',
37
-				'core/js/myFancyJSFile5',
38
-				'core/js/myFancyJSFile1',
39
-			],
40
-			'files' => ['files/js/myFancyJSFile2'],
41
-			'myApp5' => ['myApp5/js/myApp5JSFile'],
42
-			'myApp' => ['myApp/js/myFancyJSFile3'],
43
-			'myApp4' => ['myApp4/js/myApp4JSFile'],
44
-			'myApp3' => ['myApp3/js/myApp3JSFile'],
45
-			'myApp2' => ['myApp2/js/myApp2JSFile'],
46
-		];
47
-		$scriptDeps = [
48
-			'first' => new AppScriptDependency('first', ['core']),
49
-			'core' => new AppScriptDependency('core', ['core']),
50
-			'files' => new AppScriptDependency('files', ['core']),
51
-			'myApp5' => new AppScriptDependency('myApp5', ['myApp2']),
52
-			'myApp' => new AppScriptDependency('myApp', ['core']),
53
-			'myApp4' => new AppScriptDependency('myApp4', ['myApp3']),
54
-			'myApp3' => new AppScriptDependency('myApp3', ['myApp2']),
55
-			'myApp2' => new AppScriptDependency('myApp2', ['myApp']),
56
-		];
57
-
58
-		// No circular dependency is detected and logged as an error
59
-		$this->logger->expects(self::never())->method('error');
60
-
61
-		$scriptSort = new AppScriptSort($this->logger);
62
-		$sortedScripts = $scriptSort->sort($scripts, $scriptDeps);
63
-
64
-		$sortedScriptKeys = array_keys($sortedScripts);
65
-
66
-		// Core should appear first
67
-		$this->assertEquals(
68
-			0,
69
-			array_search('core', $sortedScriptKeys, true)
70
-		);
71
-
72
-		// Dependencies should appear before their children
73
-		$this->assertLessThan(
74
-			array_search('files', $sortedScriptKeys, true),
75
-			array_search('core', $sortedScriptKeys, true)
76
-		);
77
-		$this->assertLessThan(
78
-			array_search('myApp2', $sortedScriptKeys, true),
79
-			array_search('myApp', $sortedScriptKeys, true)
80
-		);
81
-		$this->assertLessThan(
82
-			array_search('myApp3', $sortedScriptKeys, true),
83
-			array_search('myApp2', $sortedScriptKeys, true)
84
-		);
85
-		$this->assertLessThan(
86
-			array_search('myApp4', $sortedScriptKeys, true),
87
-			array_search('myApp3', $sortedScriptKeys, true)
88
-		);
89
-		$this->assertLessThan(
90
-			array_search('myApp5', $sortedScriptKeys, true),
91
-			array_search('myApp2', $sortedScriptKeys, true)
92
-		);
93
-
94
-		// All apps still there
95
-		foreach ($scripts as $app => $_) {
96
-			$this->assertContains($app, $sortedScriptKeys);
97
-		}
98
-	}
99
-
100
-	public function testSortCircularDependency(): void {
101
-		$scripts = [
102
-			'circular' => ['circular/js/file1'],
103
-			'dependency' => ['dependency/js/file2'],
104
-		];
105
-		$scriptDeps = [
106
-			'circular' => new AppScriptDependency('circular', ['dependency']),
107
-			'dependency' => new AppScriptDependency('dependency', ['circular']),
108
-		];
109
-
110
-		// A circular dependency is detected and logged as an error
111
-		$this->logger->expects(self::once())->method('error');
112
-
113
-		$scriptSort = new AppScriptSort($this->logger);
114
-		$sortedScripts = $scriptSort->sort($scripts, $scriptDeps);
115
-
116
-		$sortedScriptKeys = array_keys($sortedScripts);
117
-
118
-		// All apps still there
119
-		foreach ($scripts as $app => $_) {
120
-			$this->assertContains($app, $sortedScriptKeys);
121
-		}
122
-	}
21
+    private $logger;
22
+
23
+    protected function setUp(): void {
24
+        $this->logger = $this->getMockBuilder(LoggerInterface::class)
25
+            ->disableOriginalConstructor()
26
+            ->getMock();
27
+
28
+        parent::setUp();
29
+    }
30
+
31
+    public function testSort(): void {
32
+        $scripts = [
33
+            'first' => ['myFirstJSFile'],
34
+            'core' => [
35
+                'core/js/myFancyJSFile1',
36
+                'core/js/myFancyJSFile4',
37
+                'core/js/myFancyJSFile5',
38
+                'core/js/myFancyJSFile1',
39
+            ],
40
+            'files' => ['files/js/myFancyJSFile2'],
41
+            'myApp5' => ['myApp5/js/myApp5JSFile'],
42
+            'myApp' => ['myApp/js/myFancyJSFile3'],
43
+            'myApp4' => ['myApp4/js/myApp4JSFile'],
44
+            'myApp3' => ['myApp3/js/myApp3JSFile'],
45
+            'myApp2' => ['myApp2/js/myApp2JSFile'],
46
+        ];
47
+        $scriptDeps = [
48
+            'first' => new AppScriptDependency('first', ['core']),
49
+            'core' => new AppScriptDependency('core', ['core']),
50
+            'files' => new AppScriptDependency('files', ['core']),
51
+            'myApp5' => new AppScriptDependency('myApp5', ['myApp2']),
52
+            'myApp' => new AppScriptDependency('myApp', ['core']),
53
+            'myApp4' => new AppScriptDependency('myApp4', ['myApp3']),
54
+            'myApp3' => new AppScriptDependency('myApp3', ['myApp2']),
55
+            'myApp2' => new AppScriptDependency('myApp2', ['myApp']),
56
+        ];
57
+
58
+        // No circular dependency is detected and logged as an error
59
+        $this->logger->expects(self::never())->method('error');
60
+
61
+        $scriptSort = new AppScriptSort($this->logger);
62
+        $sortedScripts = $scriptSort->sort($scripts, $scriptDeps);
63
+
64
+        $sortedScriptKeys = array_keys($sortedScripts);
65
+
66
+        // Core should appear first
67
+        $this->assertEquals(
68
+            0,
69
+            array_search('core', $sortedScriptKeys, true)
70
+        );
71
+
72
+        // Dependencies should appear before their children
73
+        $this->assertLessThan(
74
+            array_search('files', $sortedScriptKeys, true),
75
+            array_search('core', $sortedScriptKeys, true)
76
+        );
77
+        $this->assertLessThan(
78
+            array_search('myApp2', $sortedScriptKeys, true),
79
+            array_search('myApp', $sortedScriptKeys, true)
80
+        );
81
+        $this->assertLessThan(
82
+            array_search('myApp3', $sortedScriptKeys, true),
83
+            array_search('myApp2', $sortedScriptKeys, true)
84
+        );
85
+        $this->assertLessThan(
86
+            array_search('myApp4', $sortedScriptKeys, true),
87
+            array_search('myApp3', $sortedScriptKeys, true)
88
+        );
89
+        $this->assertLessThan(
90
+            array_search('myApp5', $sortedScriptKeys, true),
91
+            array_search('myApp2', $sortedScriptKeys, true)
92
+        );
93
+
94
+        // All apps still there
95
+        foreach ($scripts as $app => $_) {
96
+            $this->assertContains($app, $sortedScriptKeys);
97
+        }
98
+    }
99
+
100
+    public function testSortCircularDependency(): void {
101
+        $scripts = [
102
+            'circular' => ['circular/js/file1'],
103
+            'dependency' => ['dependency/js/file2'],
104
+        ];
105
+        $scriptDeps = [
106
+            'circular' => new AppScriptDependency('circular', ['dependency']),
107
+            'dependency' => new AppScriptDependency('dependency', ['circular']),
108
+        ];
109
+
110
+        // A circular dependency is detected and logged as an error
111
+        $this->logger->expects(self::once())->method('error');
112
+
113
+        $scriptSort = new AppScriptSort($this->logger);
114
+        $sortedScripts = $scriptSort->sort($scripts, $scriptDeps);
115
+
116
+        $sortedScriptKeys = array_keys($sortedScripts);
117
+
118
+        // All apps still there
119
+        foreach ($scripts as $app => $_) {
120
+            $this->assertContains($app, $sortedScriptKeys);
121
+        }
122
+    }
123 123
 }
Please login to merge, or discard this patch.
tests/lib/Diagnostics/EventLoggerTest.php 1 patch
Indentation   +40 added lines, -40 removed lines patch added patch discarded remove patch
@@ -14,44 +14,44 @@
 block discarded – undo
14 14
 use Test\TestCase;
15 15
 
16 16
 class EventLoggerTest extends TestCase {
17
-	/** @var \OC\Diagnostics\EventLogger */
18
-	private $logger;
19
-
20
-	protected function setUp(): void {
21
-		parent::setUp();
22
-
23
-		$this->logger = new EventLogger(
24
-			$this->createMock(SystemConfig::class),
25
-			$this->createMock(LoggerInterface::class),
26
-			$this->createMock(Log::class)
27
-		);
28
-	}
29
-
30
-	public function testQueryLogger(): void {
31
-		// Module is not activated and this should not be logged
32
-		$this->logger->start('test1', 'testevent1');
33
-		$this->logger->end('test1');
34
-		$this->logger->log('test2', 'testevent2', microtime(true), microtime(true));
35
-		$events = $this->logger->getEvents();
36
-		$this->assertSame(0, sizeof($events));
37
-
38
-		// Activate module and log some query
39
-		$this->logger->activate();
40
-
41
-		// start one event
42
-		$this->logger->start('test3', 'testevent3');
43
-
44
-		// force log of another event
45
-		$this->logger->log('test4', 'testevent4', microtime(true), microtime(true));
46
-
47
-		// log started event
48
-		$this->logger->end('test3');
49
-
50
-		$events = $this->logger->getEvents();
51
-		$this->assertSame('test4', $events['test4']->getId());
52
-		$this->assertSame('testevent4', $events['test4']->getDescription());
53
-		$this->assertSame('test3', $events['test3']->getId());
54
-		$this->assertSame('testevent3', $events['test3']->getDescription());
55
-		$this->assertSame(2, sizeof($events));
56
-	}
17
+    /** @var \OC\Diagnostics\EventLogger */
18
+    private $logger;
19
+
20
+    protected function setUp(): void {
21
+        parent::setUp();
22
+
23
+        $this->logger = new EventLogger(
24
+            $this->createMock(SystemConfig::class),
25
+            $this->createMock(LoggerInterface::class),
26
+            $this->createMock(Log::class)
27
+        );
28
+    }
29
+
30
+    public function testQueryLogger(): void {
31
+        // Module is not activated and this should not be logged
32
+        $this->logger->start('test1', 'testevent1');
33
+        $this->logger->end('test1');
34
+        $this->logger->log('test2', 'testevent2', microtime(true), microtime(true));
35
+        $events = $this->logger->getEvents();
36
+        $this->assertSame(0, sizeof($events));
37
+
38
+        // Activate module and log some query
39
+        $this->logger->activate();
40
+
41
+        // start one event
42
+        $this->logger->start('test3', 'testevent3');
43
+
44
+        // force log of another event
45
+        $this->logger->log('test4', 'testevent4', microtime(true), microtime(true));
46
+
47
+        // log started event
48
+        $this->logger->end('test3');
49
+
50
+        $events = $this->logger->getEvents();
51
+        $this->assertSame('test4', $events['test4']->getId());
52
+        $this->assertSame('testevent4', $events['test4']->getDescription());
53
+        $this->assertSame('test3', $events['test3']->getId());
54
+        $this->assertSame('testevent3', $events['test3']->getDescription());
55
+        $this->assertSame(2, sizeof($events));
56
+    }
57 57
 }
Please login to merge, or discard this patch.
tests/lib/SetupCheck/CheckServerResponseTraitImplementation.php 1 patch
Indentation   +14 added lines, -14 removed lines patch added patch discarded remove patch
@@ -20,20 +20,20 @@
 block discarded – undo
20 20
  */
21 21
 class CheckServerResponseTraitImplementation {
22 22
 
23
-	use CheckServerResponseTrait {
24
-		CheckServerResponseTrait::getRequestOptions as public;
25
-		CheckServerResponseTrait::runRequest as public;
26
-		CheckServerResponseTrait::normalizeUrl as public;
27
-		CheckServerResponseTrait::getTestUrls as public;
28
-	}
23
+    use CheckServerResponseTrait {
24
+        CheckServerResponseTrait::getRequestOptions as public;
25
+        CheckServerResponseTrait::runRequest as public;
26
+        CheckServerResponseTrait::normalizeUrl as public;
27
+        CheckServerResponseTrait::getTestUrls as public;
28
+    }
29 29
 
30
-	public function __construct(
31
-		protected IL10N $l10n,
32
-		protected IConfig $config,
33
-		protected IURLGenerator $urlGenerator,
34
-		protected IClientService $clientService,
35
-		protected LoggerInterface $logger,
36
-	) {
37
-	}
30
+    public function __construct(
31
+        protected IL10N $l10n,
32
+        protected IConfig $config,
33
+        protected IURLGenerator $urlGenerator,
34
+        protected IClientService $clientService,
35
+        protected LoggerInterface $logger,
36
+    ) {
37
+    }
38 38
 
39 39
 }
Please login to merge, or discard this patch.
tests/lib/TemplateFunctionsTest.php 1 patch
Indentation   +221 added lines, -221 removed lines patch added patch discarded remove patch
@@ -8,269 +8,269 @@
 block discarded – undo
8 8
 namespace Test;
9 9
 
10 10
 class TemplateFunctionsTest extends \Test\TestCase {
11
-	protected function setUp(): void {
12
-		parent::setUp();
13
-
14
-		require_once \OC::$SERVERROOT . '/lib/private/Template/functions.php';
15
-	}
16
-
17
-	public function testPJavaScript(): void {
18
-		$this->expectOutputString('<img onload="alert(1)" />');
19
-		p('<img onload="alert(1)" />');
20
-	}
21
-
22
-	public function testPJavaScriptWithScriptTags(): void {
23
-		$this->expectOutputString('&lt;script&gt;alert(&#039;Hacked!&#039;);&lt;/script&gt;');
24
-		p("<script>alert('Hacked!');</script>");
25
-	}
26
-
27
-	public function testPNormalString(): void {
28
-		$string = 'This is a good string without HTML.';
29
-		$this->expectOutputString($string);
30
-		p($string);
31
-	}
32
-
33
-	public function testPrintUnescaped(): void {
34
-		$htmlString = "<script>alert('xss');</script>";
35
-		$this->expectOutputString($htmlString);
36
-		print_unescaped($htmlString);
37
-	}
38
-
39
-	public function testPrintUnescapedNormalString(): void {
40
-		$string = 'This is a good string!';
41
-		$this->expectOutputString($string);
42
-		print_unescaped($string);
43
-	}
44
-
45
-	public function testEmitScriptTagWithContent(): void {
46
-		$this->expectOutputRegex('/<script nonce="[^"]+">\nalert\(\)\n<\/script>\n?/');
47
-		emit_script_tag('', 'alert()');
48
-	}
49
-
50
-	public function testEmitScriptTagWithSource(): void {
51
-		$this->expectOutputRegex('/<script nonce=".*" defer src="some.js"><\/script>/');
52
-		emit_script_tag('some.js');
53
-	}
54
-
55
-	public function testEmitScriptTagWithModuleSource(): void {
56
-		$this->expectOutputRegex('/<script nonce=".*" defer src="some.mjs" type="module"><\/script>/');
57
-		emit_script_tag('some.mjs', '', 'module');
58
-	}
59
-
60
-	public function testEmitScriptLoadingTags(): void {
61
-		// Test mjs js and inline content
62
-		$pattern = '/src="some\.mjs"[^>]+type="module"[^>]*>.+\n'; // some.mjs with type = module
63
-		$pattern .= '<script[^>]+src="other\.js"[^>]*>.+\n'; // other.js as plain javascript
64
-		$pattern .= '<script[^>]*>\n?.*inline.*\n?<\/script>'; // inline content
65
-		$pattern .= '/'; // no flags
66
-
67
-		$this->expectOutputRegex($pattern);
68
-		emit_script_loading_tags([
69
-			'jsfiles' => ['some.mjs', 'other.js'],
70
-			'inline_ocjs' => '// inline'
71
-		]);
72
-	}
73
-
74
-	public function testEmitScriptLoadingTagsWithVersion(): void {
75
-		// Test mjs js and inline content
76
-		$pattern = '/src="some\.mjs\?v=ab123cd"[^>]+type="module"[^>]*>.+\n'; // some.mjs with type = module
77
-		$pattern .= '<script[^>]+src="other\.js\?v=12abc34"[^>]*>.+\n'; // other.js as plain javascript
78
-		$pattern .= '/'; // no flags
79
-
80
-		$this->expectOutputRegex($pattern);
81
-		emit_script_loading_tags([
82
-			'jsfiles' => ['some.mjs?v=ab123cd', 'other.js?v=12abc34'],
83
-		]);
84
-	}
85
-
86
-	// ---------------------------------------------------------------------------
87
-	// Test relative_modified_date with dates only
88
-	// ---------------------------------------------------------------------------
89
-	public function testRelativeDateToday(): void {
90
-		$currentTime = 1380703592;
91
-		$elementTime = $currentTime;
92
-		$result = (string)relative_modified_date($elementTime, $currentTime, true);
93
-
94
-		$this->assertEquals('today', $result);
95
-
96
-		// 2 hours ago is still today
97
-		$elementTime = $currentTime - 2 * 3600;
98
-		$result = (string)relative_modified_date($elementTime, $currentTime, true);
99
-
100
-		$this->assertEquals('today', $result);
101
-	}
102
-
103
-	public function testRelativeDateYesterday(): void {
104
-		$currentTime = 1380703592;
105
-		$elementTime = $currentTime - 24 * 3600;
106
-		$result = (string)relative_modified_date($elementTime, $currentTime, true);
107
-
108
-		$this->assertEquals('yesterday', $result);
109
-
110
-		// yesterday - 2 hours is still yesterday
111
-		$elementTime = $currentTime - 26 * 3600;
112
-		$result = (string)relative_modified_date($elementTime, $currentTime, true);
113
-
114
-		$this->assertEquals('yesterday', $result);
115
-	}
116
-
117
-	public function testRelativeDate2DaysAgo(): void {
118
-		$currentTime = 1380703592;
119
-		$elementTime = $currentTime - 48 * 3600;
120
-		$result = (string)relative_modified_date($elementTime, $currentTime, true);
11
+    protected function setUp(): void {
12
+        parent::setUp();
13
+
14
+        require_once \OC::$SERVERROOT . '/lib/private/Template/functions.php';
15
+    }
16
+
17
+    public function testPJavaScript(): void {
18
+        $this->expectOutputString('&lt;img onload=&quot;alert(1)&quot; /&gt;');
19
+        p('<img onload="alert(1)" />');
20
+    }
21
+
22
+    public function testPJavaScriptWithScriptTags(): void {
23
+        $this->expectOutputString('&lt;script&gt;alert(&#039;Hacked!&#039;);&lt;/script&gt;');
24
+        p("<script>alert('Hacked!');</script>");
25
+    }
26
+
27
+    public function testPNormalString(): void {
28
+        $string = 'This is a good string without HTML.';
29
+        $this->expectOutputString($string);
30
+        p($string);
31
+    }
32
+
33
+    public function testPrintUnescaped(): void {
34
+        $htmlString = "<script>alert('xss');</script>";
35
+        $this->expectOutputString($htmlString);
36
+        print_unescaped($htmlString);
37
+    }
38
+
39
+    public function testPrintUnescapedNormalString(): void {
40
+        $string = 'This is a good string!';
41
+        $this->expectOutputString($string);
42
+        print_unescaped($string);
43
+    }
44
+
45
+    public function testEmitScriptTagWithContent(): void {
46
+        $this->expectOutputRegex('/<script nonce="[^"]+">\nalert\(\)\n<\/script>\n?/');
47
+        emit_script_tag('', 'alert()');
48
+    }
49
+
50
+    public function testEmitScriptTagWithSource(): void {
51
+        $this->expectOutputRegex('/<script nonce=".*" defer src="some.js"><\/script>/');
52
+        emit_script_tag('some.js');
53
+    }
54
+
55
+    public function testEmitScriptTagWithModuleSource(): void {
56
+        $this->expectOutputRegex('/<script nonce=".*" defer src="some.mjs" type="module"><\/script>/');
57
+        emit_script_tag('some.mjs', '', 'module');
58
+    }
59
+
60
+    public function testEmitScriptLoadingTags(): void {
61
+        // Test mjs js and inline content
62
+        $pattern = '/src="some\.mjs"[^>]+type="module"[^>]*>.+\n'; // some.mjs with type = module
63
+        $pattern .= '<script[^>]+src="other\.js"[^>]*>.+\n'; // other.js as plain javascript
64
+        $pattern .= '<script[^>]*>\n?.*inline.*\n?<\/script>'; // inline content
65
+        $pattern .= '/'; // no flags
66
+
67
+        $this->expectOutputRegex($pattern);
68
+        emit_script_loading_tags([
69
+            'jsfiles' => ['some.mjs', 'other.js'],
70
+            'inline_ocjs' => '// inline'
71
+        ]);
72
+    }
73
+
74
+    public function testEmitScriptLoadingTagsWithVersion(): void {
75
+        // Test mjs js and inline content
76
+        $pattern = '/src="some\.mjs\?v=ab123cd"[^>]+type="module"[^>]*>.+\n'; // some.mjs with type = module
77
+        $pattern .= '<script[^>]+src="other\.js\?v=12abc34"[^>]*>.+\n'; // other.js as plain javascript
78
+        $pattern .= '/'; // no flags
79
+
80
+        $this->expectOutputRegex($pattern);
81
+        emit_script_loading_tags([
82
+            'jsfiles' => ['some.mjs?v=ab123cd', 'other.js?v=12abc34'],
83
+        ]);
84
+    }
85
+
86
+    // ---------------------------------------------------------------------------
87
+    // Test relative_modified_date with dates only
88
+    // ---------------------------------------------------------------------------
89
+    public function testRelativeDateToday(): void {
90
+        $currentTime = 1380703592;
91
+        $elementTime = $currentTime;
92
+        $result = (string)relative_modified_date($elementTime, $currentTime, true);
93
+
94
+        $this->assertEquals('today', $result);
95
+
96
+        // 2 hours ago is still today
97
+        $elementTime = $currentTime - 2 * 3600;
98
+        $result = (string)relative_modified_date($elementTime, $currentTime, true);
99
+
100
+        $this->assertEquals('today', $result);
101
+    }
102
+
103
+    public function testRelativeDateYesterday(): void {
104
+        $currentTime = 1380703592;
105
+        $elementTime = $currentTime - 24 * 3600;
106
+        $result = (string)relative_modified_date($elementTime, $currentTime, true);
107
+
108
+        $this->assertEquals('yesterday', $result);
109
+
110
+        // yesterday - 2 hours is still yesterday
111
+        $elementTime = $currentTime - 26 * 3600;
112
+        $result = (string)relative_modified_date($elementTime, $currentTime, true);
113
+
114
+        $this->assertEquals('yesterday', $result);
115
+    }
116
+
117
+    public function testRelativeDate2DaysAgo(): void {
118
+        $currentTime = 1380703592;
119
+        $elementTime = $currentTime - 48 * 3600;
120
+        $result = (string)relative_modified_date($elementTime, $currentTime, true);
121 121
 
122
-		$this->assertEquals('2 days ago', $result);
123
-
124
-		// 2 days ago minus 4 hours is still 2 days ago
125
-		$elementTime = $currentTime - 52 * 3600;
126
-		$result = (string)relative_modified_date($elementTime, $currentTime, true);
127
-
128
-		$this->assertEquals('2 days ago', $result);
129
-	}
122
+        $this->assertEquals('2 days ago', $result);
123
+
124
+        // 2 days ago minus 4 hours is still 2 days ago
125
+        $elementTime = $currentTime - 52 * 3600;
126
+        $result = (string)relative_modified_date($elementTime, $currentTime, true);
127
+
128
+        $this->assertEquals('2 days ago', $result);
129
+    }
130 130
 
131
-	public function testRelativeDateLastMonth(): void {
132
-		$currentTime = 1380703592;
133
-		$elementTime = $currentTime - 86400 * 31;
134
-		$result = (string)relative_modified_date($elementTime, $currentTime, true);
131
+    public function testRelativeDateLastMonth(): void {
132
+        $currentTime = 1380703592;
133
+        $elementTime = $currentTime - 86400 * 31;
134
+        $result = (string)relative_modified_date($elementTime, $currentTime, true);
135 135
 
136
-		$this->assertEquals('last month', $result);
136
+        $this->assertEquals('last month', $result);
137 137
 
138
-		$elementTime = $currentTime - 86400 * 35;
139
-		$result = (string)relative_modified_date($elementTime, $currentTime, true);
138
+        $elementTime = $currentTime - 86400 * 35;
139
+        $result = (string)relative_modified_date($elementTime, $currentTime, true);
140 140
 
141
-		$this->assertEquals('last month', $result);
142
-	}
141
+        $this->assertEquals('last month', $result);
142
+    }
143 143
 
144
-	public function testRelativeDateMonthsAgo(): void {
145
-		$currentTime = 1380703592;
146
-		$elementTime = $currentTime - 86400 * 65;
147
-		$result = (string)relative_modified_date($elementTime, $currentTime, true);
144
+    public function testRelativeDateMonthsAgo(): void {
145
+        $currentTime = 1380703592;
146
+        $elementTime = $currentTime - 86400 * 65;
147
+        $result = (string)relative_modified_date($elementTime, $currentTime, true);
148 148
 
149
-		$this->assertEquals('2 months ago', $result);
149
+        $this->assertEquals('2 months ago', $result);
150 150
 
151
-		$elementTime = $currentTime - 86400 * 130;
152
-		$result = (string)relative_modified_date($elementTime, $currentTime, true);
151
+        $elementTime = $currentTime - 86400 * 130;
152
+        $result = (string)relative_modified_date($elementTime, $currentTime, true);
153 153
 
154
-		$this->assertEquals('4 months ago', $result);
155
-	}
154
+        $this->assertEquals('4 months ago', $result);
155
+    }
156 156
 
157
-	public function testRelativeDateLastYear(): void {
158
-		$currentTime = 1380703592;
159
-		$elementTime = $currentTime - 86400 * 365;
160
-		$result = (string)relative_modified_date($elementTime, $currentTime, true);
157
+    public function testRelativeDateLastYear(): void {
158
+        $currentTime = 1380703592;
159
+        $elementTime = $currentTime - 86400 * 365;
160
+        $result = (string)relative_modified_date($elementTime, $currentTime, true);
161 161
 
162
-		$this->assertEquals('last year', $result);
162
+        $this->assertEquals('last year', $result);
163 163
 
164
-		$elementTime = $currentTime - 86400 * 450;
165
-		$result = (string)relative_modified_date($elementTime, $currentTime, true);
164
+        $elementTime = $currentTime - 86400 * 450;
165
+        $result = (string)relative_modified_date($elementTime, $currentTime, true);
166 166
 
167
-		$this->assertEquals('last year', $result);
168
-	}
167
+        $this->assertEquals('last year', $result);
168
+    }
169 169
 
170
-	public function testRelativeDateYearsAgo(): void {
171
-		$currentTime = 1380703592;
172
-		$elementTime = $currentTime - 86400 * 365.25 * 2;
173
-		$result = (string)relative_modified_date($elementTime, $currentTime, true);
170
+    public function testRelativeDateYearsAgo(): void {
171
+        $currentTime = 1380703592;
172
+        $elementTime = $currentTime - 86400 * 365.25 * 2;
173
+        $result = (string)relative_modified_date($elementTime, $currentTime, true);
174 174
 
175
-		$this->assertEquals('2 years ago', $result);
175
+        $this->assertEquals('2 years ago', $result);
176 176
 
177
-		$elementTime = $currentTime - 86400 * 365.25 * 3;
178
-		$result = (string)relative_modified_date($elementTime, $currentTime, true);
177
+        $elementTime = $currentTime - 86400 * 365.25 * 3;
178
+        $result = (string)relative_modified_date($elementTime, $currentTime, true);
179 179
 
180
-		$this->assertEquals('3 years ago', $result);
181
-	}
180
+        $this->assertEquals('3 years ago', $result);
181
+    }
182 182
 
183
-	// ---------------------------------------------------------------------------
184
-	// Test relative_modified_date with timestamps only (date + time value)
185
-	// ---------------------------------------------------------------------------
183
+    // ---------------------------------------------------------------------------
184
+    // Test relative_modified_date with timestamps only (date + time value)
185
+    // ---------------------------------------------------------------------------
186 186
 
187
-	public function testRelativeTimeSecondsAgo(): void {
188
-		$currentTime = 1380703592;
189
-		$elementTime = $currentTime - 5;
190
-		$result = (string)relative_modified_date($elementTime, $currentTime, false);
187
+    public function testRelativeTimeSecondsAgo(): void {
188
+        $currentTime = 1380703592;
189
+        $elementTime = $currentTime - 5;
190
+        $result = (string)relative_modified_date($elementTime, $currentTime, false);
191 191
 
192
-		$this->assertEquals('seconds ago', $result);
193
-	}
192
+        $this->assertEquals('seconds ago', $result);
193
+    }
194 194
 
195
-	public function testRelativeTimeMinutesAgo(): void {
196
-		$currentTime = 1380703592;
197
-		$elementTime = $currentTime - 190;
198
-		$result = (string)relative_modified_date($elementTime, $currentTime, false);
195
+    public function testRelativeTimeMinutesAgo(): void {
196
+        $currentTime = 1380703592;
197
+        $elementTime = $currentTime - 190;
198
+        $result = (string)relative_modified_date($elementTime, $currentTime, false);
199 199
 
200
-		$this->assertEquals('3 minutes ago', $result);
201
-	}
200
+        $this->assertEquals('3 minutes ago', $result);
201
+    }
202 202
 
203
-	public function testRelativeTimeHoursAgo(): void {
204
-		$currentTime = 1380703592;
205
-		$elementTime = $currentTime - 7500;
206
-		$result = (string)relative_modified_date($elementTime, $currentTime, false);
203
+    public function testRelativeTimeHoursAgo(): void {
204
+        $currentTime = 1380703592;
205
+        $elementTime = $currentTime - 7500;
206
+        $result = (string)relative_modified_date($elementTime, $currentTime, false);
207 207
 
208
-		$this->assertEquals('2 hours ago', $result);
209
-	}
208
+        $this->assertEquals('2 hours ago', $result);
209
+    }
210 210
 
211
-	public function testRelativeTime2DaysAgo(): void {
212
-		$currentTime = 1380703592;
213
-		$elementTime = $currentTime - 48 * 3600;
214
-		$result = (string)relative_modified_date($elementTime, $currentTime, false);
211
+    public function testRelativeTime2DaysAgo(): void {
212
+        $currentTime = 1380703592;
213
+        $elementTime = $currentTime - 48 * 3600;
214
+        $result = (string)relative_modified_date($elementTime, $currentTime, false);
215 215
 
216
-		$this->assertEquals('2 days ago', $result);
216
+        $this->assertEquals('2 days ago', $result);
217 217
 
218
-		// 2 days ago minus 4 hours is still 2 days ago
219
-		$elementTime = $currentTime - 52 * 3600;
220
-		$result = (string)relative_modified_date($elementTime, $currentTime, false);
218
+        // 2 days ago minus 4 hours is still 2 days ago
219
+        $elementTime = $currentTime - 52 * 3600;
220
+        $result = (string)relative_modified_date($elementTime, $currentTime, false);
221 221
 
222
-		$this->assertEquals('2 days ago', $result);
223
-	}
222
+        $this->assertEquals('2 days ago', $result);
223
+    }
224 224
 
225
-	public function testRelativeTimeLastMonth(): void {
226
-		$currentTime = 1380703592;
227
-		$elementTime = $currentTime - 86400 * 31;
228
-		$result = (string)relative_modified_date($elementTime, $currentTime, false);
225
+    public function testRelativeTimeLastMonth(): void {
226
+        $currentTime = 1380703592;
227
+        $elementTime = $currentTime - 86400 * 31;
228
+        $result = (string)relative_modified_date($elementTime, $currentTime, false);
229 229
 
230
-		$this->assertEquals('last month', $result);
230
+        $this->assertEquals('last month', $result);
231 231
 
232
-		$elementTime = $currentTime - 86400 * 35;
233
-		$result = (string)relative_modified_date($elementTime, $currentTime, false);
232
+        $elementTime = $currentTime - 86400 * 35;
233
+        $result = (string)relative_modified_date($elementTime, $currentTime, false);
234 234
 
235
-		$this->assertEquals('last month', $result);
236
-	}
235
+        $this->assertEquals('last month', $result);
236
+    }
237 237
 
238
-	public function testRelativeTimeMonthsAgo(): void {
239
-		$currentTime = 1380703592;
240
-		$elementTime = $currentTime - 86400 * 65;
241
-		$result = (string)relative_modified_date($elementTime, $currentTime, false);
238
+    public function testRelativeTimeMonthsAgo(): void {
239
+        $currentTime = 1380703592;
240
+        $elementTime = $currentTime - 86400 * 65;
241
+        $result = (string)relative_modified_date($elementTime, $currentTime, false);
242 242
 
243
-		$this->assertEquals('2 months ago', $result);
243
+        $this->assertEquals('2 months ago', $result);
244 244
 
245
-		$elementTime = $currentTime - 86400 * 130;
246
-		$result = (string)relative_modified_date($elementTime, $currentTime, false);
245
+        $elementTime = $currentTime - 86400 * 130;
246
+        $result = (string)relative_modified_date($elementTime, $currentTime, false);
247 247
 
248
-		$this->assertEquals('4 months ago', $result);
249
-	}
248
+        $this->assertEquals('4 months ago', $result);
249
+    }
250 250
 
251
-	public function testRelativeTimeLastYear(): void {
252
-		$currentTime = 1380703592;
253
-		$elementTime = $currentTime - 86400 * 365;
254
-		$result = (string)relative_modified_date($elementTime, $currentTime, false);
251
+    public function testRelativeTimeLastYear(): void {
252
+        $currentTime = 1380703592;
253
+        $elementTime = $currentTime - 86400 * 365;
254
+        $result = (string)relative_modified_date($elementTime, $currentTime, false);
255 255
 
256
-		$this->assertEquals('last year', $result);
256
+        $this->assertEquals('last year', $result);
257 257
 
258
-		$elementTime = $currentTime - 86400 * 450;
259
-		$result = (string)relative_modified_date($elementTime, $currentTime, false);
258
+        $elementTime = $currentTime - 86400 * 450;
259
+        $result = (string)relative_modified_date($elementTime, $currentTime, false);
260 260
 
261
-		$this->assertEquals('last year', $result);
262
-	}
261
+        $this->assertEquals('last year', $result);
262
+    }
263 263
 
264
-	public function testRelativeTimeYearsAgo(): void {
265
-		$currentTime = 1380703592;
266
-		$elementTime = $currentTime - 86400 * 365.25 * 2;
267
-		$result = (string)relative_modified_date($elementTime, $currentTime, false);
264
+    public function testRelativeTimeYearsAgo(): void {
265
+        $currentTime = 1380703592;
266
+        $elementTime = $currentTime - 86400 * 365.25 * 2;
267
+        $result = (string)relative_modified_date($elementTime, $currentTime, false);
268 268
 
269
-		$this->assertEquals('2 years ago', $result);
269
+        $this->assertEquals('2 years ago', $result);
270 270
 
271
-		$elementTime = $currentTime - 86400 * 365.25 * 3;
272
-		$result = (string)relative_modified_date($elementTime, $currentTime, false);
271
+        $elementTime = $currentTime - 86400 * 365.25 * 3;
272
+        $result = (string)relative_modified_date($elementTime, $currentTime, false);
273 273
 
274
-		$this->assertEquals('3 years ago', $result);
275
-	}
274
+        $this->assertEquals('3 years ago', $result);
275
+    }
276 276
 }
Please login to merge, or discard this patch.
tests/lib/Http/WellKnown/RequestManagerTest.php 1 patch
Indentation   +124 added lines, -124 removed lines patch added patch discarded remove patch
@@ -27,128 +27,128 @@
 block discarded – undo
27 27
 use function get_class;
28 28
 
29 29
 class RequestManagerTest extends TestCase {
30
-	/** @var Coordinator|MockObject */
31
-	private $coordinator;
32
-
33
-	/** @var IServerContainer|MockObject */
34
-	private $container;
35
-
36
-	/** @var MockObject|LoggerInterface */
37
-	private $logger;
38
-
39
-	/** @var RequestManager */
40
-	private $manager;
41
-
42
-	protected function setUp(): void {
43
-		parent::setUp();
44
-
45
-		$this->coordinator = $this->createMock(Coordinator::class);
46
-		$this->container = $this->createMock(IServerContainer::class);
47
-		$this->logger = $this->createMock(LoggerInterface::class);
48
-
49
-		$this->manager = new RequestManager(
50
-			$this->coordinator,
51
-			$this->container,
52
-			$this->logger,
53
-		);
54
-	}
55
-
56
-	public function testProcessAppsNotRegistered(): void {
57
-		$request = $this->createMock(IRequest::class);
58
-		$this->expectException(RuntimeException::class);
59
-
60
-		$this->manager->process('webfinger', $request);
61
-	}
62
-
63
-	public function testProcessNoHandlersRegistered(): void {
64
-		$request = $this->createMock(IRequest::class);
65
-		$registrationContext = $this->createMock(RegistrationContext::class);
66
-		$this->coordinator->expects(self::once())
67
-			->method('getRegistrationContext')
68
-			->willReturn($registrationContext);
69
-		$registrationContext->expects(self::once())
70
-			->method('getWellKnownHandlers')
71
-			->willReturn([]);
72
-
73
-		$response = $this->manager->process('webfinger', $request);
74
-
75
-		self::assertNull($response);
76
-	}
77
-
78
-	public function testProcessHandlerNotLoadable(): void {
79
-		$request = $this->createMock(IRequest::class);
80
-		$registrationContext = $this->createMock(RegistrationContext::class);
81
-		$this->coordinator->expects(self::once())
82
-			->method('getRegistrationContext')
83
-			->willReturn($registrationContext);
84
-		$handler = new class {
85
-		};
86
-		$registrationContext->expects(self::once())
87
-			->method('getWellKnownHandlers')
88
-			->willReturn([
89
-				new ServiceRegistration('test', get_class($handler)),
90
-			]);
91
-		$this->container->expects(self::once())
92
-			->method('get')
93
-			->with(get_class($handler))
94
-			->willThrowException(new QueryException(''));
95
-		$this->logger->expects(self::once())
96
-			->method('error');
97
-
98
-		$response = $this->manager->process('webfinger', $request);
99
-
100
-		self::assertNull($response);
101
-	}
102
-
103
-	public function testProcessHandlerOfWrongType(): void {
104
-		$request = $this->createMock(IRequest::class);
105
-		$registrationContext = $this->createMock(RegistrationContext::class);
106
-		$this->coordinator->expects(self::once())
107
-			->method('getRegistrationContext')
108
-			->willReturn($registrationContext);
109
-		$handler = new class {
110
-		};
111
-		$registrationContext->expects(self::once())
112
-			->method('getWellKnownHandlers')
113
-			->willReturn([
114
-				new ServiceRegistration('test', get_class($handler)),
115
-			]);
116
-		$this->container->expects(self::once())
117
-			->method('get')
118
-			->with(get_class($handler))
119
-			->willReturn($handler);
120
-		$this->logger->expects(self::once())
121
-			->method('error');
122
-
123
-		$response = $this->manager->process('webfinger', $request);
124
-
125
-		self::assertNull($response);
126
-	}
127
-
128
-	public function testProcess(): void {
129
-		$request = $this->createMock(IRequest::class);
130
-		$registrationContext = $this->createMock(RegistrationContext::class);
131
-		$this->coordinator->expects(self::once())
132
-			->method('getRegistrationContext')
133
-			->willReturn($registrationContext);
134
-		$handler = new class implements IHandler {
135
-			public function handle(string $service, IRequestContext $context, ?IResponse $previousResponse): ?IResponse {
136
-				return (new JrdResponse($service))->addAlias('alias');
137
-			}
138
-		};
139
-		$registrationContext->expects(self::once())
140
-			->method('getWellKnownHandlers')
141
-			->willReturn([
142
-				new ServiceRegistration('test', get_class($handler)),
143
-			]);
144
-		$this->container->expects(self::once())
145
-			->method('get')
146
-			->with(get_class($handler))
147
-			->willReturn($handler);
148
-
149
-		$response = $this->manager->process('webfinger', $request);
150
-
151
-		self::assertNotNull($response);
152
-		self::assertInstanceOf(JrdResponse::class, $response);
153
-	}
30
+    /** @var Coordinator|MockObject */
31
+    private $coordinator;
32
+
33
+    /** @var IServerContainer|MockObject */
34
+    private $container;
35
+
36
+    /** @var MockObject|LoggerInterface */
37
+    private $logger;
38
+
39
+    /** @var RequestManager */
40
+    private $manager;
41
+
42
+    protected function setUp(): void {
43
+        parent::setUp();
44
+
45
+        $this->coordinator = $this->createMock(Coordinator::class);
46
+        $this->container = $this->createMock(IServerContainer::class);
47
+        $this->logger = $this->createMock(LoggerInterface::class);
48
+
49
+        $this->manager = new RequestManager(
50
+            $this->coordinator,
51
+            $this->container,
52
+            $this->logger,
53
+        );
54
+    }
55
+
56
+    public function testProcessAppsNotRegistered(): void {
57
+        $request = $this->createMock(IRequest::class);
58
+        $this->expectException(RuntimeException::class);
59
+
60
+        $this->manager->process('webfinger', $request);
61
+    }
62
+
63
+    public function testProcessNoHandlersRegistered(): void {
64
+        $request = $this->createMock(IRequest::class);
65
+        $registrationContext = $this->createMock(RegistrationContext::class);
66
+        $this->coordinator->expects(self::once())
67
+            ->method('getRegistrationContext')
68
+            ->willReturn($registrationContext);
69
+        $registrationContext->expects(self::once())
70
+            ->method('getWellKnownHandlers')
71
+            ->willReturn([]);
72
+
73
+        $response = $this->manager->process('webfinger', $request);
74
+
75
+        self::assertNull($response);
76
+    }
77
+
78
+    public function testProcessHandlerNotLoadable(): void {
79
+        $request = $this->createMock(IRequest::class);
80
+        $registrationContext = $this->createMock(RegistrationContext::class);
81
+        $this->coordinator->expects(self::once())
82
+            ->method('getRegistrationContext')
83
+            ->willReturn($registrationContext);
84
+        $handler = new class {
85
+        };
86
+        $registrationContext->expects(self::once())
87
+            ->method('getWellKnownHandlers')
88
+            ->willReturn([
89
+                new ServiceRegistration('test', get_class($handler)),
90
+            ]);
91
+        $this->container->expects(self::once())
92
+            ->method('get')
93
+            ->with(get_class($handler))
94
+            ->willThrowException(new QueryException(''));
95
+        $this->logger->expects(self::once())
96
+            ->method('error');
97
+
98
+        $response = $this->manager->process('webfinger', $request);
99
+
100
+        self::assertNull($response);
101
+    }
102
+
103
+    public function testProcessHandlerOfWrongType(): void {
104
+        $request = $this->createMock(IRequest::class);
105
+        $registrationContext = $this->createMock(RegistrationContext::class);
106
+        $this->coordinator->expects(self::once())
107
+            ->method('getRegistrationContext')
108
+            ->willReturn($registrationContext);
109
+        $handler = new class {
110
+        };
111
+        $registrationContext->expects(self::once())
112
+            ->method('getWellKnownHandlers')
113
+            ->willReturn([
114
+                new ServiceRegistration('test', get_class($handler)),
115
+            ]);
116
+        $this->container->expects(self::once())
117
+            ->method('get')
118
+            ->with(get_class($handler))
119
+            ->willReturn($handler);
120
+        $this->logger->expects(self::once())
121
+            ->method('error');
122
+
123
+        $response = $this->manager->process('webfinger', $request);
124
+
125
+        self::assertNull($response);
126
+    }
127
+
128
+    public function testProcess(): void {
129
+        $request = $this->createMock(IRequest::class);
130
+        $registrationContext = $this->createMock(RegistrationContext::class);
131
+        $this->coordinator->expects(self::once())
132
+            ->method('getRegistrationContext')
133
+            ->willReturn($registrationContext);
134
+        $handler = new class implements IHandler {
135
+            public function handle(string $service, IRequestContext $context, ?IResponse $previousResponse): ?IResponse {
136
+                return (new JrdResponse($service))->addAlias('alias');
137
+            }
138
+        };
139
+        $registrationContext->expects(self::once())
140
+            ->method('getWellKnownHandlers')
141
+            ->willReturn([
142
+                new ServiceRegistration('test', get_class($handler)),
143
+            ]);
144
+        $this->container->expects(self::once())
145
+            ->method('get')
146
+            ->with(get_class($handler))
147
+            ->willReturn($handler);
148
+
149
+        $response = $this->manager->process('webfinger', $request);
150
+
151
+        self::assertNotNull($response);
152
+        self::assertInstanceOf(JrdResponse::class, $response);
153
+    }
154 154
 }
Please login to merge, or discard this patch.
tests/lib/Http/WellKnown/JrdResponseTest.php 1 patch
Indentation   +72 added lines, -72 removed lines patch added patch discarded remove patch
@@ -14,79 +14,79 @@
 block discarded – undo
14 14
 use Test\TestCase;
15 15
 
16 16
 class JrdResponseTest extends TestCase {
17
-	public function testEmptyToHttpResponse(): void {
18
-		$response = new JrdResponse('subject');
19
-		$httpResponse = $response->toHttpResponse();
17
+    public function testEmptyToHttpResponse(): void {
18
+        $response = new JrdResponse('subject');
19
+        $httpResponse = $response->toHttpResponse();
20 20
 
21
-		self::assertTrue($response->isEmpty());
22
-		self::assertInstanceOf(JSONResponse::class, $httpResponse);
23
-		/** @var JSONResponse $httpResponse */
24
-		self::assertEquals(
25
-			[
26
-				'subject' => 'subject',
27
-			],
28
-			$httpResponse->getData()
29
-		);
30
-	}
21
+        self::assertTrue($response->isEmpty());
22
+        self::assertInstanceOf(JSONResponse::class, $httpResponse);
23
+        /** @var JSONResponse $httpResponse */
24
+        self::assertEquals(
25
+            [
26
+                'subject' => 'subject',
27
+            ],
28
+            $httpResponse->getData()
29
+        );
30
+    }
31 31
 
32
-	public function testComplexToHttpResponse(): void {
33
-		$response = new JrdResponse('subject');
34
-		$response->addAlias('alias');
35
-		$response->addAlias('blias');
36
-		$response->addProperty('propa', 'a');
37
-		$response->addProperty('propb', null);
38
-		$response->setExpires('tomorrow');
39
-		$response->addLink('rel', null, null);
40
-		$response->addLink('rel', 'type', null);
41
-		$response->addLink('rel', 'type', 'href', ['title' => 'titlevalue']);
42
-		$response->addLink('rel', 'type', 'href', ['title' => 'titlevalue'], ['propx' => 'valx']);
43
-		$httpResponse = $response->toHttpResponse();
32
+    public function testComplexToHttpResponse(): void {
33
+        $response = new JrdResponse('subject');
34
+        $response->addAlias('alias');
35
+        $response->addAlias('blias');
36
+        $response->addProperty('propa', 'a');
37
+        $response->addProperty('propb', null);
38
+        $response->setExpires('tomorrow');
39
+        $response->addLink('rel', null, null);
40
+        $response->addLink('rel', 'type', null);
41
+        $response->addLink('rel', 'type', 'href', ['title' => 'titlevalue']);
42
+        $response->addLink('rel', 'type', 'href', ['title' => 'titlevalue'], ['propx' => 'valx']);
43
+        $httpResponse = $response->toHttpResponse();
44 44
 
45
-		self::assertFalse($response->isEmpty());
46
-		self::assertInstanceOf(JSONResponse::class, $httpResponse);
47
-		/** @var JSONResponse $httpResponse */
48
-		self::assertEquals(
49
-			[
50
-				'subject' => 'subject',
51
-				'aliases' => [
52
-					'alias',
53
-					'blias',
54
-				],
55
-				'properties' => [
56
-					'propa' => 'a',
57
-					'propb' => null,
58
-				],
59
-				'expires' => 'tomorrow',
60
-				'links' => [
61
-					[
62
-						'rel' => 'rel',
63
-					],
64
-					[
65
-						'rel' => 'rel',
66
-						'type' => 'type',
67
-					],
68
-					[
69
-						'rel' => 'rel',
70
-						'type' => 'type',
71
-						'href' => 'href',
72
-						'titles' => [
73
-							'title' => 'titlevalue',
74
-						],
75
-					],
76
-					[
77
-						'rel' => 'rel',
78
-						'type' => 'type',
79
-						'href' => 'href',
80
-						'titles' => [
81
-							'title' => 'titlevalue',
82
-						],
83
-						'properties' => [
84
-							'propx' => 'valx',
85
-						],
86
-					],
87
-				]
88
-			],
89
-			$httpResponse->getData()
90
-		);
91
-	}
45
+        self::assertFalse($response->isEmpty());
46
+        self::assertInstanceOf(JSONResponse::class, $httpResponse);
47
+        /** @var JSONResponse $httpResponse */
48
+        self::assertEquals(
49
+            [
50
+                'subject' => 'subject',
51
+                'aliases' => [
52
+                    'alias',
53
+                    'blias',
54
+                ],
55
+                'properties' => [
56
+                    'propa' => 'a',
57
+                    'propb' => null,
58
+                ],
59
+                'expires' => 'tomorrow',
60
+                'links' => [
61
+                    [
62
+                        'rel' => 'rel',
63
+                    ],
64
+                    [
65
+                        'rel' => 'rel',
66
+                        'type' => 'type',
67
+                    ],
68
+                    [
69
+                        'rel' => 'rel',
70
+                        'type' => 'type',
71
+                        'href' => 'href',
72
+                        'titles' => [
73
+                            'title' => 'titlevalue',
74
+                        ],
75
+                    ],
76
+                    [
77
+                        'rel' => 'rel',
78
+                        'type' => 'type',
79
+                        'href' => 'href',
80
+                        'titles' => [
81
+                            'title' => 'titlevalue',
82
+                        ],
83
+                        'properties' => [
84
+                            'propx' => 'valx',
85
+                        ],
86
+                    ],
87
+                ]
88
+            ],
89
+            $httpResponse->getData()
90
+        );
91
+    }
92 92
 }
Please login to merge, or discard this patch.
tests/lib/Http/WellKnown/GenericResponseTest.php 1 patch
Indentation   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -14,11 +14,11 @@
 block discarded – undo
14 14
 use Test\TestCase;
15 15
 
16 16
 class GenericResponseTest extends TestCase {
17
-	public function testToHttpResponse(): void {
18
-		$httpResponse = $this->createMock(JSONResponse::class);
17
+    public function testToHttpResponse(): void {
18
+        $httpResponse = $this->createMock(JSONResponse::class);
19 19
 
20
-		$response = new GenericResponse($httpResponse);
20
+        $response = new GenericResponse($httpResponse);
21 21
 
22
-		self::assertSame($httpResponse, $response->toHttpResponse());
23
-	}
22
+        self::assertSame($httpResponse, $response->toHttpResponse());
23
+    }
24 24
 }
Please login to merge, or discard this patch.