@@ -307,93 +307,4 @@ public function test_conversion_same_mimetype()
307307 $ this ->assertEquals (array ('image/webp ' ), $ compress_calls [1 ]['convert_to ' ]);
308308 }
309309
310- public function test_creates_backup_of_original_image () {
311- $ this ->wp ->addOption ('tinypng_backup ' , array (
312- 'enabled ' => 'on ' ,
313- ));
314- $ this ->wp ->addOption ('tinypng_sizes ' , array (
315- Tiny_Image::ORIGINAL => 'on ' ,
316- ));
317- $ this ->wp ->stub ('get_post_mime_type ' , function () {
318- return 'image/png ' ;
319- });
320-
321- $ input_dir = '26/03 ' ;
322- $ input_name = 'testforbackup ' ;
323- $ this ->wp ->createImages (array (), 1000 , $ input_dir , $ input_name );
324-
325- $ settings = new Tiny_Settings ();
326- $ mock_compressor = $ this ->createMock (Tiny_Compress::class);
327- $ settings ->set_compressor ($ mock_compressor );
328-
329- $ metadata = $ this ->wp ->getTestMetadata ($ input_dir , $ input_name );
330- $ tinyimg = new Tiny_Image ($ settings , 999 , $ metadata );
331- $ tinyimg ->compress ();
332-
333- $ this ->assertTrue (
334- file_exists ( $ this ->vfs ->url () . '/wp-content/uploads/ ' . $ input_dir . '/ ' . $ input_name . '.bak.png ' ) ,
335- 'backup of file should be created ' );
336- }
337-
338- public function test_will_not_backup_other_sizes () {
339- $ this ->wp ->addOption ('tinypng_backup ' , array (
340- 'enabled ' => 'on ' ,
341- ));
342- $ this ->wp ->addOption ('tinypng_sizes ' , array (
343- 'thumbnail ' => 'on ' ,
344- ));
345- $ this ->wp ->stub ('get_post_mime_type ' , function () {
346- return 'image/png ' ;
347- });
348-
349- $ input_dir = '26/03 ' ;
350- $ input_name = 'testforbackup ' ;
351- $ this ->wp ->createImages (array (
352- 'thumbnail ' => 1000 ,
353- ), 1000 , $ input_dir , $ input_name );
354-
355- $ settings = new Tiny_Settings ();
356- $ mock_compressor = $ this ->createMock (Tiny_Compress::class);
357- $ settings ->set_compressor ($ mock_compressor );
358-
359- $ metadata = $ this ->wp ->getTestMetadata ($ input_dir , $ input_name );
360- $ tinyimg = new Tiny_Image ($ settings , 999 , $ metadata );
361- $ tinyimg ->compress ();
362-
363- $ this ->assertFalse (
364- file_exists ( $ this ->vfs ->url () . '/wp-content/uploads/ ' . $ input_dir . '/ ' . $ input_name . '.bak.png ' ) ,
365- 'backup of original should not exist ' );
366-
367- $ this ->assertFalse (
368- file_exists ( $ this ->vfs ->url () . '/wp-content/uploads/ ' . $ input_dir . '/ ' . $ input_name . '-thumbnail.bak.png ' ) ,
369- 'backup of thumbnail should not exist ' );
370- }
371-
372- public function test_will_not_backup_when_disabled () {
373- $ this ->wp ->addOption ('tinypng_backup ' , array (
374- 'enabled ' => false ,
375- ));
376- $ this ->wp ->addOption ('tinypng_sizes ' , array (
377- Tiny_Image::ORIGINAL => 'on ' ,
378- ));
379- $ this ->wp ->stub ('get_post_mime_type ' , function () {
380- return 'image/png ' ;
381- });
382-
383- $ input_dir = '26/03 ' ;
384- $ input_name = 'testforbackup ' ;
385- $ this ->wp ->createImages (array (), 1000 , $ input_dir , $ input_name );
386-
387- $ settings = new Tiny_Settings ();
388- $ mock_compressor = $ this ->createMock (Tiny_Compress::class);
389- $ settings ->set_compressor ($ mock_compressor );
390-
391- $ metadata = $ this ->wp ->getTestMetadata ($ input_dir , $ input_name );
392- $ tinyimg = new Tiny_Image ($ settings , 999 , $ metadata );
393- $ tinyimg ->compress ();
394-
395- $ this ->assertFalse (
396- file_exists ( $ this ->vfs ->url () . '/wp-content/uploads/ ' . $ input_dir . '/ ' . $ input_name . '.bak.png ' ) ,
397- 'backup of original should not exist ' );
398- }
399310}
0 commit comments