@@ -55,7 +55,6 @@ public function testCleanup(): void {
5555
5656 $ appDataFolder = $ this ->createMock (Folder::class);
5757 $ appDataFolder ->expects ($ this ->once ())->method ('get ' )->with ('preview ' )->willReturn ($ previewFolder );
58- $ appDataFolder ->expects ($ this ->once ())->method ('newFolder ' )->with ('preview ' );
5958
6059 $ this ->rootFolder ->expects ($ this ->once ())
6160 ->method ('getAppDataDirectoryName ' )
@@ -66,22 +65,19 @@ public function testCleanup(): void {
6665 ->with ('appdata_some_id ' )
6766 ->willReturn ($ appDataFolder );
6867
69- $ this ->output ->expects ($ this ->exactly (3 ))->method ('writeln ' )
68+ $ this ->output ->expects ($ this ->exactly (2 ))->method ('writeln ' )
7069 ->with (self ::callback (function (string $ message ): bool {
7170 static $ i = 0 ;
7271 return match (++$ i ) {
7372 1 => $ message === 'Preview folder deleted ' ,
74- 2 => $ message === 'Preview folder recreated ' ,
75- 3 => $ message === 'Previews removed '
73+ 2 => $ message === 'Previews removed '
7674 };
7775 }));
7876
7977 $ this ->assertEquals (0 , $ this ->repair ->run ($ this ->input , $ this ->output ));
8078 }
8179
8280 public function testCleanupWhenNotDeletable (): void {
83- $ this ->previewService ->expects ($ this ->once ())->method ('deleteAll ' );
84-
8581 $ previewFolder = $ this ->createMock (Folder::class);
8682 $ previewFolder ->expects ($ this ->once ())
8783 ->method ('isDeletable ' )
@@ -92,7 +88,6 @@ public function testCleanupWhenNotDeletable(): void {
9288
9389 $ appDataFolder = $ this ->createMock (Folder::class);
9490 $ appDataFolder ->expects ($ this ->once ())->method ('get ' )->with ('preview ' )->willReturn ($ previewFolder );
95- $ appDataFolder ->expects ($ this ->never ())->method ('newFolder ' )->with ('preview ' );
9691
9792 $ this ->rootFolder ->expects ($ this ->once ())
9893 ->method ('getAppDataDirectoryName ' )
@@ -111,8 +106,6 @@ public function testCleanupWhenNotDeletable(): void {
111106
112107 #[\PHPUnit \Framework \Attributes \DataProvider('dataForTestCleanupWithDeleteException ' )]
113108 public function testCleanupWithDeleteException (string $ exceptionClass , string $ errorMessage ): void {
114- $ this ->previewService ->expects ($ this ->once ())->method ('deleteAll ' );
115-
116109 $ previewFolder = $ this ->createMock (Folder::class);
117110 $ previewFolder ->expects ($ this ->once ())
118111 ->method ('isDeletable ' )
@@ -124,7 +117,6 @@ public function testCleanupWithDeleteException(string $exceptionClass, string $e
124117
125118 $ appDataFolder = $ this ->createMock (Folder::class);
126119 $ appDataFolder ->expects ($ this ->once ())->method ('get ' )->with ('preview ' )->willReturn ($ previewFolder );
127- $ appDataFolder ->expects ($ this ->never ())->method ('newFolder ' )->with ('preview ' );
128120
129121 $ this ->rootFolder ->expects ($ this ->once ())
130122 ->method ('getAppDataDirectoryName ' )
@@ -148,53 +140,16 @@ public static function dataForTestCleanupWithDeleteException(): array {
148140 ];
149141 }
150142
151- public function testCleanupWithCreateException (): void {
152- $ this ->previewService ->expects ($ this ->once ())->method ('deleteAll ' );
153-
154- $ previewFolder = $ this ->createMock (Folder::class);
155- $ previewFolder ->expects ($ this ->once ())
156- ->method ('isDeletable ' )
157- ->willReturn (true );
158-
159- $ previewFolder ->expects ($ this ->once ())
160- ->method ('delete ' );
161-
162- $ appDataFolder = $ this ->createMock (Folder::class);
163- $ appDataFolder ->expects ($ this ->once ())->method ('get ' )->with ('preview ' )->willReturn ($ previewFolder );
164- $ appDataFolder ->expects ($ this ->once ())->method ('newFolder ' )->with ('preview ' )->willThrowException (new NotPermittedException ());
165-
166- $ this ->rootFolder ->expects ($ this ->once ())
167- ->method ('getAppDataDirectoryName ' )
168- ->willReturn ('appdata_some_id ' );
169-
170- $ this ->rootFolder ->expects ($ this ->once ())
171- ->method ('get ' )
172- ->with ('appdata_some_id ' )
173- ->willReturn ($ appDataFolder );
174-
175- $ this ->output ->expects ($ this ->exactly (2 ))->method ('writeln ' )
176- ->with (self ::callback (function (string $ message ): bool {
177- static $ i = 0 ;
178- return match (++$ i ) {
179- 1 => $ message === 'Preview folder deleted ' ,
180- 2 => $ message === "Preview folder was deleted, but you don't have the permission to create preview folder " ,
181- };
182- }));
183-
184- $ this ->logger ->expects ($ this ->once ())->method ('error ' )->with ("Preview folder was deleted, but you don't have the permission to create preview folder " );
185-
186- $ this ->assertEquals (1 , $ this ->repair ->run ($ this ->input , $ this ->output ));
187- }
188-
189143 public function testCleanupWithPreviewServiceException (): void {
144+ $ this ->rootFolder ->method ('getAppDataDirectoryName ' )
145+ ->willThrowException (new NotFoundException ());
146+
190147 $ this ->previewService ->expects ($ this ->once ())->method ('deleteAll ' )
191148 ->willThrowException (new NotPermittedException ('abc ' ));
192149
150+ $ this ->logger ->expects ($ this ->once ())->method ('info ' )->with ("Legacy previews can't be removed: appdata folder can't be found " );
193151 $ this ->logger ->expects ($ this ->once ())->method ('error ' )->with ("Previews can't be removed: exception occurred: abc " );
194152
195- $ this ->rootFolder ->expects ($ this ->never ())
196- ->method ('get ' );
197-
198153 $ this ->assertEquals (1 , $ this ->repair ->run ($ this ->input , $ this ->output ));
199154 }
200155}
0 commit comments