Completed
Push — master ( 3911d6...b5b320 )
by
unknown
31:08
created
tests/lib/Authentication/Events/RemoteWipeFinishedTest.php 1 patch
Indentation   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -14,10 +14,10 @@
 block discarded – undo
14 14
 use Test\TestCase;
15 15
 
16 16
 class RemoteWipeFinishedTest extends TestCase {
17
-	public function testGetToken(): void {
18
-		$token = $this->createMock(IToken::class);
19
-		$event = new RemoteWipeFinished($token);
17
+    public function testGetToken(): void {
18
+        $token = $this->createMock(IToken::class);
19
+        $event = new RemoteWipeFinished($token);
20 20
 
21
-		$this->assertSame($token, $event->getToken());
22
-	}
21
+        $this->assertSame($token, $event->getToken());
22
+    }
23 23
 }
Please login to merge, or discard this patch.
tests/lib/Authentication/LoginCredentials/CredentialsTest.php 1 patch
Indentation   +24 added lines, -24 removed lines patch added patch discarded remove patch
@@ -11,37 +11,37 @@
 block discarded – undo
11 11
 use Test\TestCase;
12 12
 
13 13
 class CredentialsTest extends TestCase {
14
-	/** @var string */
15
-	private $uid;
14
+    /** @var string */
15
+    private $uid;
16 16
 
17
-	/** @var string */
18
-	private $user;
17
+    /** @var string */
18
+    private $user;
19 19
 
20
-	/** @var string */
21
-	private $password;
20
+    /** @var string */
21
+    private $password;
22 22
 
23
-	/** @var Credentials */
24
-	private $credentials;
23
+    /** @var Credentials */
24
+    private $credentials;
25 25
 
26
-	protected function setUp(): void {
27
-		parent::setUp();
26
+    protected function setUp(): void {
27
+        parent::setUp();
28 28
 
29
-		$this->uid = 'user123';
30
-		$this->user = 'User123';
31
-		$this->password = '123456';
29
+        $this->uid = 'user123';
30
+        $this->user = 'User123';
31
+        $this->password = '123456';
32 32
 
33
-		$this->credentials = new Credentials($this->uid, $this->user, $this->password);
34
-	}
33
+        $this->credentials = new Credentials($this->uid, $this->user, $this->password);
34
+    }
35 35
 
36
-	public function testGetUID(): void {
37
-		$this->assertEquals($this->uid, $this->credentials->getUID());
38
-	}
36
+    public function testGetUID(): void {
37
+        $this->assertEquals($this->uid, $this->credentials->getUID());
38
+    }
39 39
 
40
-	public function testGetUserName(): void {
41
-		$this->assertEquals($this->user, $this->credentials->getLoginName());
42
-	}
40
+    public function testGetUserName(): void {
41
+        $this->assertEquals($this->user, $this->credentials->getLoginName());
42
+    }
43 43
 
44
-	public function testGetPassword(): void {
45
-		$this->assertEquals($this->password, $this->credentials->getPassword());
46
-	}
44
+    public function testGetPassword(): void {
45
+        $this->assertEquals($this->password, $this->credentials->getPassword());
46
+    }
47 47
 }
Please login to merge, or discard this patch.
tests/lib/Authentication/Listeners/RemoteWipeActivityListenerTest.php 1 patch
Indentation   +112 added lines, -112 removed lines patch added patch discarded remove patch
@@ -22,116 +22,116 @@
 block discarded – undo
22 22
 use Test\TestCase;
23 23
 
24 24
 class RemoteWipeActivityListenerTest extends TestCase {
25
-	/** @var IActivityManager|MockObject */
26
-	private $activityManager;
27
-
28
-	/** @var LoggerInterface|MockObject */
29
-	private $logger;
30
-
31
-	/** @var IEventListener */
32
-	private $listener;
33
-
34
-	protected function setUp(): void {
35
-		parent::setUp();
36
-
37
-		$this->activityManager = $this->createMock(IActivityManager::class);
38
-		$this->logger = $this->createMock(LoggerInterface::class);
39
-
40
-		$this->listener = new RemoteWipeActivityListener(
41
-			$this->activityManager,
42
-			$this->logger
43
-		);
44
-	}
45
-
46
-	public function testHandleUnrelated(): void {
47
-		$event = new Event();
48
-
49
-		$this->listener->handle($event);
50
-
51
-		$this->addToAssertionCount(1);
52
-	}
53
-
54
-	public function testHandleRemoteWipeStarted(): void {
55
-		/** @var IToken|MockObject $token */
56
-		$token = $this->createMock(IToken::class);
57
-		$event = new RemoteWipeStarted($token);
58
-		$activityEvent = $this->createMock(IActivityEvent::class);
59
-		$this->activityManager->expects($this->once())
60
-			->method('generateEvent')
61
-			->willReturn($activityEvent);
62
-		$activityEvent->expects($this->once())
63
-			->method('setApp')
64
-			->with('core')
65
-			->willReturnSelf();
66
-		$activityEvent->expects($this->once())
67
-			->method('setType')
68
-			->with('security')
69
-			->willReturnSelf();
70
-		$token->method('getUID')->willReturn('user123');
71
-		$activityEvent->expects($this->once())
72
-			->method('setAuthor')
73
-			->with('user123')
74
-			->willReturnSelf();
75
-		$activityEvent->expects($this->once())
76
-			->method('setAffectedUser')
77
-			->with('user123')
78
-			->willReturnSelf();
79
-		$token->method('getName')->willReturn('Token 1');
80
-		$activityEvent->expects($this->once())
81
-			->method('setSubject')
82
-			->with('remote_wipe_start', ['name' => 'Token 1'])
83
-			->willReturnSelf();
84
-		$this->activityManager->expects($this->once())
85
-			->method('publish');
86
-
87
-		$this->listener->handle($event);
88
-	}
89
-
90
-	public function testHandleRemoteWipeStartedCanNotPublish(): void {
91
-		$token = $this->createMock(IToken::class);
92
-		$event = new RemoteWipeStarted($token);
93
-		$this->activityManager->expects($this->once())
94
-			->method('generateEvent');
95
-		$this->activityManager->expects($this->once())
96
-			->method('publish')
97
-			->willThrowException(new \BadMethodCallException());
98
-
99
-		$this->listener->handle($event);
100
-	}
101
-
102
-	public function testHandleRemoteWipeFinished(): void {
103
-		/** @var IToken|MockObject $token */
104
-		$token = $this->createMock(IToken::class);
105
-		$event = new RemoteWipeFinished($token);
106
-		$activityEvent = $this->createMock(IActivityEvent::class);
107
-		$this->activityManager->expects($this->once())
108
-			->method('generateEvent')
109
-			->willReturn($activityEvent);
110
-		$activityEvent->expects($this->once())
111
-			->method('setApp')
112
-			->with('core')
113
-			->willReturnSelf();
114
-		$activityEvent->expects($this->once())
115
-			->method('setType')
116
-			->with('security')
117
-			->willReturnSelf();
118
-		$token->method('getUID')->willReturn('user123');
119
-		$activityEvent->expects($this->once())
120
-			->method('setAuthor')
121
-			->with('user123')
122
-			->willReturnSelf();
123
-		$activityEvent->expects($this->once())
124
-			->method('setAffectedUser')
125
-			->with('user123')
126
-			->willReturnSelf();
127
-		$token->method('getName')->willReturn('Token 1');
128
-		$activityEvent->expects($this->once())
129
-			->method('setSubject')
130
-			->with('remote_wipe_finish', ['name' => 'Token 1'])
131
-			->willReturnSelf();
132
-		$this->activityManager->expects($this->once())
133
-			->method('publish');
134
-
135
-		$this->listener->handle($event);
136
-	}
25
+    /** @var IActivityManager|MockObject */
26
+    private $activityManager;
27
+
28
+    /** @var LoggerInterface|MockObject */
29
+    private $logger;
30
+
31
+    /** @var IEventListener */
32
+    private $listener;
33
+
34
+    protected function setUp(): void {
35
+        parent::setUp();
36
+
37
+        $this->activityManager = $this->createMock(IActivityManager::class);
38
+        $this->logger = $this->createMock(LoggerInterface::class);
39
+
40
+        $this->listener = new RemoteWipeActivityListener(
41
+            $this->activityManager,
42
+            $this->logger
43
+        );
44
+    }
45
+
46
+    public function testHandleUnrelated(): void {
47
+        $event = new Event();
48
+
49
+        $this->listener->handle($event);
50
+
51
+        $this->addToAssertionCount(1);
52
+    }
53
+
54
+    public function testHandleRemoteWipeStarted(): void {
55
+        /** @var IToken|MockObject $token */
56
+        $token = $this->createMock(IToken::class);
57
+        $event = new RemoteWipeStarted($token);
58
+        $activityEvent = $this->createMock(IActivityEvent::class);
59
+        $this->activityManager->expects($this->once())
60
+            ->method('generateEvent')
61
+            ->willReturn($activityEvent);
62
+        $activityEvent->expects($this->once())
63
+            ->method('setApp')
64
+            ->with('core')
65
+            ->willReturnSelf();
66
+        $activityEvent->expects($this->once())
67
+            ->method('setType')
68
+            ->with('security')
69
+            ->willReturnSelf();
70
+        $token->method('getUID')->willReturn('user123');
71
+        $activityEvent->expects($this->once())
72
+            ->method('setAuthor')
73
+            ->with('user123')
74
+            ->willReturnSelf();
75
+        $activityEvent->expects($this->once())
76
+            ->method('setAffectedUser')
77
+            ->with('user123')
78
+            ->willReturnSelf();
79
+        $token->method('getName')->willReturn('Token 1');
80
+        $activityEvent->expects($this->once())
81
+            ->method('setSubject')
82
+            ->with('remote_wipe_start', ['name' => 'Token 1'])
83
+            ->willReturnSelf();
84
+        $this->activityManager->expects($this->once())
85
+            ->method('publish');
86
+
87
+        $this->listener->handle($event);
88
+    }
89
+
90
+    public function testHandleRemoteWipeStartedCanNotPublish(): void {
91
+        $token = $this->createMock(IToken::class);
92
+        $event = new RemoteWipeStarted($token);
93
+        $this->activityManager->expects($this->once())
94
+            ->method('generateEvent');
95
+        $this->activityManager->expects($this->once())
96
+            ->method('publish')
97
+            ->willThrowException(new \BadMethodCallException());
98
+
99
+        $this->listener->handle($event);
100
+    }
101
+
102
+    public function testHandleRemoteWipeFinished(): void {
103
+        /** @var IToken|MockObject $token */
104
+        $token = $this->createMock(IToken::class);
105
+        $event = new RemoteWipeFinished($token);
106
+        $activityEvent = $this->createMock(IActivityEvent::class);
107
+        $this->activityManager->expects($this->once())
108
+            ->method('generateEvent')
109
+            ->willReturn($activityEvent);
110
+        $activityEvent->expects($this->once())
111
+            ->method('setApp')
112
+            ->with('core')
113
+            ->willReturnSelf();
114
+        $activityEvent->expects($this->once())
115
+            ->method('setType')
116
+            ->with('security')
117
+            ->willReturnSelf();
118
+        $token->method('getUID')->willReturn('user123');
119
+        $activityEvent->expects($this->once())
120
+            ->method('setAuthor')
121
+            ->with('user123')
122
+            ->willReturnSelf();
123
+        $activityEvent->expects($this->once())
124
+            ->method('setAffectedUser')
125
+            ->with('user123')
126
+            ->willReturnSelf();
127
+        $token->method('getName')->willReturn('Token 1');
128
+        $activityEvent->expects($this->once())
129
+            ->method('setSubject')
130
+            ->with('remote_wipe_finish', ['name' => 'Token 1'])
131
+            ->willReturnSelf();
132
+        $this->activityManager->expects($this->once())
133
+            ->method('publish');
134
+
135
+        $this->listener->handle($event);
136
+    }
137 137
 }
Please login to merge, or discard this patch.
tests/lib/Authentication/Listeners/RemoteWipeEmailListenerTest.php 1 patch
Indentation   +195 added lines, -195 removed lines patch added patch discarded remove patch
@@ -27,199 +27,199 @@
 block discarded – undo
27 27
 use Test\TestCase;
28 28
 
29 29
 class RemoteWipeEmailListenerTest extends TestCase {
30
-	/** @var IMailer|MockObject */
31
-	private $mailer;
32
-
33
-	/** @var IUserManager|MockObject */
34
-	private $userManager;
35
-
36
-	/** @var IFactory|MockObject */
37
-	private $l10nFactory;
38
-
39
-	/** @var IL10N|MockObject */
40
-	private $l10n;
41
-
42
-	/** @var LoggerInterface|MockObject */
43
-	private $logger;
44
-
45
-	/** @var IEventListener */
46
-	private $listener;
47
-
48
-	protected function setUp(): void {
49
-		parent::setUp();
50
-
51
-		$this->mailer = $this->createMock(IMailer::class);
52
-		$this->userManager = $this->createMock(IUserManager::class);
53
-		$this->l10nFactory = $this->createMock(IFactory::class);
54
-		$this->l10n = $this->createMock(IL10N::class);
55
-		$this->logger = $this->createMock(LoggerInterface::class);
56
-
57
-		$this->l10nFactory->method('get')->with('core')->willReturn($this->l10n);
58
-		$this->l10n->method('t')->willReturnArgument(0);
59
-
60
-		$this->listener = new RemoteWipeEmailListener(
61
-			$this->mailer,
62
-			$this->userManager,
63
-			$this->l10nFactory,
64
-			$this->logger
65
-		);
66
-	}
67
-
68
-
69
-	public function testHandleUnrelated(): void {
70
-		$event = new Event();
71
-		$this->mailer->expects($this->never())->method('send');
72
-
73
-		$this->listener->handle($event);
74
-	}
75
-
76
-	public function testHandleRemoteWipeStartedInvalidUser(): void {
77
-		/** @var IToken|MockObject $token */
78
-		$token = $this->createMock(IToken::class);
79
-		$event = new RemoteWipeStarted($token);
80
-		$token->method('getUID')->willReturn('nope');
81
-		$this->userManager->expects($this->once())
82
-			->method('get')
83
-			->with('nope')
84
-			->willReturn(null);
85
-		$this->mailer->expects($this->never())->method('send');
86
-
87
-		$this->listener->handle($event);
88
-	}
89
-
90
-	public function testHandleRemoteWipeStartedNoEmailSet(): void {
91
-		/** @var IToken|MockObject $token */
92
-		$token = $this->createMock(IToken::class);
93
-		$event = new RemoteWipeStarted($token);
94
-		$token->method('getUID')->willReturn('nope');
95
-		$user = $this->createMock(IUser::class);
96
-		$this->userManager->expects($this->once())
97
-			->method('get')
98
-			->with('nope')
99
-			->willReturn($user);
100
-		$user->method('getEMailAddress')->willReturn(null);
101
-		$this->mailer->expects($this->never())->method('send');
102
-
103
-		$this->listener->handle($event);
104
-	}
105
-
106
-	public function testHandleRemoteWipeStartedTransmissionError(): void {
107
-		/** @var IToken|MockObject $token */
108
-		$token = $this->createMock(IToken::class);
109
-		$event = new RemoteWipeStarted($token);
110
-		$token->method('getUID')->willReturn('nope');
111
-		$user = $this->createMock(IUser::class);
112
-		$this->userManager->expects($this->once())
113
-			->method('get')
114
-			->with('nope')
115
-			->willReturn($user);
116
-		$user->method('getEMailAddress')->willReturn('[email protected]');
117
-		$this->mailer->expects($this->once())
118
-			->method('send')
119
-			->willThrowException(new Exception());
120
-		$this->logger->expects($this->once())
121
-			->method('error');
122
-
123
-		$this->listener->handle($event);
124
-	}
125
-
126
-	public function testHandleRemoteWipeStarted(): void {
127
-		/** @var IToken|MockObject $token */
128
-		$token = $this->createMock(IToken::class);
129
-		$event = new RemoteWipeStarted($token);
130
-		$token->method('getUID')->willReturn('nope');
131
-		$user = $this->createMock(IUser::class);
132
-		$this->userManager->expects($this->once())
133
-			->method('get')
134
-			->with('nope')
135
-			->willReturn($user);
136
-		$user->method('getEMailAddress')->willReturn('[email protected]');
137
-		$message = $this->createMock(IMessage::class);
138
-		$this->mailer->expects($this->once())
139
-			->method('createMessage')
140
-			->willReturn($message);
141
-		$message->expects($this->once())
142
-			->method('setTo')
143
-			->with($this->equalTo(['[email protected]']));
144
-		$this->mailer->expects($this->once())
145
-			->method('send')
146
-			->with($message);
147
-
148
-		$this->listener->handle($event);
149
-	}
150
-
151
-	public function testHandleRemoteWipeFinishedInvalidUser(): void {
152
-		/** @var IToken|MockObject $token */
153
-		$token = $this->createMock(IToken::class);
154
-		$event = new RemoteWipeFinished($token);
155
-		$token->method('getUID')->willReturn('nope');
156
-		$this->userManager->expects($this->once())
157
-			->method('get')
158
-			->with('nope')
159
-			->willReturn(null);
160
-		$this->mailer->expects($this->never())->method('send');
161
-
162
-		$this->listener->handle($event);
163
-	}
164
-
165
-	public function testHandleRemoteWipeFinishedNoEmailSet(): void {
166
-		/** @var IToken|MockObject $token */
167
-		$token = $this->createMock(IToken::class);
168
-		$event = new RemoteWipeFinished($token);
169
-		$token->method('getUID')->willReturn('nope');
170
-		$user = $this->createMock(IUser::class);
171
-		$this->userManager->expects($this->once())
172
-			->method('get')
173
-			->with('nope')
174
-			->willReturn($user);
175
-		$user->method('getEMailAddress')->willReturn(null);
176
-		$this->mailer->expects($this->never())->method('send');
177
-
178
-		$this->listener->handle($event);
179
-	}
180
-
181
-	public function testHandleRemoteWipeFinishedTransmissionError(): void {
182
-		/** @var IToken|MockObject $token */
183
-		$token = $this->createMock(IToken::class);
184
-		$event = new RemoteWipeFinished($token);
185
-		$token->method('getUID')->willReturn('nope');
186
-		$user = $this->createMock(IUser::class);
187
-		$this->userManager->expects($this->once())
188
-			->method('get')
189
-			->with('nope')
190
-			->willReturn($user);
191
-		$user->method('getEMailAddress')->willReturn('[email protected]');
192
-		$this->mailer->expects($this->once())
193
-			->method('send')
194
-			->willThrowException(new Exception());
195
-		$this->logger->expects($this->once())
196
-			->method('error');
197
-
198
-		$this->listener->handle($event);
199
-	}
200
-
201
-	public function testHandleRemoteWipeFinished(): void {
202
-		/** @var IToken|MockObject $token */
203
-		$token = $this->createMock(IToken::class);
204
-		$event = new RemoteWipeFinished($token);
205
-		$token->method('getUID')->willReturn('nope');
206
-		$user = $this->createMock(IUser::class);
207
-		$this->userManager->expects($this->once())
208
-			->method('get')
209
-			->with('nope')
210
-			->willReturn($user);
211
-		$user->method('getEMailAddress')->willReturn('[email protected]');
212
-		$message = $this->createMock(IMessage::class);
213
-		$this->mailer->expects($this->once())
214
-			->method('createMessage')
215
-			->willReturn($message);
216
-		$message->expects($this->once())
217
-			->method('setTo')
218
-			->with($this->equalTo(['[email protected]']));
219
-		$this->mailer->expects($this->once())
220
-			->method('send')
221
-			->with($message);
222
-
223
-		$this->listener->handle($event);
224
-	}
30
+    /** @var IMailer|MockObject */
31
+    private $mailer;
32
+
33
+    /** @var IUserManager|MockObject */
34
+    private $userManager;
35
+
36
+    /** @var IFactory|MockObject */
37
+    private $l10nFactory;
38
+
39
+    /** @var IL10N|MockObject */
40
+    private $l10n;
41
+
42
+    /** @var LoggerInterface|MockObject */
43
+    private $logger;
44
+
45
+    /** @var IEventListener */
46
+    private $listener;
47
+
48
+    protected function setUp(): void {
49
+        parent::setUp();
50
+
51
+        $this->mailer = $this->createMock(IMailer::class);
52
+        $this->userManager = $this->createMock(IUserManager::class);
53
+        $this->l10nFactory = $this->createMock(IFactory::class);
54
+        $this->l10n = $this->createMock(IL10N::class);
55
+        $this->logger = $this->createMock(LoggerInterface::class);
56
+
57
+        $this->l10nFactory->method('get')->with('core')->willReturn($this->l10n);
58
+        $this->l10n->method('t')->willReturnArgument(0);
59
+
60
+        $this->listener = new RemoteWipeEmailListener(
61
+            $this->mailer,
62
+            $this->userManager,
63
+            $this->l10nFactory,
64
+            $this->logger
65
+        );
66
+    }
67
+
68
+
69
+    public function testHandleUnrelated(): void {
70
+        $event = new Event();
71
+        $this->mailer->expects($this->never())->method('send');
72
+
73
+        $this->listener->handle($event);
74
+    }
75
+
76
+    public function testHandleRemoteWipeStartedInvalidUser(): void {
77
+        /** @var IToken|MockObject $token */
78
+        $token = $this->createMock(IToken::class);
79
+        $event = new RemoteWipeStarted($token);
80
+        $token->method('getUID')->willReturn('nope');
81
+        $this->userManager->expects($this->once())
82
+            ->method('get')
83
+            ->with('nope')
84
+            ->willReturn(null);
85
+        $this->mailer->expects($this->never())->method('send');
86
+
87
+        $this->listener->handle($event);
88
+    }
89
+
90
+    public function testHandleRemoteWipeStartedNoEmailSet(): void {
91
+        /** @var IToken|MockObject $token */
92
+        $token = $this->createMock(IToken::class);
93
+        $event = new RemoteWipeStarted($token);
94
+        $token->method('getUID')->willReturn('nope');
95
+        $user = $this->createMock(IUser::class);
96
+        $this->userManager->expects($this->once())
97
+            ->method('get')
98
+            ->with('nope')
99
+            ->willReturn($user);
100
+        $user->method('getEMailAddress')->willReturn(null);
101
+        $this->mailer->expects($this->never())->method('send');
102
+
103
+        $this->listener->handle($event);
104
+    }
105
+
106
+    public function testHandleRemoteWipeStartedTransmissionError(): void {
107
+        /** @var IToken|MockObject $token */
108
+        $token = $this->createMock(IToken::class);
109
+        $event = new RemoteWipeStarted($token);
110
+        $token->method('getUID')->willReturn('nope');
111
+        $user = $this->createMock(IUser::class);
112
+        $this->userManager->expects($this->once())
113
+            ->method('get')
114
+            ->with('nope')
115
+            ->willReturn($user);
116
+        $user->method('getEMailAddress')->willReturn('[email protected]');
117
+        $this->mailer->expects($this->once())
118
+            ->method('send')
119
+            ->willThrowException(new Exception());
120
+        $this->logger->expects($this->once())
121
+            ->method('error');
122
+
123
+        $this->listener->handle($event);
124
+    }
125
+
126
+    public function testHandleRemoteWipeStarted(): void {
127
+        /** @var IToken|MockObject $token */
128
+        $token = $this->createMock(IToken::class);
129
+        $event = new RemoteWipeStarted($token);
130
+        $token->method('getUID')->willReturn('nope');
131
+        $user = $this->createMock(IUser::class);
132
+        $this->userManager->expects($this->once())
133
+            ->method('get')
134
+            ->with('nope')
135
+            ->willReturn($user);
136
+        $user->method('getEMailAddress')->willReturn('[email protected]');
137
+        $message = $this->createMock(IMessage::class);
138
+        $this->mailer->expects($this->once())
139
+            ->method('createMessage')
140
+            ->willReturn($message);
141
+        $message->expects($this->once())
142
+            ->method('setTo')
143
+            ->with($this->equalTo(['[email protected]']));
144
+        $this->mailer->expects($this->once())
145
+            ->method('send')
146
+            ->with($message);
147
+
148
+        $this->listener->handle($event);
149
+    }
150
+
151
+    public function testHandleRemoteWipeFinishedInvalidUser(): void {
152
+        /** @var IToken|MockObject $token */
153
+        $token = $this->createMock(IToken::class);
154
+        $event = new RemoteWipeFinished($token);
155
+        $token->method('getUID')->willReturn('nope');
156
+        $this->userManager->expects($this->once())
157
+            ->method('get')
158
+            ->with('nope')
159
+            ->willReturn(null);
160
+        $this->mailer->expects($this->never())->method('send');
161
+
162
+        $this->listener->handle($event);
163
+    }
164
+
165
+    public function testHandleRemoteWipeFinishedNoEmailSet(): void {
166
+        /** @var IToken|MockObject $token */
167
+        $token = $this->createMock(IToken::class);
168
+        $event = new RemoteWipeFinished($token);
169
+        $token->method('getUID')->willReturn('nope');
170
+        $user = $this->createMock(IUser::class);
171
+        $this->userManager->expects($this->once())
172
+            ->method('get')
173
+            ->with('nope')
174
+            ->willReturn($user);
175
+        $user->method('getEMailAddress')->willReturn(null);
176
+        $this->mailer->expects($this->never())->method('send');
177
+
178
+        $this->listener->handle($event);
179
+    }
180
+
181
+    public function testHandleRemoteWipeFinishedTransmissionError(): void {
182
+        /** @var IToken|MockObject $token */
183
+        $token = $this->createMock(IToken::class);
184
+        $event = new RemoteWipeFinished($token);
185
+        $token->method('getUID')->willReturn('nope');
186
+        $user = $this->createMock(IUser::class);
187
+        $this->userManager->expects($this->once())
188
+            ->method('get')
189
+            ->with('nope')
190
+            ->willReturn($user);
191
+        $user->method('getEMailAddress')->willReturn('[email protected]');
192
+        $this->mailer->expects($this->once())
193
+            ->method('send')
194
+            ->willThrowException(new Exception());
195
+        $this->logger->expects($this->once())
196
+            ->method('error');
197
+
198
+        $this->listener->handle($event);
199
+    }
200
+
201
+    public function testHandleRemoteWipeFinished(): void {
202
+        /** @var IToken|MockObject $token */
203
+        $token = $this->createMock(IToken::class);
204
+        $event = new RemoteWipeFinished($token);
205
+        $token->method('getUID')->willReturn('nope');
206
+        $user = $this->createMock(IUser::class);
207
+        $this->userManager->expects($this->once())
208
+            ->method('get')
209
+            ->with('nope')
210
+            ->willReturn($user);
211
+        $user->method('getEMailAddress')->willReturn('[email protected]');
212
+        $message = $this->createMock(IMessage::class);
213
+        $this->mailer->expects($this->once())
214
+            ->method('createMessage')
215
+            ->willReturn($message);
216
+        $message->expects($this->once())
217
+            ->method('setTo')
218
+            ->with($this->equalTo(['[email protected]']));
219
+        $this->mailer->expects($this->once())
220
+            ->method('send')
221
+            ->with($message);
222
+
223
+        $this->listener->handle($event);
224
+    }
225 225
 }
Please login to merge, or discard this patch.
tests/lib/Authentication/Listeners/RemoteWipeNotificationsListenerTest.php 1 patch
Indentation   +108 added lines, -108 removed lines patch added patch discarded remove patch
@@ -23,112 +23,112 @@
 block discarded – undo
23 23
 use Test\TestCase;
24 24
 
25 25
 class RemoteWipeNotificationsListenerTest extends TestCase {
26
-	/** @var INotificationManager|MockObject */
27
-	private $notificationManager;
28
-
29
-	/** @var ITimeFactory|MockObject */
30
-	private $timeFactory;
31
-
32
-	/** @var IEventListener */
33
-	private $listener;
34
-
35
-	protected function setUp(): void {
36
-		parent::setUp();
37
-
38
-		$this->notificationManager = $this->createMock(INotificationManager::class);
39
-		$this->timeFactory = $this->createMock(ITimeFactory::class);
40
-
41
-		$this->listener = new RemoteWipeNotificationsListener(
42
-			$this->notificationManager,
43
-			$this->timeFactory
44
-		);
45
-	}
46
-
47
-	public function testHandleUnrelated(): void {
48
-		$event = new Event();
49
-
50
-		$this->listener->handle($event);
51
-
52
-		$this->addToAssertionCount(1);
53
-	}
54
-
55
-	public function testHandleRemoteWipeStarted(): void {
56
-		$token = $this->createMock(IToken::class);
57
-		$event = new RemoteWipeStarted($token);
58
-		$notification = $this->createMock(INotification::class);
59
-		$this->notificationManager->expects($this->once())
60
-			->method('createNotification')
61
-			->willReturn($notification);
62
-		$notification->expects($this->once())
63
-			->method('setApp')
64
-			->with('auth')
65
-			->willReturnSelf();
66
-		$token->method('getUID')->willReturn('user123');
67
-		$notification->expects($this->once())
68
-			->method('setUser')
69
-			->with('user123')
70
-			->willReturnSelf();
71
-		$now = new DateTime();
72
-		$this->timeFactory->method('getDateTime')->willReturn($now);
73
-		$notification->expects($this->once())
74
-			->method('setDateTime')
75
-			->with($now)
76
-			->willReturnSelf();
77
-		$token->method('getId')->willReturn(123);
78
-		$notification->expects($this->once())
79
-			->method('setObject')
80
-			->with('token', '123')
81
-			->willReturnSelf();
82
-		$token->method('getName')->willReturn('Token 1');
83
-		$notification->expects($this->once())
84
-			->method('setSubject')
85
-			->with('remote_wipe_start', [
86
-				'name' => 'Token 1'
87
-			])
88
-			->willReturnSelf();
89
-		$this->notificationManager->expects($this->once())
90
-			->method('notify');
91
-
92
-		$this->listener->handle($event);
93
-	}
94
-
95
-	public function testHandleRemoteWipeFinished(): void {
96
-		$token = $this->createMock(IToken::class);
97
-		$event = new RemoteWipeFinished($token);
98
-		$notification = $this->createMock(INotification::class);
99
-		$this->notificationManager->expects($this->once())
100
-			->method('createNotification')
101
-			->willReturn($notification);
102
-		$notification->expects($this->once())
103
-			->method('setApp')
104
-			->with('auth')
105
-			->willReturnSelf();
106
-		$token->method('getUID')->willReturn('user123');
107
-		$notification->expects($this->once())
108
-			->method('setUser')
109
-			->with('user123')
110
-			->willReturnSelf();
111
-		$now = new DateTime();
112
-		$this->timeFactory->method('getDateTime')->willReturn($now);
113
-		$notification->expects($this->once())
114
-			->method('setDateTime')
115
-			->with($now)
116
-			->willReturnSelf();
117
-		$token->method('getId')->willReturn(123);
118
-		$notification->expects($this->once())
119
-			->method('setObject')
120
-			->with('token', '123')
121
-			->willReturnSelf();
122
-		$token->method('getName')->willReturn('Token 1');
123
-		$notification->expects($this->once())
124
-			->method('setSubject')
125
-			->with('remote_wipe_finish', [
126
-				'name' => 'Token 1'
127
-			])
128
-			->willReturnSelf();
129
-		$this->notificationManager->expects($this->once())
130
-			->method('notify');
131
-
132
-		$this->listener->handle($event);
133
-	}
26
+    /** @var INotificationManager|MockObject */
27
+    private $notificationManager;
28
+
29
+    /** @var ITimeFactory|MockObject */
30
+    private $timeFactory;
31
+
32
+    /** @var IEventListener */
33
+    private $listener;
34
+
35
+    protected function setUp(): void {
36
+        parent::setUp();
37
+
38
+        $this->notificationManager = $this->createMock(INotificationManager::class);
39
+        $this->timeFactory = $this->createMock(ITimeFactory::class);
40
+
41
+        $this->listener = new RemoteWipeNotificationsListener(
42
+            $this->notificationManager,
43
+            $this->timeFactory
44
+        );
45
+    }
46
+
47
+    public function testHandleUnrelated(): void {
48
+        $event = new Event();
49
+
50
+        $this->listener->handle($event);
51
+
52
+        $this->addToAssertionCount(1);
53
+    }
54
+
55
+    public function testHandleRemoteWipeStarted(): void {
56
+        $token = $this->createMock(IToken::class);
57
+        $event = new RemoteWipeStarted($token);
58
+        $notification = $this->createMock(INotification::class);
59
+        $this->notificationManager->expects($this->once())
60
+            ->method('createNotification')
61
+            ->willReturn($notification);
62
+        $notification->expects($this->once())
63
+            ->method('setApp')
64
+            ->with('auth')
65
+            ->willReturnSelf();
66
+        $token->method('getUID')->willReturn('user123');
67
+        $notification->expects($this->once())
68
+            ->method('setUser')
69
+            ->with('user123')
70
+            ->willReturnSelf();
71
+        $now = new DateTime();
72
+        $this->timeFactory->method('getDateTime')->willReturn($now);
73
+        $notification->expects($this->once())
74
+            ->method('setDateTime')
75
+            ->with($now)
76
+            ->willReturnSelf();
77
+        $token->method('getId')->willReturn(123);
78
+        $notification->expects($this->once())
79
+            ->method('setObject')
80
+            ->with('token', '123')
81
+            ->willReturnSelf();
82
+        $token->method('getName')->willReturn('Token 1');
83
+        $notification->expects($this->once())
84
+            ->method('setSubject')
85
+            ->with('remote_wipe_start', [
86
+                'name' => 'Token 1'
87
+            ])
88
+            ->willReturnSelf();
89
+        $this->notificationManager->expects($this->once())
90
+            ->method('notify');
91
+
92
+        $this->listener->handle($event);
93
+    }
94
+
95
+    public function testHandleRemoteWipeFinished(): void {
96
+        $token = $this->createMock(IToken::class);
97
+        $event = new RemoteWipeFinished($token);
98
+        $notification = $this->createMock(INotification::class);
99
+        $this->notificationManager->expects($this->once())
100
+            ->method('createNotification')
101
+            ->willReturn($notification);
102
+        $notification->expects($this->once())
103
+            ->method('setApp')
104
+            ->with('auth')
105
+            ->willReturnSelf();
106
+        $token->method('getUID')->willReturn('user123');
107
+        $notification->expects($this->once())
108
+            ->method('setUser')
109
+            ->with('user123')
110
+            ->willReturnSelf();
111
+        $now = new DateTime();
112
+        $this->timeFactory->method('getDateTime')->willReturn($now);
113
+        $notification->expects($this->once())
114
+            ->method('setDateTime')
115
+            ->with($now)
116
+            ->willReturnSelf();
117
+        $token->method('getId')->willReturn(123);
118
+        $notification->expects($this->once())
119
+            ->method('setObject')
120
+            ->with('token', '123')
121
+            ->willReturnSelf();
122
+        $token->method('getName')->willReturn('Token 1');
123
+        $notification->expects($this->once())
124
+            ->method('setSubject')
125
+            ->with('remote_wipe_finish', [
126
+                'name' => 'Token 1'
127
+            ])
128
+            ->willReturnSelf();
129
+        $this->notificationManager->expects($this->once())
130
+            ->method('notify');
131
+
132
+        $this->listener->handle($event);
133
+    }
134 134
 }
Please login to merge, or discard this patch.
tests/lib/Authentication/Token/PublicKeyTokenTest.php 1 patch
Indentation   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -13,17 +13,17 @@
 block discarded – undo
13 13
 use Test\TestCase;
14 14
 
15 15
 class PublicKeyTokenTest extends TestCase {
16
-	public function testSetScopeAsArray(): void {
17
-		$scope = [IToken::SCOPE_FILESYSTEM => false];
18
-		$token = new PublicKeyToken();
19
-		$token->setScope($scope);
20
-		$this->assertEquals(json_encode($scope), $token->getScope());
21
-		$this->assertEquals($scope, $token->getScopeAsArray());
22
-	}
16
+    public function testSetScopeAsArray(): void {
17
+        $scope = [IToken::SCOPE_FILESYSTEM => false];
18
+        $token = new PublicKeyToken();
19
+        $token->setScope($scope);
20
+        $this->assertEquals(json_encode($scope), $token->getScope());
21
+        $this->assertEquals($scope, $token->getScopeAsArray());
22
+    }
23 23
 
24
-	public function testDefaultScope(): void {
25
-		$scope = [IToken::SCOPE_FILESYSTEM => true];
26
-		$token = new PublicKeyToken();
27
-		$this->assertEquals($scope, $token->getScopeAsArray());
28
-	}
24
+    public function testDefaultScope(): void {
25
+        $scope = [IToken::SCOPE_FILESYSTEM => true];
26
+        $token = new PublicKeyToken();
27
+        $this->assertEquals($scope, $token->getScopeAsArray());
28
+    }
29 29
 }
Please login to merge, or discard this patch.
tests/lib/Authentication/Token/RemoteWipeTest.php 1 patch
Indentation   +146 added lines, -146 removed lines patch added patch discarded remove patch
@@ -24,150 +24,150 @@
 block discarded – undo
24 24
 use Test\TestCase;
25 25
 
26 26
 class RemoteWipeTest extends TestCase {
27
-	/** @var ITokenProvider|MockObject */
28
-	private $tokenProvider;
29
-
30
-	/** @var IEventDispatcher|MockObject */
31
-	private $eventDispatcher;
32
-
33
-	/** @var LoggerInterface|MockObject */
34
-	private $logger;
35
-
36
-	/** @var RemoteWipe */
37
-	private $remoteWipe;
38
-
39
-	protected function setUp(): void {
40
-		parent::setUp();
41
-
42
-		$this->tokenProvider = $this->createMock(IProvider::class);
43
-		$this->eventDispatcher = $this->createMock(IEventDispatcher::class);
44
-		$this->logger = $this->createMock(LoggerInterface::class);
45
-
46
-		$this->remoteWipe = new RemoteWipe(
47
-			$this->tokenProvider,
48
-			$this->eventDispatcher,
49
-			$this->logger
50
-		);
51
-	}
52
-
53
-	public function testMarkNonWipableTokenForWipe(): void {
54
-		$token = $this->createMock(IToken::class);
55
-		$result = $this->remoteWipe->markTokenForWipe($token);
56
-		$this->assertFalse($result);
57
-	}
58
-
59
-	public function testMarkTokenForWipe(): void {
60
-		$token = $this->createMock(IWipeableToken::class);
61
-		$token->expects($this->once())
62
-			->method('wipe');
63
-
64
-		$this->tokenProvider->expects($this->once())
65
-			->method('updateToken')
66
-			->with($token);
67
-
68
-		$result = $this->remoteWipe->markTokenForWipe($token);
69
-		$this->assertTrue($result);
70
-	}
71
-
72
-	public function testMarkAllTokensForWipeNoWipeableToken(): void {
73
-		/** @var IUser|MockObject $user */
74
-		$user = $this->createMock(IUser::class);
75
-		$user->method('getUID')->willReturn('user123');
76
-		$token1 = $this->createMock(IToken::class);
77
-		$token2 = $this->createMock(IToken::class);
78
-		$this->tokenProvider->expects($this->once())
79
-			->method('getTokenByUser')
80
-			->with('user123')
81
-			->willReturn([$token1, $token2]);
82
-
83
-		$result = $this->remoteWipe->markAllTokensForWipe($user);
84
-
85
-		$this->assertFalse($result);
86
-	}
87
-
88
-	public function testMarkAllTokensForWipe(): void {
89
-		/** @var IUser|MockObject $user */
90
-		$user = $this->createMock(IUser::class);
91
-		$user->method('getUID')->willReturn('user123');
92
-		$token1 = $this->createMock(IToken::class);
93
-		$token2 = $this->createMock(IWipeableToken::class);
94
-		$this->tokenProvider->expects($this->once())
95
-			->method('getTokenByUser')
96
-			->with('user123')
97
-			->willReturn([$token1, $token2]);
98
-		$token2->expects($this->once())
99
-			->method('wipe');
100
-		$this->tokenProvider->expects($this->once())
101
-			->method('updateToken')
102
-			->with($token2);
103
-
104
-		$result = $this->remoteWipe->markAllTokensForWipe($user);
105
-
106
-		$this->assertTrue($result);
107
-	}
108
-
109
-	public function testStartWipingNotAWipeToken(): void {
110
-		$token = $this->createMock(IToken::class);
111
-		$this->tokenProvider->expects($this->once())
112
-			->method('getToken')
113
-			->with('tk1')
114
-			->willReturn($token);
115
-		$this->eventDispatcher->expects($this->never())
116
-			->method('dispatch');
117
-
118
-		$result = $this->remoteWipe->start('tk1');
119
-
120
-		$this->assertFalse($result);
121
-	}
122
-
123
-	public function testStartWiping(): void {
124
-		$token = $this->createMock(IToken::class);
125
-		$this->tokenProvider->expects($this->once())
126
-			->method('getToken')
127
-			->with('tk1')
128
-			->willThrowException(new WipeTokenException($token));
129
-		$this->eventDispatcher->expects($this->once())
130
-			->method('dispatch');
131
-		$this->eventDispatcher->expects($this->once())
132
-			->method('dispatch')
133
-			->with(RemoteWipeStarted::class, $this->equalTo(new RemoteWipeStarted($token)));
134
-
135
-		$result = $this->remoteWipe->start('tk1');
136
-
137
-		$this->assertTrue($result);
138
-	}
139
-
140
-	public function testFinishWipingNotAWipeToken(): void {
141
-		$token = $this->createMock(IToken::class);
142
-		$this->tokenProvider->expects($this->once())
143
-			->method('getToken')
144
-			->with('tk1')
145
-			->willReturn($token);
146
-		$this->eventDispatcher->expects($this->never())
147
-			->method('dispatch');
148
-
149
-		$result = $this->remoteWipe->finish('tk1');
150
-
151
-		$this->assertFalse($result);
152
-	}
153
-
154
-	public function startFinishWiping() {
155
-		$token = $this->createMock(IToken::class);
156
-		$this->tokenProvider->expects($this->once())
157
-			->method('getToken')
158
-			->with('tk1')
159
-			->willThrowException(new WipeTokenException($token));
160
-		$this->eventDispatcher->expects($this->once())
161
-			->method('dispatch');
162
-		$this->tokenProvider->expects($this->once())
163
-			->method('invalidateToken')
164
-			->with($token);
165
-		$this->eventDispatcher->expects($this->once())
166
-			->method('dispatch')
167
-			->with(RemoteWipeFinished::class, $this->equalTo(new RemoteWipeFinished($token)));
168
-
169
-		$result = $this->remoteWipe->finish('tk1');
170
-
171
-		$this->assertTrue($result);
172
-	}
27
+    /** @var ITokenProvider|MockObject */
28
+    private $tokenProvider;
29
+
30
+    /** @var IEventDispatcher|MockObject */
31
+    private $eventDispatcher;
32
+
33
+    /** @var LoggerInterface|MockObject */
34
+    private $logger;
35
+
36
+    /** @var RemoteWipe */
37
+    private $remoteWipe;
38
+
39
+    protected function setUp(): void {
40
+        parent::setUp();
41
+
42
+        $this->tokenProvider = $this->createMock(IProvider::class);
43
+        $this->eventDispatcher = $this->createMock(IEventDispatcher::class);
44
+        $this->logger = $this->createMock(LoggerInterface::class);
45
+
46
+        $this->remoteWipe = new RemoteWipe(
47
+            $this->tokenProvider,
48
+            $this->eventDispatcher,
49
+            $this->logger
50
+        );
51
+    }
52
+
53
+    public function testMarkNonWipableTokenForWipe(): void {
54
+        $token = $this->createMock(IToken::class);
55
+        $result = $this->remoteWipe->markTokenForWipe($token);
56
+        $this->assertFalse($result);
57
+    }
58
+
59
+    public function testMarkTokenForWipe(): void {
60
+        $token = $this->createMock(IWipeableToken::class);
61
+        $token->expects($this->once())
62
+            ->method('wipe');
63
+
64
+        $this->tokenProvider->expects($this->once())
65
+            ->method('updateToken')
66
+            ->with($token);
67
+
68
+        $result = $this->remoteWipe->markTokenForWipe($token);
69
+        $this->assertTrue($result);
70
+    }
71
+
72
+    public function testMarkAllTokensForWipeNoWipeableToken(): void {
73
+        /** @var IUser|MockObject $user */
74
+        $user = $this->createMock(IUser::class);
75
+        $user->method('getUID')->willReturn('user123');
76
+        $token1 = $this->createMock(IToken::class);
77
+        $token2 = $this->createMock(IToken::class);
78
+        $this->tokenProvider->expects($this->once())
79
+            ->method('getTokenByUser')
80
+            ->with('user123')
81
+            ->willReturn([$token1, $token2]);
82
+
83
+        $result = $this->remoteWipe->markAllTokensForWipe($user);
84
+
85
+        $this->assertFalse($result);
86
+    }
87
+
88
+    public function testMarkAllTokensForWipe(): void {
89
+        /** @var IUser|MockObject $user */
90
+        $user = $this->createMock(IUser::class);
91
+        $user->method('getUID')->willReturn('user123');
92
+        $token1 = $this->createMock(IToken::class);
93
+        $token2 = $this->createMock(IWipeableToken::class);
94
+        $this->tokenProvider->expects($this->once())
95
+            ->method('getTokenByUser')
96
+            ->with('user123')
97
+            ->willReturn([$token1, $token2]);
98
+        $token2->expects($this->once())
99
+            ->method('wipe');
100
+        $this->tokenProvider->expects($this->once())
101
+            ->method('updateToken')
102
+            ->with($token2);
103
+
104
+        $result = $this->remoteWipe->markAllTokensForWipe($user);
105
+
106
+        $this->assertTrue($result);
107
+    }
108
+
109
+    public function testStartWipingNotAWipeToken(): void {
110
+        $token = $this->createMock(IToken::class);
111
+        $this->tokenProvider->expects($this->once())
112
+            ->method('getToken')
113
+            ->with('tk1')
114
+            ->willReturn($token);
115
+        $this->eventDispatcher->expects($this->never())
116
+            ->method('dispatch');
117
+
118
+        $result = $this->remoteWipe->start('tk1');
119
+
120
+        $this->assertFalse($result);
121
+    }
122
+
123
+    public function testStartWiping(): void {
124
+        $token = $this->createMock(IToken::class);
125
+        $this->tokenProvider->expects($this->once())
126
+            ->method('getToken')
127
+            ->with('tk1')
128
+            ->willThrowException(new WipeTokenException($token));
129
+        $this->eventDispatcher->expects($this->once())
130
+            ->method('dispatch');
131
+        $this->eventDispatcher->expects($this->once())
132
+            ->method('dispatch')
133
+            ->with(RemoteWipeStarted::class, $this->equalTo(new RemoteWipeStarted($token)));
134
+
135
+        $result = $this->remoteWipe->start('tk1');
136
+
137
+        $this->assertTrue($result);
138
+    }
139
+
140
+    public function testFinishWipingNotAWipeToken(): void {
141
+        $token = $this->createMock(IToken::class);
142
+        $this->tokenProvider->expects($this->once())
143
+            ->method('getToken')
144
+            ->with('tk1')
145
+            ->willReturn($token);
146
+        $this->eventDispatcher->expects($this->never())
147
+            ->method('dispatch');
148
+
149
+        $result = $this->remoteWipe->finish('tk1');
150
+
151
+        $this->assertFalse($result);
152
+    }
153
+
154
+    public function startFinishWiping() {
155
+        $token = $this->createMock(IToken::class);
156
+        $this->tokenProvider->expects($this->once())
157
+            ->method('getToken')
158
+            ->with('tk1')
159
+            ->willThrowException(new WipeTokenException($token));
160
+        $this->eventDispatcher->expects($this->once())
161
+            ->method('dispatch');
162
+        $this->tokenProvider->expects($this->once())
163
+            ->method('invalidateToken')
164
+            ->with($token);
165
+        $this->eventDispatcher->expects($this->once())
166
+            ->method('dispatch')
167
+            ->with(RemoteWipeFinished::class, $this->equalTo(new RemoteWipeFinished($token)));
168
+
169
+        $result = $this->remoteWipe->finish('tk1');
170
+
171
+        $this->assertTrue($result);
172
+    }
173 173
 }
Please login to merge, or discard this patch.
tests/lib/Contacts/ContactsMenu/Actions/LinkActionTest.php 1 patch
Indentation   +76 added lines, -76 removed lines patch added patch discarded remove patch
@@ -11,80 +11,80 @@
 block discarded – undo
11 11
 use Test\TestCase;
12 12
 
13 13
 class LinkActionTest extends TestCase {
14
-	private LinkAction $action;
15
-
16
-	protected function setUp(): void {
17
-		parent::setUp();
18
-
19
-		$this->action = new LinkAction();
20
-	}
21
-
22
-	public function testSetIcon(): void {
23
-		$icon = 'icon-test';
24
-
25
-		$this->action->setIcon($icon);
26
-		$json = $this->action->jsonSerialize();
27
-
28
-		$this->assertArrayHasKey('icon', $json);
29
-		$this->assertEquals($json['icon'], $icon);
30
-	}
31
-
32
-	public function testGetSetName(): void {
33
-		$name = 'Jane Doe';
34
-
35
-		$this->assertEmpty($this->action->getName());
36
-		$this->action->setName($name);
37
-		$this->assertEquals($name, $this->action->getName());
38
-	}
39
-
40
-	public function testGetSetPriority(): void {
41
-		$prio = 50;
42
-
43
-		$this->assertEquals(10, $this->action->getPriority());
44
-		$this->action->setPriority($prio);
45
-		$this->assertEquals($prio, $this->action->getPriority());
46
-	}
47
-
48
-	public function testSetHref(): void {
49
-		$this->action->setHref('/some/url');
50
-
51
-		$json = $this->action->jsonSerialize();
52
-		$this->assertArrayHasKey('hyperlink', $json);
53
-		$this->assertEquals('/some/url', $json['hyperlink']);
54
-	}
55
-
56
-	public function testJsonSerialize(): void {
57
-		$this->action->setIcon('icon-contacts');
58
-		$this->action->setName('Nickie Works');
59
-		$this->action->setPriority(33);
60
-		$this->action->setHref('example.com');
61
-		$this->action->setAppId('contacts');
62
-		$expected = [
63
-			'title' => 'Nickie Works',
64
-			'icon' => 'icon-contacts',
65
-			'hyperlink' => 'example.com',
66
-			'appId' => 'contacts',
67
-		];
68
-
69
-		$json = $this->action->jsonSerialize();
70
-
71
-		$this->assertEquals($expected, $json);
72
-	}
73
-
74
-	public function testJsonSerializeNoAppName(): void {
75
-		$this->action->setIcon('icon-contacts');
76
-		$this->action->setName('Nickie Works');
77
-		$this->action->setPriority(33);
78
-		$this->action->setHref('example.com');
79
-		$expected = [
80
-			'title' => 'Nickie Works',
81
-			'icon' => 'icon-contacts',
82
-			'hyperlink' => 'example.com',
83
-			'appId' => '',
84
-		];
85
-
86
-		$json = $this->action->jsonSerialize();
87
-
88
-		$this->assertEquals($expected, $json);
89
-	}
14
+    private LinkAction $action;
15
+
16
+    protected function setUp(): void {
17
+        parent::setUp();
18
+
19
+        $this->action = new LinkAction();
20
+    }
21
+
22
+    public function testSetIcon(): void {
23
+        $icon = 'icon-test';
24
+
25
+        $this->action->setIcon($icon);
26
+        $json = $this->action->jsonSerialize();
27
+
28
+        $this->assertArrayHasKey('icon', $json);
29
+        $this->assertEquals($json['icon'], $icon);
30
+    }
31
+
32
+    public function testGetSetName(): void {
33
+        $name = 'Jane Doe';
34
+
35
+        $this->assertEmpty($this->action->getName());
36
+        $this->action->setName($name);
37
+        $this->assertEquals($name, $this->action->getName());
38
+    }
39
+
40
+    public function testGetSetPriority(): void {
41
+        $prio = 50;
42
+
43
+        $this->assertEquals(10, $this->action->getPriority());
44
+        $this->action->setPriority($prio);
45
+        $this->assertEquals($prio, $this->action->getPriority());
46
+    }
47
+
48
+    public function testSetHref(): void {
49
+        $this->action->setHref('/some/url');
50
+
51
+        $json = $this->action->jsonSerialize();
52
+        $this->assertArrayHasKey('hyperlink', $json);
53
+        $this->assertEquals('/some/url', $json['hyperlink']);
54
+    }
55
+
56
+    public function testJsonSerialize(): void {
57
+        $this->action->setIcon('icon-contacts');
58
+        $this->action->setName('Nickie Works');
59
+        $this->action->setPriority(33);
60
+        $this->action->setHref('example.com');
61
+        $this->action->setAppId('contacts');
62
+        $expected = [
63
+            'title' => 'Nickie Works',
64
+            'icon' => 'icon-contacts',
65
+            'hyperlink' => 'example.com',
66
+            'appId' => 'contacts',
67
+        ];
68
+
69
+        $json = $this->action->jsonSerialize();
70
+
71
+        $this->assertEquals($expected, $json);
72
+    }
73
+
74
+    public function testJsonSerializeNoAppName(): void {
75
+        $this->action->setIcon('icon-contacts');
76
+        $this->action->setName('Nickie Works');
77
+        $this->action->setPriority(33);
78
+        $this->action->setHref('example.com');
79
+        $expected = [
80
+            'title' => 'Nickie Works',
81
+            'icon' => 'icon-contacts',
82
+            'hyperlink' => 'example.com',
83
+            'appId' => '',
84
+        ];
85
+
86
+        $json = $this->action->jsonSerialize();
87
+
88
+        $this->assertEquals($expected, $json);
89
+    }
90 90
 }
Please login to merge, or discard this patch.
tests/lib/Contacts/ContactsMenu/Providers/EMailproviderTest.php 1 patch
Indentation   +57 added lines, -57 removed lines patch added patch discarded remove patch
@@ -16,70 +16,70 @@
 block discarded – undo
16 16
 use Test\TestCase;
17 17
 
18 18
 class EMailproviderTest extends TestCase {
19
-	/** @var IActionFactory|MockObject */
20
-	private $actionFactory;
19
+    /** @var IActionFactory|MockObject */
20
+    private $actionFactory;
21 21
 
22
-	/** @var IURLGenerator|MockObject */
23
-	private $urlGenerator;
22
+    /** @var IURLGenerator|MockObject */
23
+    private $urlGenerator;
24 24
 
25
-	private EMailProvider $provider;
25
+    private EMailProvider $provider;
26 26
 
27
-	protected function setUp(): void {
28
-		parent::setUp();
27
+    protected function setUp(): void {
28
+        parent::setUp();
29 29
 
30
-		$this->actionFactory = $this->createMock(IActionFactory::class);
31
-		$this->urlGenerator = $this->createMock(IURLGenerator::class);
30
+        $this->actionFactory = $this->createMock(IActionFactory::class);
31
+        $this->urlGenerator = $this->createMock(IURLGenerator::class);
32 32
 
33
-		$this->provider = new EMailProvider($this->actionFactory, $this->urlGenerator);
34
-	}
33
+        $this->provider = new EMailProvider($this->actionFactory, $this->urlGenerator);
34
+    }
35 35
 
36
-	public function testProcess(): void {
37
-		$entry = $this->createMock(IEntry::class);
38
-		$action = $this->createMock(ILinkAction::class);
39
-		$iconUrl = 'https://example.com/img/actions/icon.svg';
40
-		$this->urlGenerator->expects($this->once())
41
-			->method('imagePath')
42
-			->willReturn('img/actions/icon.svg');
43
-		$this->urlGenerator->expects($this->once())
44
-			->method('getAbsoluteURL')
45
-			->with('img/actions/icon.svg')
46
-			->willReturn($iconUrl);
47
-		$entry->expects($this->once())
48
-			->method('getEMailAddresses')
49
-			->willReturn([
50
-				'[email protected]',
51
-			]);
52
-		$this->actionFactory->expects($this->once())
53
-			->method('newEMailAction')
54
-			->with($this->equalTo($iconUrl), $this->equalTo('[email protected]'), $this->equalTo('[email protected]'))
55
-			->willReturn($action);
56
-		$entry->expects($this->once())
57
-			->method('addAction')
58
-			->with($action);
36
+    public function testProcess(): void {
37
+        $entry = $this->createMock(IEntry::class);
38
+        $action = $this->createMock(ILinkAction::class);
39
+        $iconUrl = 'https://example.com/img/actions/icon.svg';
40
+        $this->urlGenerator->expects($this->once())
41
+            ->method('imagePath')
42
+            ->willReturn('img/actions/icon.svg');
43
+        $this->urlGenerator->expects($this->once())
44
+            ->method('getAbsoluteURL')
45
+            ->with('img/actions/icon.svg')
46
+            ->willReturn($iconUrl);
47
+        $entry->expects($this->once())
48
+            ->method('getEMailAddresses')
49
+            ->willReturn([
50
+                '[email protected]',
51
+            ]);
52
+        $this->actionFactory->expects($this->once())
53
+            ->method('newEMailAction')
54
+            ->with($this->equalTo($iconUrl), $this->equalTo('[email protected]'), $this->equalTo('[email protected]'))
55
+            ->willReturn($action);
56
+        $entry->expects($this->once())
57
+            ->method('addAction')
58
+            ->with($action);
59 59
 
60
-		$this->provider->process($entry);
61
-	}
60
+        $this->provider->process($entry);
61
+    }
62 62
 
63
-	public function testProcessEmptyAddress(): void {
64
-		$entry = $this->createMock(IEntry::class);
65
-		$iconUrl = 'https://example.com/img/actions/icon.svg';
66
-		$this->urlGenerator->expects($this->once())
67
-			->method('imagePath')
68
-			->willReturn('img/actions/icon.svg');
69
-		$this->urlGenerator->expects($this->once())
70
-			->method('getAbsoluteURL')
71
-			->with('img/actions/icon.svg')
72
-			->willReturn($iconUrl);
73
-		$entry->expects($this->once())
74
-			->method('getEMailAddresses')
75
-			->willReturn([
76
-				'',
77
-			]);
78
-		$this->actionFactory->expects($this->never())
79
-			->method('newEMailAction');
80
-		$entry->expects($this->never())
81
-			->method('addAction');
63
+    public function testProcessEmptyAddress(): void {
64
+        $entry = $this->createMock(IEntry::class);
65
+        $iconUrl = 'https://example.com/img/actions/icon.svg';
66
+        $this->urlGenerator->expects($this->once())
67
+            ->method('imagePath')
68
+            ->willReturn('img/actions/icon.svg');
69
+        $this->urlGenerator->expects($this->once())
70
+            ->method('getAbsoluteURL')
71
+            ->with('img/actions/icon.svg')
72
+            ->willReturn($iconUrl);
73
+        $entry->expects($this->once())
74
+            ->method('getEMailAddresses')
75
+            ->willReturn([
76
+                '',
77
+            ]);
78
+        $this->actionFactory->expects($this->never())
79
+            ->method('newEMailAction');
80
+        $entry->expects($this->never())
81
+            ->method('addAction');
82 82
 
83
-		$this->provider->process($entry);
84
-	}
83
+        $this->provider->process($entry);
84
+    }
85 85
 }
Please login to merge, or discard this patch.