Skip to content

Commit 5928823

Browse files
Test empty media library.
1 parent 2d7b52d commit 5928823

2 files changed

Lines changed: 23 additions & 2 deletions

File tree

src/class-tiny-image-size.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ public function modified() {
111111
public function uncompressed() {
112112
return $this->exists() &&
113113
! $this->is_duplicate() &&
114-
! (isset( $this->meta['output'] ) && $this->same_size() );
114+
! ( isset( $this->meta['output'] ) && $this->same_size() );
115115
}
116116

117117
public function in_progress() {

test/integration/BulkOptimizationIntegrationTest.php

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,24 @@ public function tear_down() {
99
clear_uploads();
1010
}
1111

12-
public function test_summary_should_display_accurate_values() {
12+
public function test_summary_should_display_correct_values_for_empty_library() {
13+
$this->enable_compression_sizes( array( '0', 'thumbnail', 'medium' ) );
14+
15+
$this->visit( '/wp-admin/upload.php?page=tiny-bulk-optimization' );
16+
17+
$this->assertEquals( '0', $this->find( '#uploaded-images' )->getText() );
18+
$this->assertEquals( '0', $this->find( '#optimizable-image-sizes' )->getText() );
19+
$this->assertEquals( '$ 0.00', $this->find( '#estimated-cost' )->getText() );
20+
$this->assertEquals( '0', $this->find( '#optimized-image-sizes' )->getText() );
21+
22+
$this->assertEquals( '-', $this->find( '#unoptimized-library-size' )->getText() );
23+
$this->assertEquals( '-', $this->find( '#optimized-library-size' )->getText() );
24+
$this->assertEquals( '0%', $this->find( '#savings-percentage' )->getText() );
25+
26+
$this->assertEquals( '0 / 0 (100%)', $this->find( '#compression-progress-bar' )->getText() );
27+
}
28+
29+
public function test_summary_should_display_correct_values() {
1330
$this->set_api_key( 'JPG123' );
1431

1532
$this->enable_compression_sizes( array() );
@@ -31,6 +48,8 @@ public function test_summary_should_display_accurate_values() {
3148
$this->assertRegExp( '/[23](\.\d+)? MB/', $this->find( '#unoptimized-library-size' )->getText() );
3249
$this->assertRegExp( '/[12](\.\d+)? MB/', $this->find( '#optimized-library-size' )->getText() );
3350
$this->assertRegExp( '/2\d(\.\d+)?%/', $this->find( '#savings-percentage' )->getText() );
51+
52+
$this->assertEquals( '4 / 9 (44%)', $this->find( '#compression-progress-bar' )->getText() );
3453
}
3554

3655
public function test_start_bulk_optimization_should_optimize_remaining_images() {
@@ -55,5 +74,7 @@ public function test_start_bulk_optimization_should_optimize_remaining_images()
5574
'#optimizable-image-sizes',
5675
'0'
5776
);
77+
78+
$this->assertEquals( '9 / 9 (100%)', $this->find( '#compression-progress-bar' )->getText() );
5879
}
5980
}

0 commit comments

Comments
 (0)