@@ -56,7 +56,6 @@ public function testCleanup(): void {
5656
5757 $ appDataFolder = $ this ->createMock (Folder::class);
5858 $ appDataFolder ->expects ($ this ->once ())->method ('get ' )->with ('preview ' )->willReturn ($ previewFolder );
59- $ appDataFolder ->expects ($ this ->once ())->method ('newFolder ' )->with ('preview ' );
6059
6160 $ this ->rootFolder ->expects ($ this ->once ())
6261 ->method ('getAppDataDirectoryName ' )
@@ -67,22 +66,19 @@ public function testCleanup(): void {
6766 ->with ('appdata_some_id ' )
6867 ->willReturn ($ appDataFolder );
6968
70- $ this ->output ->expects ($ this ->exactly (3 ))->method ('writeln ' )
69+ $ this ->output ->expects ($ this ->exactly (2 ))->method ('writeln ' )
7170 ->with (self ::callback (function (string $ message ): bool {
7271 static $ i = 0 ;
7372 return match (++$ i ) {
7473 1 => $ message === 'Preview folder deleted ' ,
75- 2 => $ message === 'Preview folder recreated ' ,
76- 3 => $ message === 'Previews removed '
74+ 2 => $ message === 'Previews removed '
7775 };
7876 }));
7977
8078 $ this ->assertEquals (0 , $ this ->repair ->run ($ this ->input , $ this ->output ));
8179 }
8280
8381 public function testCleanupWhenNotDeletable (): void {
84- $ this ->previewService ->expects ($ this ->once ())->method ('deleteAll ' );
85-
8682 $ previewFolder = $ this ->createMock (Folder::class);
8783 $ previewFolder ->expects ($ this ->once ())
8884 ->method ('isDeletable ' )
@@ -93,7 +89,6 @@ public function testCleanupWhenNotDeletable(): void {
9389
9490 $ appDataFolder = $ this ->createMock (Folder::class);
9591 $ appDataFolder ->expects ($ this ->once ())->method ('get ' )->with ('preview ' )->willReturn ($ previewFolder );
96- $ appDataFolder ->expects ($ this ->never ())->method ('newFolder ' )->with ('preview ' );
9792
9893 $ this ->rootFolder ->expects ($ this ->once ())
9994 ->method ('getAppDataDirectoryName ' )
@@ -112,8 +107,6 @@ public function testCleanupWhenNotDeletable(): void {
112107
113108 #[\PHPUnit \Framework \Attributes \DataProvider('dataForTestCleanupWithDeleteException ' )]
114109 public function testCleanupWithDeleteException (string $ exceptionClass , string $ errorMessage ): void {
115- $ this ->previewService ->expects ($ this ->once ())->method ('deleteAll ' );
116-
117110 $ previewFolder = $ this ->createMock (Folder::class);
118111 $ previewFolder ->expects ($ this ->once ())
119112 ->method ('isDeletable ' )
@@ -125,7 +118,6 @@ public function testCleanupWithDeleteException(string $exceptionClass, string $e
125118
126119 $ appDataFolder = $ this ->createMock (Folder::class);
127120 $ appDataFolder ->expects ($ this ->once ())->method ('get ' )->with ('preview ' )->willReturn ($ previewFolder );
128- $ appDataFolder ->expects ($ this ->never ())->method ('newFolder ' )->with ('preview ' );
129121
130122 $ this ->rootFolder ->expects ($ this ->once ())
131123 ->method ('getAppDataDirectoryName ' )
@@ -149,53 +141,16 @@ public static function dataForTestCleanupWithDeleteException(): array {
149141 ];
150142 }
151143
152- public function testCleanupWithCreateException (): void {
153- $ this ->previewService ->expects ($ this ->once ())->method ('deleteAll ' );
154-
155- $ previewFolder = $ this ->createMock (Folder::class);
156- $ previewFolder ->expects ($ this ->once ())
157- ->method ('isDeletable ' )
158- ->willReturn (true );
159-
160- $ previewFolder ->expects ($ this ->once ())
161- ->method ('delete ' );
162-
163- $ appDataFolder = $ this ->createMock (Folder::class);
164- $ appDataFolder ->expects ($ this ->once ())->method ('get ' )->with ('preview ' )->willReturn ($ previewFolder );
165- $ appDataFolder ->expects ($ this ->once ())->method ('newFolder ' )->with ('preview ' )->willThrowException (new NotPermittedException ());
166-
167- $ this ->rootFolder ->expects ($ this ->once ())
168- ->method ('getAppDataDirectoryName ' )
169- ->willReturn ('appdata_some_id ' );
170-
171- $ this ->rootFolder ->expects ($ this ->once ())
172- ->method ('get ' )
173- ->with ('appdata_some_id ' )
174- ->willReturn ($ appDataFolder );
175-
176- $ this ->output ->expects ($ this ->exactly (2 ))->method ('writeln ' )
177- ->with (self ::callback (function (string $ message ): bool {
178- static $ i = 0 ;
179- return match (++$ i ) {
180- 1 => $ message === 'Preview folder deleted ' ,
181- 2 => $ message === "Preview folder was deleted, but you don't have the permission to create preview folder " ,
182- };
183- }));
184-
185- $ this ->logger ->expects ($ this ->once ())->method ('error ' )->with ("Preview folder was deleted, but you don't have the permission to create preview folder " );
186-
187- $ this ->assertEquals (1 , $ this ->repair ->run ($ this ->input , $ this ->output ));
188- }
189-
190144 public function testCleanupWithPreviewServiceException (): void {
145+ $ this ->rootFolder ->method ('getAppDataDirectoryName ' )
146+ ->willThrowException (new NotFoundException ());
147+
191148 $ this ->previewService ->expects ($ this ->once ())->method ('deleteAll ' )
192149 ->willThrowException (new NotPermittedException ('abc ' ));
193150
151+ $ this ->logger ->expects ($ this ->once ())->method ('info ' )->with ("Legacy previews can't be removed: appdata folder can't be found " );
194152 $ this ->logger ->expects ($ this ->once ())->method ('error ' )->with ("Previews can't be removed: exception occurred: abc " );
195153
196- $ this ->rootFolder ->expects ($ this ->never ())
197- ->method ('get ' );
198-
199154 $ this ->assertEquals (1 , $ this ->repair ->run ($ this ->input , $ this ->output ));
200155 }
201156}
0 commit comments