2020use OCP \Mail \IMailer ;
2121use OCP \Security \ISecureRandom ;
2222use OCP \UserInterface ;
23+ use PHPUnit \Framework \MockObject \MockObject ;
24+ use Psr \Log \LoggerInterface ;
2325use Symfony \Component \Console \Formatter \OutputFormatterInterface ;
2426use Symfony \Component \Console \Helper \ProgressBar ;
2527use Symfony \Component \Console \Helper \QuestionHelper ;
2830use Test \TestCase ;
2931
3032class EncryptAllTest extends TestCase {
31-
32- /** @var \PHPUnit\Framework\MockObject\MockObject|KeyManager */
33- protected $ keyManager ;
34-
35- /** @var \PHPUnit\Framework\MockObject\MockObject|Util */
36- protected $ util ;
37-
38- /** @var \PHPUnit\Framework\MockObject\MockObject|IUserManager */
39- protected $ userManager ;
40-
41- /** @var \PHPUnit\Framework\MockObject\MockObject|Setup */
42- protected $ setupUser ;
43-
44- /** @var \PHPUnit\Framework\MockObject\MockObject|View */
45- protected $ view ;
46-
47- /** @var \PHPUnit\Framework\MockObject\MockObject|IConfig */
48- protected $ config ;
49-
50- /** @var \PHPUnit\Framework\MockObject\MockObject|IMailer */
51- protected $ mailer ;
52-
53- /** @var \PHPUnit\Framework\MockObject\MockObject|IL10N */
54- protected $ l ;
55-
56- /** @var \PHPUnit\Framework\MockObject\MockObject | IFactory */
57- protected $ l10nFactory ;
58-
59- /** @var \PHPUnit\Framework\MockObject\MockObject | \Symfony\Component\Console\Helper\QuestionHelper */
60- protected $ questionHelper ;
61-
62- /** @var \PHPUnit\Framework\MockObject\MockObject | \Symfony\Component\Console\Input\InputInterface */
63- protected $ inputInterface ;
64-
65- /** @var \PHPUnit\Framework\MockObject\MockObject | \Symfony\Component\Console\Output\OutputInterface */
66- protected $ outputInterface ;
67-
68- /** @var \PHPUnit\Framework\MockObject\MockObject|UserInterface */
69- protected $ userInterface ;
70-
71- /** @var \PHPUnit\Framework\MockObject\MockObject|ISecureRandom */
72- protected $ secureRandom ;
33+ protected KeyManager &MockObject $ keyManager ;
34+ protected Util &MockObject $ util ;
35+ protected IUserManager &MockObject $ userManager ;
36+ protected Setup &MockObject $ setupUser ;
37+ protected View &MockObject $ view ;
38+ protected IConfig &MockObject $ config ;
39+ protected IMailer &MockObject $ mailer ;
40+ protected IL10N &MockObject $ l ;
41+ protected IFactory &MockObject $ l10nFactory ;
42+ protected \Symfony \Component \Console \Helper \QuestionHelper &MockObject $ questionHelper ;
43+ protected \Symfony \Component \Console \Input \InputInterface &MockObject $ inputInterface ;
44+ protected \Symfony \Component \Console \Output \OutputInterface &MockObject $ outputInterface ;
45+ protected UserInterface &MockObject $ userInterface ;
46+ protected ISecureRandom &MockObject $ secureRandom ;
47+ protected LoggerInterface &MockObject $ logger ;
7348
7449 /** @var EncryptAll */
7550 protected $ encryptAll ;
@@ -101,6 +76,7 @@ protected function setUp(): void {
10176 ->disableOriginalConstructor ()->getMock ();
10277 $ this ->userInterface = $ this ->getMockBuilder (UserInterface::class)
10378 ->disableOriginalConstructor ()->getMock ();
79+ $ this ->logger = $ this ->createMock (LoggerInterface::class);
10480
10581 /**
10682 * We need format method to return a string
@@ -131,12 +107,13 @@ protected function setUp(): void {
131107 $ this ->l ,
132108 $ this ->l10nFactory ,
133109 $ this ->questionHelper ,
134- $ this ->secureRandom
110+ $ this ->secureRandom ,
111+ $ this ->logger ,
135112 );
136113 }
137114
138115 public function testEncryptAll (): void {
139- /** @var EncryptAll | \PHPUnit\Framework\ MockObject\MockObject $encryptAll */
116+ /** @var EncryptAll& MockObject $encryptAll */
140117 $ encryptAll = $ this ->getMockBuilder (EncryptAll::class)
141118 ->setConstructorArgs (
142119 [
@@ -150,7 +127,8 @@ public function testEncryptAll(): void {
150127 $ this ->l ,
151128 $ this ->l10nFactory ,
152129 $ this ->questionHelper ,
153- $ this ->secureRandom
130+ $ this ->secureRandom ,
131+ $ this ->logger ,
154132 ]
155133 )
156134 ->setMethods (['createKeyPairs ' , 'encryptAllUsersFiles ' , 'outputPasswords ' ])
@@ -165,7 +143,7 @@ public function testEncryptAll(): void {
165143 }
166144
167145 public function testEncryptAllWithMasterKey (): void {
168- /** @var EncryptAll | \PHPUnit\Framework\ MockObject\MockObject $encryptAll */
146+ /** @var EncryptAll& MockObject $encryptAll */
169147 $ encryptAll = $ this ->getMockBuilder (EncryptAll::class)
170148 ->setConstructorArgs (
171149 [
@@ -179,7 +157,8 @@ public function testEncryptAllWithMasterKey(): void {
179157 $ this ->l ,
180158 $ this ->l10nFactory ,
181159 $ this ->questionHelper ,
182- $ this ->secureRandom
160+ $ this ->secureRandom ,
161+ $ this ->logger ,
183162 ]
184163 )
185164 ->setMethods (['createKeyPairs ' , 'encryptAllUsersFiles ' , 'outputPasswords ' ])
@@ -195,7 +174,7 @@ public function testEncryptAllWithMasterKey(): void {
195174 }
196175
197176 public function testCreateKeyPairs (): void {
198- /** @var EncryptAll | \PHPUnit\Framework\ MockObject\MockObject $encryptAll */
177+ /** @var EncryptAll& MockObject $encryptAll */
199178 $ encryptAll = $ this ->getMockBuilder (EncryptAll::class)
200179 ->setConstructorArgs (
201180 [
@@ -209,7 +188,8 @@ public function testCreateKeyPairs(): void {
209188 $ this ->l ,
210189 $ this ->l10nFactory ,
211190 $ this ->questionHelper ,
212- $ this ->secureRandom
191+ $ this ->secureRandom ,
192+ $ this ->logger ,
213193 ]
214194 )
215195 ->setMethods (['setupUserFS ' , 'generateOneTimePassword ' ])
@@ -259,7 +239,8 @@ public function testEncryptAllUsersFiles(): void {
259239 $ this ->l ,
260240 $ this ->l10nFactory ,
261241 $ this ->questionHelper ,
262- $ this ->secureRandom
242+ $ this ->secureRandom ,
243+ $ this ->logger ,
263244 ]
264245 )
265246 ->setMethods (['encryptUsersFiles ' ])
@@ -295,7 +276,8 @@ public function testEncryptUsersFiles(): void {
295276 $ this ->l ,
296277 $ this ->l10nFactory ,
297278 $ this ->questionHelper ,
298- $ this ->secureRandom
279+ $ this ->secureRandom ,
280+ $ this ->logger ,
299281 ]
300282 )
301283 ->setMethods (['encryptFile ' , 'setupUserFS ' ])
0 commit comments