1010
1111use OC \Core \Command \Encryption \DecryptAll ;
1212use OCP \App \IAppManager ;
13- use OCP \IAppConfig ;
1413use OCP \IConfig ;
1514use PHPUnit \Framework \MockObject \MockObject ;
1615use Symfony \Component \Console \Helper \QuestionHelper ;
2019
2120class DecryptAllTest extends TestCase {
2221 private MockObject &IConfig $ config ;
23- private MockObject &IAppConfig $ appConfig ;
2422 private MockObject &IAppManager $ appManager ;
2523 private MockObject &InputInterface $ consoleInput ;
2624 private MockObject &OutputInterface $ consoleOutput ;
@@ -31,7 +29,6 @@ protected function setUp(): void {
3129 parent ::setUp ();
3230
3331 $ this ->config = $ this ->createMock (IConfig::class);
34- $ this ->appConfig = $ this ->createMock (IAppConfig::class);
3532 $ this ->appManager = $ this ->createMock (IAppManager::class);
3633 $ this ->questionHelper = $ this ->createMock (QuestionHelper::class);
3734 $ this ->decryptAll = $ this ->createMock (\OC \Encryption \DecryptAll::class);
@@ -74,7 +71,6 @@ public function testMaintenanceAndTrashbin(): void {
7471 $ instance = new DecryptAll (
7572 $ this ->appManager ,
7673 $ this ->config ,
77- $ this ->appConfig ,
7874 $ this ->decryptAll ,
7975 $ this ->questionHelper
8076 );
@@ -95,15 +91,14 @@ public function testExecute($encryptionEnabled, $continue): void {
9591 $ instance = new DecryptAll (
9692 $ this ->appManager ,
9793 $ this ->config ,
98- $ this ->appConfig ,
9994 $ this ->decryptAll ,
10095 $ this ->questionHelper
10196 );
10297
103- $ this ->appConfig ->expects ($ this ->once ())
104- ->method ('getValueBool ' )
105- ->with ('core ' , 'encryption_enabled ' )
106- ->willReturn ($ encryptionEnabled );
98+ $ this ->config ->expects ($ this ->once ())
99+ ->method ('getAppValue ' )
100+ ->with ('core ' , 'encryption_enabled ' , ' no ' )
101+ ->willReturn ($ encryptionEnabled ? ' yes ' : ' no ' );
107102
108103 $ this ->consoleInput ->expects ($ this ->any ())
109104 ->method ('getArgument ' )
@@ -112,19 +107,18 @@ public function testExecute($encryptionEnabled, $continue): void {
112107
113108 if ($ encryptionEnabled ) {
114109 $ calls = [
115- ['core ' , 'encryption_enabled ' , false , false ],
116- ['core ' , 'encryption_enabled ' , true , false ],
110+ ['core ' , 'encryption_enabled ' , ' no ' ],
111+ ['core ' , 'encryption_enabled ' , ' yes ' ],
117112 ];
118- $ this ->appConfig ->expects ($ this ->exactly (count ($ calls )))
119- ->method ('setValueBool ' )
120- ->willReturnCallback (function () use (&$ calls ): bool {
113+ $ this ->config ->expects ($ this ->exactly (count ($ calls )))
114+ ->method ('setAppValue ' )
115+ ->willReturnCallback (function () use (&$ calls ): void {
121116 $ expected = array_shift ($ calls );
122117 $ this ->assertEquals ($ expected , func_get_args ());
123- return true ;
124118 });
125119 } else {
126- $ this ->appConfig ->expects ($ this ->never ())
127- ->method ('setValueBool ' );
120+ $ this ->config ->expects ($ this ->never ())
121+ ->method ('setAppValue ' );
128122 }
129123 $ this ->questionHelper ->expects ($ this ->once ())
130124 ->method ('ask ' )
@@ -156,27 +150,25 @@ public function testExecuteFailure(): void {
156150 $ instance = new DecryptAll (
157151 $ this ->appManager ,
158152 $ this ->config ,
159- $ this ->appConfig ,
160153 $ this ->decryptAll ,
161154 $ this ->questionHelper
162155 );
163156
164157 // make sure that we enable encryption again after a exception was thrown
165158 $ calls = [
166- ['core ' , 'encryption_enabled ' , false , false ],
167- ['core ' , 'encryption_enabled ' , true , false ],
159+ ['core ' , 'encryption_enabled ' , ' no ' ],
160+ ['core ' , 'encryption_enabled ' , ' yes ' ],
168161 ];
169- $ this ->appConfig ->expects ($ this ->exactly (2 ))
170- ->method ('setValuebool ' )
171- ->willReturnCallback (function () use (&$ calls ): bool {
162+ $ this ->config ->expects ($ this ->exactly (2 ))
163+ ->method ('setAppValue ' )
164+ ->willReturnCallback (function () use (&$ calls ): void {
172165 $ expected = array_shift ($ calls );
173166 $ this ->assertEquals ($ expected , func_get_args ());
174- return true ;
175167 });
176- $ this ->appConfig ->expects ($ this ->once ())
177- ->method ('getValueBool ' )
178- ->with ('core ' , 'encryption_enabled ' )
179- ->willReturn (true );
168+ $ this ->config ->expects ($ this ->once ())
169+ ->method ('getAppValue ' )
170+ ->with ('core ' , 'encryption_enabled ' , ' no ' )
171+ ->willReturn (' yes ' );
180172
181173 $ this ->consoleInput ->expects ($ this ->any ())
182174 ->method ('getArgument ' )
0 commit comments