@@ -11,31 +11,46 @@ public function setUp() {
1111 public function tearDown () {
1212 clear_settings ();
1313 clear_uploads ();
14+ reset_webservice ();
1415 }
1516
16- public function testBulkCompressActionShouldBePresent ()
17- {
17+ public function testBulkCompressActionShouldBePresentInMedia () {
1818 $ this ->upload_image (dirname (__FILE__ ) . '/../fixtures/input-example.png ' );
1919 self ::$ driver ->get (wordpress ('/wp-admin/upload.php?mode=list ' ));
2020 $ this ->assertEquals ('Compress all ' , self ::$ driver ->findElement (
2121 WebDriverBy::cssSelector ('select[name="action"] option[value="tiny_bulk_compress"] ' )
2222 )->getText ());
2323 }
2424
25- public function testBulkCompressShouldCompressUncompressedSizes () {
26- $ this ->enable_compression_sizes (array ('thumbnail ' ));
27-
25+ private function prepare ($ normal =1 , $ large =0 ) {
2826 $ this ->set_api_key ('PNG123 ' );
29- $ this ->upload_image (dirname (__FILE__ ) . '/../fixtures/input-large.png ' );
27+ $ this ->enable_compression_sizes (array ());
28+
29+ for ($ i = 0 ; $ i < $ normal ; $ i ++) {
30+ $ this ->upload_image (dirname (__FILE__ ) . '/../fixtures/input-example.png ' );
31+ }
32+ for ($ i = 0 ; $ i < $ large ; $ i ++) {
33+ $ this ->upload_image (dirname (__FILE__ ) . '/../fixtures/input-large.png ' );
34+ }
35+
36+ $ this ->enable_compression_sizes (array ('thumbnail ' , 'medium ' , 'large ' ));
37+ }
3038
31- $ this ->enable_compression_sizes (array ('thumbnail ' , 'medium ' ));
39+ public function testBulkCompressShouldInMediaShouldRedirect () {
40+ $ this ->prepare ();
3241
3342 self ::$ driver ->get (wordpress ('/wp-admin/upload.php?mode=list ' ));
3443 $ checkboxes = self ::$ driver ->findElements (WebDriverBy::cssSelector ('th input[type="checkbox"] ' ));
3544 $ checkboxes [0 ]->click ();
36- self ::$ driver ->findElement (WebDriverBy::cssSelector ('select[name="action"] option[value=" ' . 'tiny_bulk_compress ' . '"] ' ))->click ();
45+
46+ self ::$ driver ->findElement (WebDriverBy::cssSelector ('select[name="action"] option[value="tiny_bulk_compress"] ' ))->click ();
3747 self ::$ driver ->findElement (WebDriverBy::cssSelector ('div.actions input[value="Apply"] ' ))->click ();
3848
39- $ this ->assertContains ('Compressed 2 out of 2 sizes ' , self ::$ driver ->findElement (WebDriverBy::cssSelector ('td.tiny-compress-images ' ))->getText ());
49+ self ::$ driver ->wait (2 )->until (WebDriverExpectedCondition::textToBePresentInElement (
50+ WebDriverBy::cssSelector ('.updated ' ), 'All images are processed ' ));
51+
52+ $ this ->assertContains ("tools.php?page=tiny-bulk-compress&ids= " , self ::$ driver ->getCurrentUrl ());
4053 }
54+
55+ // TODO: More tests
4156}
0 commit comments