@@ -160,6 +160,41 @@ public function testDeleteStillRemovesChunksIfFileDoesNotExist($input, $expected
160160 $ this ->assertCollectionCount ($ this ->chunksCollection , 0 );
161161 }
162162
163+ public function testDeleteByName (): void
164+ {
165+ $ this ->bucket ->uploadFromStream ('filename ' , self ::createStream ('foobar1 ' ));
166+ $ this ->bucket ->uploadFromStream ('filename ' , self ::createStream ('foobar2 ' ));
167+ $ this ->bucket ->uploadFromStream ('filename ' , self ::createStream ('foobar3 ' ));
168+
169+ $ this ->bucket ->uploadFromStream ('other ' , self ::createStream ('foobar ' ));
170+
171+ $ this ->assertCollectionCount ($ this ->filesCollection , 4 );
172+ $ this ->assertCollectionCount ($ this ->chunksCollection , 4 );
173+
174+ $ this ->bucket ->deleteByName ('filename ' );
175+
176+ $ this ->assertCollectionCount ($ this ->filesCollection , 1 );
177+ $ this ->assertCollectionCount ($ this ->chunksCollection , 1 );
178+
179+ $ this ->bucket ->deleteByName ('other ' );
180+
181+ $ this ->assertCollectionCount ($ this ->filesCollection , 0 );
182+ $ this ->assertCollectionCount ($ this ->chunksCollection , 0 );
183+ }
184+
185+ public function testDeleteByNameShouldIgnoreNonexistentFiles (): void
186+ {
187+ $ this ->bucket ->uploadFromStream ('filename ' , self ::createStream ('foobar ' ));
188+
189+ $ this ->assertCollectionCount ($ this ->filesCollection , 1 );
190+ $ this ->assertCollectionCount ($ this ->chunksCollection , 1 );
191+
192+ $ this ->bucket ->deleteByName ('nonexistent-filename ' );
193+
194+ $ this ->assertCollectionCount ($ this ->filesCollection , 1 );
195+ $ this ->assertCollectionCount ($ this ->chunksCollection , 1 );
196+ }
197+
163198 public function testDownloadingFileWithMissingChunk (): void
164199 {
165200 $ id = $ this ->bucket ->uploadFromStream ('filename ' , self ::createStream ('foobar ' ));
0 commit comments