Completed
Push — master ( 38c8ea...c9712b )
by Joas
40:21
created
tests/lib/Security/RateLimiting/Backend/MemoryCacheBackendTest.php 1 patch
Indentation   +123 added lines, -123 removed lines patch added patch discarded remove patch
@@ -17,127 +17,127 @@
 block discarded – undo
17 17
 use Test\TestCase;
18 18
 
19 19
 class MemoryCacheBackendTest extends TestCase {
20
-	/** @var IConfig|\PHPUnit\Framework\MockObject\MockObject */
21
-	private $config;
22
-	/** @var ICacheFactory|\PHPUnit\Framework\MockObject\MockObject */
23
-	private $cacheFactory;
24
-	/** @var ITimeFactory|\PHPUnit\Framework\MockObject\MockObject */
25
-	private $timeFactory;
26
-	/** @var ICache|\PHPUnit\Framework\MockObject\MockObject */
27
-	private $cache;
28
-	/** @var MemoryCacheBackend */
29
-	private $memoryCache;
30
-
31
-	protected function setUp(): void {
32
-		parent::setUp();
33
-
34
-		$this->config = $this->createMock(IConfig::class);
35
-		$this->cacheFactory = $this->createMock(ICacheFactory::class);
36
-		$this->timeFactory = $this->createMock(ITimeFactory::class);
37
-		$this->cache = $this->createMock(ICache::class);
38
-
39
-		$this->cacheFactory
40
-			->expects($this->once())
41
-			->method('createDistributed')
42
-			->with('OC\Security\RateLimiting\Backend\MemoryCacheBackend')
43
-			->willReturn($this->cache);
44
-
45
-		$this->config->method('getSystemValueBool')
46
-			->with('ratelimit.protection.enabled')
47
-			->willReturn(true);
48
-
49
-		$this->memoryCache = new MemoryCacheBackend(
50
-			$this->config,
51
-			$this->cacheFactory,
52
-			$this->timeFactory
53
-		);
54
-	}
55
-
56
-	public function testGetAttemptsWithNoAttemptsBefore(): void {
57
-		$this->cache
58
-			->expects($this->once())
59
-			->method('get')
60
-			->with('eea460b8d756885099c7f0a4c083bf6a745069ee4a301984e726df58fd4510bffa2dac4b7fd5d835726a6753ffa8343ba31c7e902bbef78fc68c2e743667cb4b')
61
-			->willReturn(null);
62
-
63
-		$this->assertSame(0, $this->memoryCache->getAttempts('Method', 'User'));
64
-	}
65
-
66
-	public function testGetAttempts(): void {
67
-		$this->timeFactory
68
-			->expects($this->once())
69
-			->method('getTime')
70
-			->willReturn(210);
71
-		$this->cache
72
-			->expects($this->once())
73
-			->method('get')
74
-			->with('eea460b8d756885099c7f0a4c083bf6a745069ee4a301984e726df58fd4510bffa2dac4b7fd5d835726a6753ffa8343ba31c7e902bbef78fc68c2e743667cb4b')
75
-			->willReturn(json_encode([
76
-				'1',
77
-				'2',
78
-				'87',
79
-				'223',
80
-				'223',
81
-				'224',
82
-			]));
83
-
84
-		$this->assertSame(3, $this->memoryCache->getAttempts('Method', 'User'));
85
-	}
86
-
87
-	public function testRegisterAttemptWithNoAttemptsBefore(): void {
88
-		$this->timeFactory
89
-			->expects($this->once())
90
-			->method('getTime')
91
-			->willReturn(123);
92
-
93
-		$this->cache
94
-			->expects($this->once())
95
-			->method('get')
96
-			->with('eea460b8d756885099c7f0a4c083bf6a745069ee4a301984e726df58fd4510bffa2dac4b7fd5d835726a6753ffa8343ba31c7e902bbef78fc68c2e743667cb4b')
97
-			->willReturn(null);
98
-		$this->cache
99
-			->expects($this->once())
100
-			->method('set')
101
-			->with(
102
-				'eea460b8d756885099c7f0a4c083bf6a745069ee4a301984e726df58fd4510bffa2dac4b7fd5d835726a6753ffa8343ba31c7e902bbef78fc68c2e743667cb4b',
103
-				json_encode(['223'])
104
-			);
105
-
106
-		$this->memoryCache->registerAttempt('Method', 'User', 100);
107
-	}
108
-
109
-	public function testRegisterAttempt(): void {
110
-		$this->timeFactory
111
-			->expects($this->once())
112
-			->method('getTime')
113
-			->willReturn(86);
114
-
115
-		$this->cache
116
-			->expects($this->once())
117
-			->method('get')
118
-			->with('eea460b8d756885099c7f0a4c083bf6a745069ee4a301984e726df58fd4510bffa2dac4b7fd5d835726a6753ffa8343ba31c7e902bbef78fc68c2e743667cb4b')
119
-			->willReturn(json_encode([
120
-				'1',
121
-				'2',
122
-				'87',
123
-				'123',
124
-				'123',
125
-				'124',
126
-			]));
127
-		$this->cache
128
-			->expects($this->once())
129
-			->method('set')
130
-			->with(
131
-				'eea460b8d756885099c7f0a4c083bf6a745069ee4a301984e726df58fd4510bffa2dac4b7fd5d835726a6753ffa8343ba31c7e902bbef78fc68c2e743667cb4b',
132
-				json_encode([
133
-					'87',
134
-					'123',
135
-					'123',
136
-					'124',
137
-					'186',
138
-				])
139
-			);
140
-
141
-		$this->memoryCache->registerAttempt('Method', 'User', 100);
142
-	}
20
+    /** @var IConfig|\PHPUnit\Framework\MockObject\MockObject */
21
+    private $config;
22
+    /** @var ICacheFactory|\PHPUnit\Framework\MockObject\MockObject */
23
+    private $cacheFactory;
24
+    /** @var ITimeFactory|\PHPUnit\Framework\MockObject\MockObject */
25
+    private $timeFactory;
26
+    /** @var ICache|\PHPUnit\Framework\MockObject\MockObject */
27
+    private $cache;
28
+    /** @var MemoryCacheBackend */
29
+    private $memoryCache;
30
+
31
+    protected function setUp(): void {
32
+        parent::setUp();
33
+
34
+        $this->config = $this->createMock(IConfig::class);
35
+        $this->cacheFactory = $this->createMock(ICacheFactory::class);
36
+        $this->timeFactory = $this->createMock(ITimeFactory::class);
37
+        $this->cache = $this->createMock(ICache::class);
38
+
39
+        $this->cacheFactory
40
+            ->expects($this->once())
41
+            ->method('createDistributed')
42
+            ->with('OC\Security\RateLimiting\Backend\MemoryCacheBackend')
43
+            ->willReturn($this->cache);
44
+
45
+        $this->config->method('getSystemValueBool')
46
+            ->with('ratelimit.protection.enabled')
47
+            ->willReturn(true);
48
+
49
+        $this->memoryCache = new MemoryCacheBackend(
50
+            $this->config,
51
+            $this->cacheFactory,
52
+            $this->timeFactory
53
+        );
54
+    }
55
+
56
+    public function testGetAttemptsWithNoAttemptsBefore(): void {
57
+        $this->cache
58
+            ->expects($this->once())
59
+            ->method('get')
60
+            ->with('eea460b8d756885099c7f0a4c083bf6a745069ee4a301984e726df58fd4510bffa2dac4b7fd5d835726a6753ffa8343ba31c7e902bbef78fc68c2e743667cb4b')
61
+            ->willReturn(null);
62
+
63
+        $this->assertSame(0, $this->memoryCache->getAttempts('Method', 'User'));
64
+    }
65
+
66
+    public function testGetAttempts(): void {
67
+        $this->timeFactory
68
+            ->expects($this->once())
69
+            ->method('getTime')
70
+            ->willReturn(210);
71
+        $this->cache
72
+            ->expects($this->once())
73
+            ->method('get')
74
+            ->with('eea460b8d756885099c7f0a4c083bf6a745069ee4a301984e726df58fd4510bffa2dac4b7fd5d835726a6753ffa8343ba31c7e902bbef78fc68c2e743667cb4b')
75
+            ->willReturn(json_encode([
76
+                '1',
77
+                '2',
78
+                '87',
79
+                '223',
80
+                '223',
81
+                '224',
82
+            ]));
83
+
84
+        $this->assertSame(3, $this->memoryCache->getAttempts('Method', 'User'));
85
+    }
86
+
87
+    public function testRegisterAttemptWithNoAttemptsBefore(): void {
88
+        $this->timeFactory
89
+            ->expects($this->once())
90
+            ->method('getTime')
91
+            ->willReturn(123);
92
+
93
+        $this->cache
94
+            ->expects($this->once())
95
+            ->method('get')
96
+            ->with('eea460b8d756885099c7f0a4c083bf6a745069ee4a301984e726df58fd4510bffa2dac4b7fd5d835726a6753ffa8343ba31c7e902bbef78fc68c2e743667cb4b')
97
+            ->willReturn(null);
98
+        $this->cache
99
+            ->expects($this->once())
100
+            ->method('set')
101
+            ->with(
102
+                'eea460b8d756885099c7f0a4c083bf6a745069ee4a301984e726df58fd4510bffa2dac4b7fd5d835726a6753ffa8343ba31c7e902bbef78fc68c2e743667cb4b',
103
+                json_encode(['223'])
104
+            );
105
+
106
+        $this->memoryCache->registerAttempt('Method', 'User', 100);
107
+    }
108
+
109
+    public function testRegisterAttempt(): void {
110
+        $this->timeFactory
111
+            ->expects($this->once())
112
+            ->method('getTime')
113
+            ->willReturn(86);
114
+
115
+        $this->cache
116
+            ->expects($this->once())
117
+            ->method('get')
118
+            ->with('eea460b8d756885099c7f0a4c083bf6a745069ee4a301984e726df58fd4510bffa2dac4b7fd5d835726a6753ffa8343ba31c7e902bbef78fc68c2e743667cb4b')
119
+            ->willReturn(json_encode([
120
+                '1',
121
+                '2',
122
+                '87',
123
+                '123',
124
+                '123',
125
+                '124',
126
+            ]));
127
+        $this->cache
128
+            ->expects($this->once())
129
+            ->method('set')
130
+            ->with(
131
+                'eea460b8d756885099c7f0a4c083bf6a745069ee4a301984e726df58fd4510bffa2dac4b7fd5d835726a6753ffa8343ba31c7e902bbef78fc68c2e743667cb4b',
132
+                json_encode([
133
+                    '87',
134
+                    '123',
135
+                    '123',
136
+                    '124',
137
+                    '186',
138
+                ])
139
+            );
140
+
141
+        $this->memoryCache->registerAttempt('Method', 'User', 100);
142
+    }
143 143
 }
Please login to merge, or discard this patch.
tests/lib/EventSourceFactoryTest.php 1 patch
Indentation   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -11,11 +11,11 @@
 block discarded – undo
11 11
 use OCP\IRequest;
12 12
 
13 13
 class EventSourceFactoryTest extends TestCase {
14
-	public function testCreate(): void {
15
-		$request = $this->createMock(IRequest::class);
16
-		$factory = new EventSourceFactory($request);
14
+    public function testCreate(): void {
15
+        $request = $this->createMock(IRequest::class);
16
+        $factory = new EventSourceFactory($request);
17 17
 
18
-		$instance = $factory->create();
19
-		$this->assertInstanceOf(IEventSource::class, $instance);
20
-	}
18
+        $instance = $factory->create();
19
+        $this->assertInstanceOf(IEventSource::class, $instance);
20
+    }
21 21
 }
Please login to merge, or discard this patch.
tests/lib/Template/JSResourceLocatorTest.php 1 patch
Indentation   +162 added lines, -162 removed lines patch added patch discarded remove patch
@@ -17,166 +17,166 @@
 block discarded – undo
17 17
 use Psr\Log\LoggerInterface;
18 18
 
19 19
 class JSResourceLocatorTest extends \Test\TestCase {
20
-	/** @var IAppData|\PHPUnit\Framework\MockObject\MockObject */
21
-	protected $appData;
22
-	/** @var IURLGenerator|\PHPUnit\Framework\MockObject\MockObject */
23
-	protected $urlGenerator;
24
-	/** @var SystemConfig|\PHPUnit\Framework\MockObject\MockObject */
25
-	protected $config;
26
-	/** @var ICacheFactory|\PHPUnit\Framework\MockObject\MockObject */
27
-	protected $cacheFactory;
28
-	/** @var LoggerInterface|\PHPUnit\Framework\MockObject\MockObject */
29
-	protected $logger;
30
-	/** @var IAppManager|\PHPUnit\Framework\MockObject\MockObject */
31
-	protected $appManager;
32
-
33
-	protected function setUp(): void {
34
-		parent::setUp();
35
-
36
-		$this->appData = $this->createMock(IAppData::class);
37
-		$this->urlGenerator = $this->createMock(IURLGenerator::class);
38
-		$this->config = $this->createMock(SystemConfig::class);
39
-		$this->cacheFactory = $this->createMock(ICacheFactory::class);
40
-		$this->logger = $this->createMock(LoggerInterface::class);
41
-		$this->appManager = $this->createMock(IAppManager::class);
42
-	}
43
-
44
-	private function jsResourceLocator() {
45
-		$jsCombiner = new JSCombiner(
46
-			$this->appData,
47
-			$this->urlGenerator,
48
-			$this->cacheFactory,
49
-			$this->config,
50
-			$this->logger
51
-		);
52
-		return new JSResourceLocator(
53
-			$this->logger,
54
-			$jsCombiner,
55
-			$this->appManager,
56
-		);
57
-	}
58
-
59
-	private function rrmdir($directory) {
60
-		$files = array_diff(scandir($directory), ['.','..']);
61
-		foreach ($files as $file) {
62
-			if (is_dir($directory . '/' . $file)) {
63
-				$this->rrmdir($directory . '/' . $file);
64
-			} else {
65
-				unlink($directory . '/' . $file);
66
-			}
67
-		}
68
-		return rmdir($directory);
69
-	}
70
-
71
-	private function randomString() {
72
-		return sha1(uniqid(mt_rand(), true));
73
-	}
74
-
75
-	public function testFindWithAppPathSymlink(): void {
76
-		$appName = 'test-js-app';
77
-
78
-		// First create new apps path, and a symlink to it
79
-		$apps_dirname = $this->randomString();
80
-		$new_apps_path = sys_get_temp_dir() . '/' . $apps_dirname;
81
-		$new_apps_path_symlink = $new_apps_path . '_link';
82
-		$this->assertTrue((
83
-			mkdir($new_apps_path) && symlink($apps_dirname, $new_apps_path_symlink)
84
-		), 'Setup of apps path failed');
85
-
86
-		// Create an app within that path
87
-		$this->assertTrue((
88
-			mkdir($new_apps_path . '/' . $appName) && touch($new_apps_path . '/' . $appName . '/' . 'test-file.js')
89
-		), 'Setup of app within the new apps path failed');
90
-
91
-		// Use the symlink as the app path
92
-		$this->appManager->expects($this->once())
93
-			->method('getAppPath')
94
-			->with($appName)
95
-			->willReturn("$new_apps_path_symlink/$appName");
96
-		$this->appManager->expects($this->once())
97
-			->method('getAppWebPath')
98
-			->with($appName)
99
-			->willReturn("/js-apps-test/$appName");
100
-
101
-		// Run the tests
102
-		$locator = $this->jsResourceLocator();
103
-		$locator->find(["$appName/test-file"]);
104
-
105
-		$resources = $locator->getResources();
106
-		$this->assertCount(1, $resources);
107
-		$resource = $resources[0];
108
-		$this->assertCount(3, $resource);
109
-		$root = $resource[0];
110
-		$webRoot = $resource[1];
111
-		$file = $resource[2];
112
-
113
-		$expectedRoot = $new_apps_path;
114
-		$expectedWebRoot = \OC::$WEBROOT . '/js-apps-test';
115
-		$expectedFile = $appName . '/test-file.js';
116
-
117
-		$this->assertEquals($expectedRoot, $root,
118
-			'Ensure the app path symlink is resolved into the real path');
119
-		$this->assertEquals($expectedWebRoot, $webRoot);
120
-		$this->assertEquals($expectedFile, $file);
121
-
122
-		unlink($new_apps_path_symlink);
123
-		$this->rrmdir($new_apps_path);
124
-	}
125
-
126
-	public function testNotExistingTranslationHandledSilent(): void {
127
-		$this->appManager->expects($this->once())
128
-			->method('getAppPath')
129
-			->with('core')
130
-			->willThrowException(new AppPathNotFoundException());
131
-		$this->appManager->expects($this->atMost(1))
132
-			->method('getAppWebPath')
133
-			->with('core')
134
-			->willThrowException(new AppPathNotFoundException());
135
-		// Assert logger is not called
136
-		$this->logger->expects($this->never())
137
-			->method('error');
138
-
139
-		// Run the tests
140
-		$locator = $this->jsResourceLocator();
141
-		$locator->find(['core/l10n/en.js']);
142
-
143
-		$resources = $locator->getResources();
144
-		$this->assertCount(0, $resources);
145
-	}
146
-
147
-	public function testFindModuleJSWithFallback(): void {
148
-		// First create new apps path, and a symlink to it
149
-		$apps_dirname = $this->randomString();
150
-		$new_apps_path = sys_get_temp_dir() . '/' . $apps_dirname;
151
-		mkdir($new_apps_path);
152
-
153
-		// Create an app within that path
154
-		mkdir("$new_apps_path/test-js-app");
155
-		touch("$new_apps_path/test-js-app/module.mjs");
156
-		touch("$new_apps_path/test-js-app/both.mjs");
157
-		touch("$new_apps_path/test-js-app/both.js");
158
-		touch("$new_apps_path/test-js-app/plain.js");
159
-
160
-		// Use the app path
161
-		$this->appManager->expects($this->any())
162
-			->method('getAppPath')
163
-			->with('test-js-app')
164
-			->willReturn("$new_apps_path/test-js-app");
165
-
166
-		$locator = $this->jsResourceLocator();
167
-		$locator->find(['test-js-app/module', 'test-js-app/both', 'test-js-app/plain']);
168
-
169
-		$resources = $locator->getResources();
170
-		$this->assertCount(3, $resources);
171
-
172
-		$expectedWebRoot = \OC::$WEBROOT . '/js-apps-test/test-js-app';
173
-		$expectedFiles = ['module.mjs', 'both.mjs', 'plain.js'];
174
-
175
-		for ($idx = 0; $idx++; $idx < 3) {
176
-			$this->assertEquals($expectedWebRoot, $resources[$idx][1]);
177
-			$this->assertEquals($expectedFiles[$idx], $resources[$idx][2]);
178
-		}
179
-
180
-		$this->rrmdir($new_apps_path);
181
-	}
20
+    /** @var IAppData|\PHPUnit\Framework\MockObject\MockObject */
21
+    protected $appData;
22
+    /** @var IURLGenerator|\PHPUnit\Framework\MockObject\MockObject */
23
+    protected $urlGenerator;
24
+    /** @var SystemConfig|\PHPUnit\Framework\MockObject\MockObject */
25
+    protected $config;
26
+    /** @var ICacheFactory|\PHPUnit\Framework\MockObject\MockObject */
27
+    protected $cacheFactory;
28
+    /** @var LoggerInterface|\PHPUnit\Framework\MockObject\MockObject */
29
+    protected $logger;
30
+    /** @var IAppManager|\PHPUnit\Framework\MockObject\MockObject */
31
+    protected $appManager;
32
+
33
+    protected function setUp(): void {
34
+        parent::setUp();
35
+
36
+        $this->appData = $this->createMock(IAppData::class);
37
+        $this->urlGenerator = $this->createMock(IURLGenerator::class);
38
+        $this->config = $this->createMock(SystemConfig::class);
39
+        $this->cacheFactory = $this->createMock(ICacheFactory::class);
40
+        $this->logger = $this->createMock(LoggerInterface::class);
41
+        $this->appManager = $this->createMock(IAppManager::class);
42
+    }
43
+
44
+    private function jsResourceLocator() {
45
+        $jsCombiner = new JSCombiner(
46
+            $this->appData,
47
+            $this->urlGenerator,
48
+            $this->cacheFactory,
49
+            $this->config,
50
+            $this->logger
51
+        );
52
+        return new JSResourceLocator(
53
+            $this->logger,
54
+            $jsCombiner,
55
+            $this->appManager,
56
+        );
57
+    }
58
+
59
+    private function rrmdir($directory) {
60
+        $files = array_diff(scandir($directory), ['.','..']);
61
+        foreach ($files as $file) {
62
+            if (is_dir($directory . '/' . $file)) {
63
+                $this->rrmdir($directory . '/' . $file);
64
+            } else {
65
+                unlink($directory . '/' . $file);
66
+            }
67
+        }
68
+        return rmdir($directory);
69
+    }
70
+
71
+    private function randomString() {
72
+        return sha1(uniqid(mt_rand(), true));
73
+    }
74
+
75
+    public function testFindWithAppPathSymlink(): void {
76
+        $appName = 'test-js-app';
77
+
78
+        // First create new apps path, and a symlink to it
79
+        $apps_dirname = $this->randomString();
80
+        $new_apps_path = sys_get_temp_dir() . '/' . $apps_dirname;
81
+        $new_apps_path_symlink = $new_apps_path . '_link';
82
+        $this->assertTrue((
83
+            mkdir($new_apps_path) && symlink($apps_dirname, $new_apps_path_symlink)
84
+        ), 'Setup of apps path failed');
85
+
86
+        // Create an app within that path
87
+        $this->assertTrue((
88
+            mkdir($new_apps_path . '/' . $appName) && touch($new_apps_path . '/' . $appName . '/' . 'test-file.js')
89
+        ), 'Setup of app within the new apps path failed');
90
+
91
+        // Use the symlink as the app path
92
+        $this->appManager->expects($this->once())
93
+            ->method('getAppPath')
94
+            ->with($appName)
95
+            ->willReturn("$new_apps_path_symlink/$appName");
96
+        $this->appManager->expects($this->once())
97
+            ->method('getAppWebPath')
98
+            ->with($appName)
99
+            ->willReturn("/js-apps-test/$appName");
100
+
101
+        // Run the tests
102
+        $locator = $this->jsResourceLocator();
103
+        $locator->find(["$appName/test-file"]);
104
+
105
+        $resources = $locator->getResources();
106
+        $this->assertCount(1, $resources);
107
+        $resource = $resources[0];
108
+        $this->assertCount(3, $resource);
109
+        $root = $resource[0];
110
+        $webRoot = $resource[1];
111
+        $file = $resource[2];
112
+
113
+        $expectedRoot = $new_apps_path;
114
+        $expectedWebRoot = \OC::$WEBROOT . '/js-apps-test';
115
+        $expectedFile = $appName . '/test-file.js';
116
+
117
+        $this->assertEquals($expectedRoot, $root,
118
+            'Ensure the app path symlink is resolved into the real path');
119
+        $this->assertEquals($expectedWebRoot, $webRoot);
120
+        $this->assertEquals($expectedFile, $file);
121
+
122
+        unlink($new_apps_path_symlink);
123
+        $this->rrmdir($new_apps_path);
124
+    }
125
+
126
+    public function testNotExistingTranslationHandledSilent(): void {
127
+        $this->appManager->expects($this->once())
128
+            ->method('getAppPath')
129
+            ->with('core')
130
+            ->willThrowException(new AppPathNotFoundException());
131
+        $this->appManager->expects($this->atMost(1))
132
+            ->method('getAppWebPath')
133
+            ->with('core')
134
+            ->willThrowException(new AppPathNotFoundException());
135
+        // Assert logger is not called
136
+        $this->logger->expects($this->never())
137
+            ->method('error');
138
+
139
+        // Run the tests
140
+        $locator = $this->jsResourceLocator();
141
+        $locator->find(['core/l10n/en.js']);
142
+
143
+        $resources = $locator->getResources();
144
+        $this->assertCount(0, $resources);
145
+    }
146
+
147
+    public function testFindModuleJSWithFallback(): void {
148
+        // First create new apps path, and a symlink to it
149
+        $apps_dirname = $this->randomString();
150
+        $new_apps_path = sys_get_temp_dir() . '/' . $apps_dirname;
151
+        mkdir($new_apps_path);
152
+
153
+        // Create an app within that path
154
+        mkdir("$new_apps_path/test-js-app");
155
+        touch("$new_apps_path/test-js-app/module.mjs");
156
+        touch("$new_apps_path/test-js-app/both.mjs");
157
+        touch("$new_apps_path/test-js-app/both.js");
158
+        touch("$new_apps_path/test-js-app/plain.js");
159
+
160
+        // Use the app path
161
+        $this->appManager->expects($this->any())
162
+            ->method('getAppPath')
163
+            ->with('test-js-app')
164
+            ->willReturn("$new_apps_path/test-js-app");
165
+
166
+        $locator = $this->jsResourceLocator();
167
+        $locator->find(['test-js-app/module', 'test-js-app/both', 'test-js-app/plain']);
168
+
169
+        $resources = $locator->getResources();
170
+        $this->assertCount(3, $resources);
171
+
172
+        $expectedWebRoot = \OC::$WEBROOT . '/js-apps-test/test-js-app';
173
+        $expectedFiles = ['module.mjs', 'both.mjs', 'plain.js'];
174
+
175
+        for ($idx = 0; $idx++; $idx < 3) {
176
+            $this->assertEquals($expectedWebRoot, $resources[$idx][1]);
177
+            $this->assertEquals($expectedFiles[$idx], $resources[$idx][2]);
178
+        }
179
+
180
+        $this->rrmdir($new_apps_path);
181
+    }
182 182
 }
Please login to merge, or discard this patch.
tests/lib/Talk/ConversationOptionsTest.php 1 patch
Indentation   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -13,9 +13,9 @@
 block discarded – undo
13 13
 use Test\TestCase;
14 14
 
15 15
 class ConversationOptionsTest extends TestCase {
16
-	public function testDefaults(): void {
17
-		ConversationOptions::default();
16
+    public function testDefaults(): void {
17
+        ConversationOptions::default();
18 18
 
19
-		$this->addToAssertionCount(1);
20
-	}
19
+        $this->addToAssertionCount(1);
20
+    }
21 21
 }
Please login to merge, or discard this patch.
tests/lib/Talk/BrokerTest.php 1 patch
Indentation   +110 added lines, -110 removed lines patch added patch discarded remove patch
@@ -22,114 +22,114 @@
 block discarded – undo
22 22
 use Test\TestCase;
23 23
 
24 24
 class BrokerTest extends TestCase {
25
-	private Coordinator $coordinator;
26
-
27
-	private IServerContainer $container;
28
-
29
-	private LoggerInterface $logger;
30
-
31
-	private Broker $broker;
32
-
33
-	protected function setUp(): void {
34
-		parent::setUp();
35
-
36
-		$this->coordinator = $this->createMock(Coordinator::class);
37
-		$this->container = $this->createMock(IServerContainer::class);
38
-		$this->logger = $this->createMock(LoggerInterface::class);
39
-
40
-		$this->broker = new Broker(
41
-			$this->coordinator,
42
-			$this->container,
43
-			$this->logger,
44
-		);
45
-	}
46
-
47
-	public function testHasNoBackendCalledTooEarly(): void {
48
-		$this->expectException(RuntimeException::class);
49
-
50
-		$this->broker->hasBackend();
51
-	}
52
-
53
-	public function testHasNoBackend(): void {
54
-		$this->coordinator->expects(self::once())
55
-			->method('getRegistrationContext')
56
-			->willReturn($this->createMock(RegistrationContext::class));
57
-
58
-		self::assertFalse(
59
-			$this->broker->hasBackend()
60
-		);
61
-	}
62
-
63
-	public function testHasFaultyBackend(): void {
64
-		$fakeTalkServiceClass = '\\OCA\\Spreed\\TalkBackend';
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('getTalkBackendRegistration')
71
-			->willReturn(new ServiceRegistration('spreed', $fakeTalkServiceClass));
72
-		$this->container->expects(self::once())
73
-			->method('get')
74
-			->willThrowException(new QueryException());
75
-		$this->logger->expects(self::once())
76
-			->method('error');
77
-
78
-		self::assertFalse(
79
-			$this->broker->hasBackend()
80
-		);
81
-	}
82
-
83
-	public function testHasBackend(): void {
84
-		$fakeTalkServiceClass = '\\OCA\\Spreed\\TalkBackend';
85
-		$registrationContext = $this->createMock(RegistrationContext::class);
86
-		$this->coordinator->expects(self::once())
87
-			->method('getRegistrationContext')
88
-			->willReturn($registrationContext);
89
-		$registrationContext->expects(self::once())
90
-			->method('getTalkBackendRegistration')
91
-			->willReturn(new ServiceRegistration('spreed', $fakeTalkServiceClass));
92
-		$talkService = $this->createMock(ITalkBackend::class);
93
-		$this->container->expects(self::once())
94
-			->method('get')
95
-			->with($fakeTalkServiceClass)
96
-			->willReturn($talkService);
97
-
98
-		self::assertTrue(
99
-			$this->broker->hasBackend()
100
-		);
101
-	}
102
-
103
-	public function testNewConversationOptions(): void {
104
-		$this->broker->newConversationOptions();
105
-
106
-		// Nothing to assert
107
-		$this->addToAssertionCount(1);
108
-	}
109
-
110
-	public function testCreateConversation(): void {
111
-		$fakeTalkServiceClass = '\\OCA\\Spreed\\TalkBackend';
112
-		$registrationContext = $this->createMock(RegistrationContext::class);
113
-		$this->coordinator->expects(self::once())
114
-			->method('getRegistrationContext')
115
-			->willReturn($registrationContext);
116
-		$registrationContext->expects(self::once())
117
-			->method('getTalkBackendRegistration')
118
-			->willReturn(new ServiceRegistration('spreed', $fakeTalkServiceClass));
119
-		$talkService = $this->createMock(ITalkBackend::class);
120
-		$this->container->expects(self::once())
121
-			->method('get')
122
-			->with($fakeTalkServiceClass)
123
-			->willReturn($talkService);
124
-		$options = $this->createMock(IConversationOptions::class);
125
-		$talkService->expects(self::once())
126
-			->method('createConversation')
127
-			->with('Watercooler', [], $options);
128
-
129
-		$this->broker->createConversation(
130
-			'Watercooler',
131
-			[],
132
-			$options
133
-		);
134
-	}
25
+    private Coordinator $coordinator;
26
+
27
+    private IServerContainer $container;
28
+
29
+    private LoggerInterface $logger;
30
+
31
+    private Broker $broker;
32
+
33
+    protected function setUp(): void {
34
+        parent::setUp();
35
+
36
+        $this->coordinator = $this->createMock(Coordinator::class);
37
+        $this->container = $this->createMock(IServerContainer::class);
38
+        $this->logger = $this->createMock(LoggerInterface::class);
39
+
40
+        $this->broker = new Broker(
41
+            $this->coordinator,
42
+            $this->container,
43
+            $this->logger,
44
+        );
45
+    }
46
+
47
+    public function testHasNoBackendCalledTooEarly(): void {
48
+        $this->expectException(RuntimeException::class);
49
+
50
+        $this->broker->hasBackend();
51
+    }
52
+
53
+    public function testHasNoBackend(): void {
54
+        $this->coordinator->expects(self::once())
55
+            ->method('getRegistrationContext')
56
+            ->willReturn($this->createMock(RegistrationContext::class));
57
+
58
+        self::assertFalse(
59
+            $this->broker->hasBackend()
60
+        );
61
+    }
62
+
63
+    public function testHasFaultyBackend(): void {
64
+        $fakeTalkServiceClass = '\\OCA\\Spreed\\TalkBackend';
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('getTalkBackendRegistration')
71
+            ->willReturn(new ServiceRegistration('spreed', $fakeTalkServiceClass));
72
+        $this->container->expects(self::once())
73
+            ->method('get')
74
+            ->willThrowException(new QueryException());
75
+        $this->logger->expects(self::once())
76
+            ->method('error');
77
+
78
+        self::assertFalse(
79
+            $this->broker->hasBackend()
80
+        );
81
+    }
82
+
83
+    public function testHasBackend(): void {
84
+        $fakeTalkServiceClass = '\\OCA\\Spreed\\TalkBackend';
85
+        $registrationContext = $this->createMock(RegistrationContext::class);
86
+        $this->coordinator->expects(self::once())
87
+            ->method('getRegistrationContext')
88
+            ->willReturn($registrationContext);
89
+        $registrationContext->expects(self::once())
90
+            ->method('getTalkBackendRegistration')
91
+            ->willReturn(new ServiceRegistration('spreed', $fakeTalkServiceClass));
92
+        $talkService = $this->createMock(ITalkBackend::class);
93
+        $this->container->expects(self::once())
94
+            ->method('get')
95
+            ->with($fakeTalkServiceClass)
96
+            ->willReturn($talkService);
97
+
98
+        self::assertTrue(
99
+            $this->broker->hasBackend()
100
+        );
101
+    }
102
+
103
+    public function testNewConversationOptions(): void {
104
+        $this->broker->newConversationOptions();
105
+
106
+        // Nothing to assert
107
+        $this->addToAssertionCount(1);
108
+    }
109
+
110
+    public function testCreateConversation(): void {
111
+        $fakeTalkServiceClass = '\\OCA\\Spreed\\TalkBackend';
112
+        $registrationContext = $this->createMock(RegistrationContext::class);
113
+        $this->coordinator->expects(self::once())
114
+            ->method('getRegistrationContext')
115
+            ->willReturn($registrationContext);
116
+        $registrationContext->expects(self::once())
117
+            ->method('getTalkBackendRegistration')
118
+            ->willReturn(new ServiceRegistration('spreed', $fakeTalkServiceClass));
119
+        $talkService = $this->createMock(ITalkBackend::class);
120
+        $this->container->expects(self::once())
121
+            ->method('get')
122
+            ->with($fakeTalkServiceClass)
123
+            ->willReturn($talkService);
124
+        $options = $this->createMock(IConversationOptions::class);
125
+        $talkService->expects(self::once())
126
+            ->method('createConversation')
127
+            ->with('Watercooler', [], $options);
128
+
129
+        $this->broker->createConversation(
130
+            'Watercooler',
131
+            [],
132
+            $options
133
+        );
134
+    }
135 135
 }
Please login to merge, or discard this patch.
tests/lib/Mail/Provider/AttachmentTest.php 1 patch
Indentation   +39 added lines, -39 removed lines patch added patch discarded remove patch
@@ -13,59 +13,59 @@
 block discarded – undo
13 13
 
14 14
 class AttachmentTest extends TestCase {
15 15
 
16
-	/** @var Attachment&MockObject */
17
-	private Attachment $attachment;
16
+    /** @var Attachment&MockObject */
17
+    private Attachment $attachment;
18 18
 
19
-	protected function setUp(): void {
20
-		parent::setUp();
19
+    protected function setUp(): void {
20
+        parent::setUp();
21 21
 
22
-		$this->attachment = new Attachment(
23
-			'This is the contents of a file',
24
-			'example1.txt',
25
-			'text/plain',
26
-			false
27
-		);
22
+        $this->attachment = new Attachment(
23
+            'This is the contents of a file',
24
+            'example1.txt',
25
+            'text/plain',
26
+            false
27
+        );
28 28
 
29
-	}
29
+    }
30 30
 
31
-	public function testName(): void {
31
+    public function testName(): void {
32 32
 		
33
-		// test set by constructor
34
-		$this->assertEquals('example1.txt', $this->attachment->getName());
35
-		// test set by setter
36
-		$this->attachment->setName('example2.txt');
37
-		$this->assertEquals('example2.txt', $this->attachment->getName());
33
+        // test set by constructor
34
+        $this->assertEquals('example1.txt', $this->attachment->getName());
35
+        // test set by setter
36
+        $this->attachment->setName('example2.txt');
37
+        $this->assertEquals('example2.txt', $this->attachment->getName());
38 38
 
39
-	}
39
+    }
40 40
 
41
-	public function testType(): void {
41
+    public function testType(): void {
42 42
 		
43
-		// test set by constructor
44
-		$this->assertEquals('text/plain', $this->attachment->getType());
45
-		// test set by setter
46
-		$this->attachment->setType('text/html');
47
-		$this->assertEquals('text/html', $this->attachment->getType());
43
+        // test set by constructor
44
+        $this->assertEquals('text/plain', $this->attachment->getType());
45
+        // test set by setter
46
+        $this->attachment->setType('text/html');
47
+        $this->assertEquals('text/html', $this->attachment->getType());
48 48
 
49
-	}
49
+    }
50 50
 
51
-	public function testContents(): void {
51
+    public function testContents(): void {
52 52
 		
53
-		// test set by constructor
54
-		$this->assertEquals('This is the contents of a file', $this->attachment->getContents());
55
-		// test set by setter
56
-		$this->attachment->setContents('This is the modified contents of a file');
57
-		$this->assertEquals('This is the modified contents of a file', $this->attachment->getContents());
53
+        // test set by constructor
54
+        $this->assertEquals('This is the contents of a file', $this->attachment->getContents());
55
+        // test set by setter
56
+        $this->attachment->setContents('This is the modified contents of a file');
57
+        $this->assertEquals('This is the modified contents of a file', $this->attachment->getContents());
58 58
 
59
-	}
59
+    }
60 60
 
61
-	public function testEmbedded(): void {
61
+    public function testEmbedded(): void {
62 62
 		
63
-		// test set by constructor
64
-		$this->assertEquals(false, $this->attachment->getEmbedded());
65
-		// test set by setter
66
-		$this->attachment->setEmbedded(true);
67
-		$this->assertEquals(true, $this->attachment->getEmbedded());
63
+        // test set by constructor
64
+        $this->assertEquals(false, $this->attachment->getEmbedded());
65
+        // test set by setter
66
+        $this->attachment->setEmbedded(true);
67
+        $this->assertEquals(true, $this->attachment->getEmbedded());
68 68
 
69
-	}
69
+    }
70 70
 
71 71
 }
Please login to merge, or discard this patch.
tests/lib/Mail/Provider/ManagerTest.php 1 patch
Indentation   +163 added lines, -163 removed lines patch added patch discarded remove patch
@@ -21,169 +21,169 @@
 block discarded – undo
21 21
 
22 22
 class ManagerTest extends TestCase {
23 23
 
24
-	/** @var Coordinator&MockObject */
25
-	private Coordinator $coordinator;
26
-	/** @var ContainerInterface&MockObject */
27
-	private ContainerInterface $container;
28
-	/** @var LoggerInterface&MockObject */
29
-	private LoggerInterface $logger;
30
-	/** @var IProvider&MockObject */
31
-	private IProvider $provider;
32
-	/** @var IService&MockObject */
33
-	private IService $service;
34
-
35
-	protected function setUp(): void {
36
-		parent::setUp();
37
-
38
-		$this->logger = $this->createMock(LoggerInterface::class);
39
-
40
-		// construct service registration
41
-		$registration = $this->createMock(ServiceRegistration::class);
42
-		$registration
43
-			->method('getService')
44
-			->willReturn('Mock\Provider\MailProvider');
45
-		// construct registration context
46
-		$context = $this->createMock(RegistrationContext::class);
47
-		$context
48
-			->method('getMailProviders')
49
-			->willReturn([$registration]);
50
-		// construct coordinator
51
-		$this->coordinator = $this->createMock(Coordinator::class);
52
-		$this->coordinator
53
-			->method('getRegistrationContext')
54
-			->willReturn($context);
55
-
56
-		// construct mail service
57
-		$this->service = $this->createMock(IService::class);
58
-		$this->service
59
-			->method('id')
60
-			->willReturn('100');
61
-		$this->service
62
-			->method('getLabel')
63
-			->willReturn('Mock Mail Service');
64
-		$this->service
65
-			->method('getPrimaryAddress')
66
-			->willReturn((new Address('[email protected]', 'User One')));
67
-		// construct mail provider
68
-		$this->provider = $this->createMock(IProvider::class);
69
-		$this->provider
70
-			->method('id')
71
-			->willReturn('mock-provider');
72
-		$this->provider
73
-			->method('label')
74
-			->willReturn('Mock Provider');
75
-		$this->provider
76
-			->method('listServices')
77
-			->willReturnMap([
78
-				['user0', []],
79
-				['user1', [$this->service->id() => $this->service]]
80
-			]);
81
-		$this->provider
82
-			->method('findServiceById')
83
-			->willReturnMap([
84
-				['user0', '100', null],
85
-				['user1', '100', $this->service]
86
-			]);
87
-		$this->provider
88
-			->method('findServiceByAddress')
89
-			->willReturnMap([
90
-				['user0', '[email protected]', null],
91
-				['user1', '[email protected]', $this->service]
92
-			]);
93
-		// construct container interface
94
-		$this->container = $this->createMock(ContainerInterface::class);
95
-		$this->container
96
-			->method('get')
97
-			->willReturnMap([
98
-				['Mock\Provider\MailProvider', $this->provider]
99
-			]);
100
-
101
-	}
102
-
103
-	public function testHas(): void {
104
-
105
-		// construct mail manager
106
-		$manager = new Manager($this->coordinator, $this->container, $this->logger);
107
-		// test result with providers found
108
-		$this->assertTrue($manager->has());
109
-
110
-	}
111
-
112
-	public function testCount(): void {
113
-
114
-		// construct mail manager
115
-		$manager = new Manager($this->coordinator, $this->container, $this->logger);
116
-		// test result with providers found
117
-		$this->assertGreaterThan(0, $manager->count());
118
-
119
-	}
120
-
121
-	public function testTypes(): void {
122
-
123
-		// construct mail manager
124
-		$manager = new Manager($this->coordinator, $this->container, $this->logger);
125
-		// test result with providers found
126
-		$this->assertEquals(['mock-provider' => 'Mock Provider'], $manager->types());
127
-
128
-	}
129
-
130
-	public function testProviders(): void {
131
-
132
-		// construct mail manager
133
-		$manager = new Manager($this->coordinator, $this->container, $this->logger);
134
-		// test result with providers found
135
-		$this->assertEquals([$this->provider->id() => $this->provider], $manager->providers());
136
-
137
-	}
138
-
139
-	public function testFindProviderById(): void {
140
-
141
-		// construct mail manager
142
-		$manager = new Manager($this->coordinator, $this->container, $this->logger);
143
-		// test result with providers found
144
-		$this->assertEquals($this->provider, $manager->findProviderById($this->provider->id()));
145
-
146
-	}
147
-
148
-	public function testServices(): void {
149
-
150
-		// construct mail manager
151
-		$manager = new Manager($this->coordinator, $this->container, $this->logger);
152
-		// test result with no services found
153
-		$this->assertEquals([], $manager->services('user0'));
154
-		// test result with services found
155
-		$this->assertEquals([$this->provider->id() => [$this->service->id() => $this->service]], $manager->services('user1'));
156
-
157
-	}
158
-
159
-	public function testFindServiceById(): void {
160
-
161
-		// construct mail manager
162
-		$manager = new Manager($this->coordinator, $this->container, $this->logger);
163
-		// test result with no services found and not provider specified
164
-		$this->assertEquals(null, $manager->findServiceById('user0', '100'));
165
-		// test result with no services found and provider specified
166
-		$this->assertEquals(null, $manager->findServiceById('user0', '100', $this->provider->id()));
167
-		// test result with services found and not provider specified
168
-		$this->assertEquals($this->service, $manager->findServiceById('user1', '100'));
169
-		// test result with services found and provider specified
170
-		$this->assertEquals($this->service, $manager->findServiceById('user1', '100', $this->provider->id()));
171
-
172
-	}
173
-
174
-	public function testFindServiceByAddress(): void {
175
-
176
-		// construct mail manager
177
-		$manager = new Manager($this->coordinator, $this->container, $this->logger);
178
-		// test result with no services found and not provider specified
179
-		$this->assertEquals(null, $manager->findServiceByAddress('user0', '[email protected]'));
180
-		// test result with no services found and provider specified
181
-		$this->assertEquals(null, $manager->findServiceByAddress('user0', '[email protected]', $this->provider->id()));
182
-		// test result with services found and not provider specified
183
-		$this->assertEquals($this->service, $manager->findServiceByAddress('user1', '[email protected]'));
184
-		// test result with services found and provider specified
185
-		$this->assertEquals($this->service, $manager->findServiceByAddress('user1', '[email protected]', $this->provider->id()));
24
+    /** @var Coordinator&MockObject */
25
+    private Coordinator $coordinator;
26
+    /** @var ContainerInterface&MockObject */
27
+    private ContainerInterface $container;
28
+    /** @var LoggerInterface&MockObject */
29
+    private LoggerInterface $logger;
30
+    /** @var IProvider&MockObject */
31
+    private IProvider $provider;
32
+    /** @var IService&MockObject */
33
+    private IService $service;
34
+
35
+    protected function setUp(): void {
36
+        parent::setUp();
37
+
38
+        $this->logger = $this->createMock(LoggerInterface::class);
39
+
40
+        // construct service registration
41
+        $registration = $this->createMock(ServiceRegistration::class);
42
+        $registration
43
+            ->method('getService')
44
+            ->willReturn('Mock\Provider\MailProvider');
45
+        // construct registration context
46
+        $context = $this->createMock(RegistrationContext::class);
47
+        $context
48
+            ->method('getMailProviders')
49
+            ->willReturn([$registration]);
50
+        // construct coordinator
51
+        $this->coordinator = $this->createMock(Coordinator::class);
52
+        $this->coordinator
53
+            ->method('getRegistrationContext')
54
+            ->willReturn($context);
55
+
56
+        // construct mail service
57
+        $this->service = $this->createMock(IService::class);
58
+        $this->service
59
+            ->method('id')
60
+            ->willReturn('100');
61
+        $this->service
62
+            ->method('getLabel')
63
+            ->willReturn('Mock Mail Service');
64
+        $this->service
65
+            ->method('getPrimaryAddress')
66
+            ->willReturn((new Address('[email protected]', 'User One')));
67
+        // construct mail provider
68
+        $this->provider = $this->createMock(IProvider::class);
69
+        $this->provider
70
+            ->method('id')
71
+            ->willReturn('mock-provider');
72
+        $this->provider
73
+            ->method('label')
74
+            ->willReturn('Mock Provider');
75
+        $this->provider
76
+            ->method('listServices')
77
+            ->willReturnMap([
78
+                ['user0', []],
79
+                ['user1', [$this->service->id() => $this->service]]
80
+            ]);
81
+        $this->provider
82
+            ->method('findServiceById')
83
+            ->willReturnMap([
84
+                ['user0', '100', null],
85
+                ['user1', '100', $this->service]
86
+            ]);
87
+        $this->provider
88
+            ->method('findServiceByAddress')
89
+            ->willReturnMap([
90
+                ['user0', '[email protected]', null],
91
+                ['user1', '[email protected]', $this->service]
92
+            ]);
93
+        // construct container interface
94
+        $this->container = $this->createMock(ContainerInterface::class);
95
+        $this->container
96
+            ->method('get')
97
+            ->willReturnMap([
98
+                ['Mock\Provider\MailProvider', $this->provider]
99
+            ]);
100
+
101
+    }
102
+
103
+    public function testHas(): void {
104
+
105
+        // construct mail manager
106
+        $manager = new Manager($this->coordinator, $this->container, $this->logger);
107
+        // test result with providers found
108
+        $this->assertTrue($manager->has());
109
+
110
+    }
111
+
112
+    public function testCount(): void {
113
+
114
+        // construct mail manager
115
+        $manager = new Manager($this->coordinator, $this->container, $this->logger);
116
+        // test result with providers found
117
+        $this->assertGreaterThan(0, $manager->count());
118
+
119
+    }
120
+
121
+    public function testTypes(): void {
122
+
123
+        // construct mail manager
124
+        $manager = new Manager($this->coordinator, $this->container, $this->logger);
125
+        // test result with providers found
126
+        $this->assertEquals(['mock-provider' => 'Mock Provider'], $manager->types());
127
+
128
+    }
129
+
130
+    public function testProviders(): void {
131
+
132
+        // construct mail manager
133
+        $manager = new Manager($this->coordinator, $this->container, $this->logger);
134
+        // test result with providers found
135
+        $this->assertEquals([$this->provider->id() => $this->provider], $manager->providers());
136
+
137
+    }
138
+
139
+    public function testFindProviderById(): void {
140
+
141
+        // construct mail manager
142
+        $manager = new Manager($this->coordinator, $this->container, $this->logger);
143
+        // test result with providers found
144
+        $this->assertEquals($this->provider, $manager->findProviderById($this->provider->id()));
145
+
146
+    }
147
+
148
+    public function testServices(): void {
149
+
150
+        // construct mail manager
151
+        $manager = new Manager($this->coordinator, $this->container, $this->logger);
152
+        // test result with no services found
153
+        $this->assertEquals([], $manager->services('user0'));
154
+        // test result with services found
155
+        $this->assertEquals([$this->provider->id() => [$this->service->id() => $this->service]], $manager->services('user1'));
156
+
157
+    }
158
+
159
+    public function testFindServiceById(): void {
160
+
161
+        // construct mail manager
162
+        $manager = new Manager($this->coordinator, $this->container, $this->logger);
163
+        // test result with no services found and not provider specified
164
+        $this->assertEquals(null, $manager->findServiceById('user0', '100'));
165
+        // test result with no services found and provider specified
166
+        $this->assertEquals(null, $manager->findServiceById('user0', '100', $this->provider->id()));
167
+        // test result with services found and not provider specified
168
+        $this->assertEquals($this->service, $manager->findServiceById('user1', '100'));
169
+        // test result with services found and provider specified
170
+        $this->assertEquals($this->service, $manager->findServiceById('user1', '100', $this->provider->id()));
171
+
172
+    }
173
+
174
+    public function testFindServiceByAddress(): void {
175
+
176
+        // construct mail manager
177
+        $manager = new Manager($this->coordinator, $this->container, $this->logger);
178
+        // test result with no services found and not provider specified
179
+        $this->assertEquals(null, $manager->findServiceByAddress('user0', '[email protected]'));
180
+        // test result with no services found and provider specified
181
+        $this->assertEquals(null, $manager->findServiceByAddress('user0', '[email protected]', $this->provider->id()));
182
+        // test result with services found and not provider specified
183
+        $this->assertEquals($this->service, $manager->findServiceByAddress('user1', '[email protected]'));
184
+        // test result with services found and provider specified
185
+        $this->assertEquals($this->service, $manager->findServiceByAddress('user1', '[email protected]', $this->provider->id()));
186 186
 
187
-	}
187
+    }
188 188
 
189 189
 }
Please login to merge, or discard this patch.
tests/lib/Mail/Provider/AddressTest.php 1 patch
Indentation   +20 added lines, -20 removed lines patch added patch discarded remove patch
@@ -13,34 +13,34 @@
 block discarded – undo
13 13
 
14 14
 class AddressTest extends TestCase {
15 15
 
16
-	/** @var Address&MockObject */
17
-	private Address $address;
16
+    /** @var Address&MockObject */
17
+    private Address $address;
18 18
 
19
-	protected function setUp(): void {
20
-		parent::setUp();
19
+    protected function setUp(): void {
20
+        parent::setUp();
21 21
 
22
-		$this->address = new Address('[email protected]', 'User One');
22
+        $this->address = new Address('[email protected]', 'User One');
23 23
 
24
-	}
24
+    }
25 25
 
26
-	public function testAddress(): void {
26
+    public function testAddress(): void {
27 27
 		
28
-		// test set by constructor
29
-		$this->assertEquals('[email protected]', $this->address->getAddress());
30
-		// test set by setter
31
-		$this->address->setAddress('[email protected]');
32
-		$this->assertEquals('[email protected]', $this->address->getAddress());
28
+        // test set by constructor
29
+        $this->assertEquals('[email protected]', $this->address->getAddress());
30
+        // test set by setter
31
+        $this->address->setAddress('[email protected]');
32
+        $this->assertEquals('[email protected]', $this->address->getAddress());
33 33
 
34
-	}
34
+    }
35 35
 
36
-	public function testLabel(): void {
36
+    public function testLabel(): void {
37 37
 		
38
-		// test set by constructor
39
-		$this->assertEquals('User One', $this->address->getLabel());
40
-		// test set by setter
41
-		$this->address->setLabel('User Two');
42
-		$this->assertEquals('User Two', $this->address->getLabel());
38
+        // test set by constructor
39
+        $this->assertEquals('User One', $this->address->getLabel());
40
+        // test set by setter
41
+        $this->address->setLabel('User Two');
42
+        $this->assertEquals('User Two', $this->address->getLabel());
43 43
 
44
-	}
44
+    }
45 45
 
46 46
 }
Please login to merge, or discard this patch.
tests/lib/Remote/InstanceTest.php 1 patch
Indentation   +44 added lines, -44 removed lines patch added patch discarded remove patch
@@ -13,63 +13,63 @@
 block discarded – undo
13 13
 use Test\Traits\ClientServiceTrait;
14 14
 
15 15
 class InstanceTest extends TestCase {
16
-	use ClientServiceTrait;
16
+    use ClientServiceTrait;
17 17
 
18
-	/** @var ICache */
19
-	private $cache;
18
+    /** @var ICache */
19
+    private $cache;
20 20
 
21
-	protected function setUp(): void {
22
-		parent::setUp();
21
+    protected function setUp(): void {
22
+        parent::setUp();
23 23
 
24
-		$this->cache = new ArrayCache();
25
-	}
24
+        $this->cache = new ArrayCache();
25
+    }
26 26
 
27
-	public function testBasicStatus(): void {
28
-		$instance = new Instance('example.com', $this->cache, $this->getClientService());
29
-		$this->expectGetRequest('https://example.com/status.php', '{"installed":true,"maintenance":false,"needsDbUpgrade":false,"version":"13.0.0.5","versionstring":"13.0.0 alpha","edition":"","productname":"Nextcloud"}');
27
+    public function testBasicStatus(): void {
28
+        $instance = new Instance('example.com', $this->cache, $this->getClientService());
29
+        $this->expectGetRequest('https://example.com/status.php', '{"installed":true,"maintenance":false,"needsDbUpgrade":false,"version":"13.0.0.5","versionstring":"13.0.0 alpha","edition":"","productname":"Nextcloud"}');
30 30
 
31
-		$this->assertEquals(true, $instance->isActive());
32
-		$this->assertEquals('13.0.0.5', $instance->getVersion());
33
-		$this->assertEquals('https', $instance->getProtocol());
34
-		$this->assertEquals('https://example.com', $instance->getFullUrl());
35
-	}
31
+        $this->assertEquals(true, $instance->isActive());
32
+        $this->assertEquals('13.0.0.5', $instance->getVersion());
33
+        $this->assertEquals('https', $instance->getProtocol());
34
+        $this->assertEquals('https://example.com', $instance->getFullUrl());
35
+    }
36 36
 
37
-	public function testHttpFallback(): void {
38
-		$instance = new Instance('example.com', $this->cache, $this->getClientService());
39
-		$this->expectGetRequest('https://example.com/status.php', new \Exception());
40
-		$this->expectGetRequest('http://example.com/status.php', '{"installed":true,"maintenance":false,"needsDbUpgrade":false,"version":"13.0.0.5","versionstring":"13.0.0 alpha","edition":"","productname":"Nextcloud"}');
37
+    public function testHttpFallback(): void {
38
+        $instance = new Instance('example.com', $this->cache, $this->getClientService());
39
+        $this->expectGetRequest('https://example.com/status.php', new \Exception());
40
+        $this->expectGetRequest('http://example.com/status.php', '{"installed":true,"maintenance":false,"needsDbUpgrade":false,"version":"13.0.0.5","versionstring":"13.0.0 alpha","edition":"","productname":"Nextcloud"}');
41 41
 
42
-		$this->assertEquals('http', $instance->getProtocol());
43
-		$this->assertEquals('http://example.com', $instance->getFullUrl());
44
-	}
42
+        $this->assertEquals('http', $instance->getProtocol());
43
+        $this->assertEquals('http://example.com', $instance->getFullUrl());
44
+    }
45 45
 
46
-	public function testRerequestHttps(): void {
47
-		$instance = new Instance('example.com', $this->cache, $this->getClientService());
48
-		$this->expectGetRequest('https://example.com/status.php', '{"installed":true,"maintenance":false,"needsDbUpgrade":false,"version":"13.0.0.5","versionstring":"13.0.0 alpha","edition":"","productname":"Nextcloud"}');
46
+    public function testRerequestHttps(): void {
47
+        $instance = new Instance('example.com', $this->cache, $this->getClientService());
48
+        $this->expectGetRequest('https://example.com/status.php', '{"installed":true,"maintenance":false,"needsDbUpgrade":false,"version":"13.0.0.5","versionstring":"13.0.0 alpha","edition":"","productname":"Nextcloud"}');
49 49
 
50
-		$this->assertEquals('https', $instance->getProtocol());
51
-		$this->assertEquals(true, $instance->isActive());
50
+        $this->assertEquals('https', $instance->getProtocol());
51
+        $this->assertEquals(true, $instance->isActive());
52 52
 
53
-		$this->cache->remove('remote/example.com/status');
54
-		$this->expectGetRequest('https://example.com/status.php', '{"installed":true,"maintenance":true,"needsDbUpgrade":false,"version":"13.0.0.5","versionstring":"13.0.0 alpha","edition":"","productname":"Nextcloud"}');
55
-		$instance2 = new Instance('example.com', $this->cache, $this->getClientService());
56
-		$this->assertEquals('https', $instance2->getProtocol());
57
-		$this->assertEquals(false, $instance2->isActive());
58
-	}
53
+        $this->cache->remove('remote/example.com/status');
54
+        $this->expectGetRequest('https://example.com/status.php', '{"installed":true,"maintenance":true,"needsDbUpgrade":false,"version":"13.0.0.5","versionstring":"13.0.0 alpha","edition":"","productname":"Nextcloud"}');
55
+        $instance2 = new Instance('example.com', $this->cache, $this->getClientService());
56
+        $this->assertEquals('https', $instance2->getProtocol());
57
+        $this->assertEquals(false, $instance2->isActive());
58
+    }
59 59
 
60 60
 	
61
-	public function testPreventDowngradeAttach(): void {
62
-		$this->expectException(\Exception::class);
63
-		$this->expectExceptionMessage('refusing to connect to remote instance(example.com) over http that was previously accessible over https');
61
+    public function testPreventDowngradeAttach(): void {
62
+        $this->expectException(\Exception::class);
63
+        $this->expectExceptionMessage('refusing to connect to remote instance(example.com) over http that was previously accessible over https');
64 64
 
65
-		$instance = new Instance('example.com', $this->cache, $this->getClientService());
66
-		$this->expectGetRequest('https://example.com/status.php', '{"installed":true,"maintenance":false,"needsDbUpgrade":false,"version":"13.0.0.5","versionstring":"13.0.0 alpha","edition":"","productname":"Nextcloud"}');
65
+        $instance = new Instance('example.com', $this->cache, $this->getClientService());
66
+        $this->expectGetRequest('https://example.com/status.php', '{"installed":true,"maintenance":false,"needsDbUpgrade":false,"version":"13.0.0.5","versionstring":"13.0.0 alpha","edition":"","productname":"Nextcloud"}');
67 67
 
68
-		$this->assertEquals('https', $instance->getProtocol());
68
+        $this->assertEquals('https', $instance->getProtocol());
69 69
 
70
-		$this->expectGetRequest('https://example.com/status.php', new \Exception());
71
-		$this->cache->remove('remote/example.com/status');
72
-		$instance2 = new Instance('example.com', $this->cache, $this->getClientService());
73
-		$instance2->getProtocol();
74
-	}
70
+        $this->expectGetRequest('https://example.com/status.php', new \Exception());
71
+        $this->cache->remove('remote/example.com/status');
72
+        $instance2 = new Instance('example.com', $this->cache, $this->getClientService());
73
+        $instance2->getProtocol();
74
+    }
75 75
 }
Please login to merge, or discard this patch.