@@ -86,6 +86,55 @@ public function testShouldPersistNoSizes() {
8686 $ this ->assertEquals (0 , count (array_map ('elementName ' , $ elements )));
8787 }
8888
89+ public function testShouldShowOriginalsMessageWhenChecked () {
90+ $ elements = self ::$ driver ->findElement (WebDriverBy::id ('tiny-image-sizes-notices ' ))->findElements (WebDriverBy::tagName ('p ' ));
91+ $ statuses = array_map ('innerText ' , $ elements );
92+ $ this ->assertContains ('Note: your original images will be overwritten with the compressed versions! ' , $ statuses );
93+ }
94+
95+ public function testShouldHideOriginalsMessageWhenUnchecked () {
96+ $ element = self ::$ driver ->findElement (
97+ WebDriverBy::xpath ('//input[@type="checkbox" and @name="tinypng_sizes[0]" and @checked="checked"] ' ));
98+ $ element ->click ();
99+ self ::$ driver ->findElement (WebDriverBy::tagName ('form ' ))->submit ();
100+
101+ $ elements = self ::$ driver ->findElement (WebDriverBy::id ('tiny-image-sizes-notices ' ))->findElements (WebDriverBy::tagName ('p ' ));
102+ $ statuses = array_map ('innerText ' , $ elements );
103+ $ this ->assertNotContains ('Note: your original images will be overwritten with the compressed versions! ' , $ statuses );
104+ }
105+
106+ public function testShouldShowTotalImagesInfo () {
107+ $ elements = self ::$ driver ->findElement (WebDriverBy::id ('tiny-image-sizes-notices ' ))->findElements (WebDriverBy::tagName ('p ' ));
108+ $ statuses = array_map ('innerText ' , $ elements );
109+ $ this ->assertContains ('With these settings you can compress 100 images for free each month. ' , $ statuses );
110+ }
111+
112+ public function testShouldUpdateTotalImagesInfo () {
113+ $ element = self ::$ driver ->findElement (
114+ WebDriverBy::xpath ('//input[@type="checkbox" and @name="tinypng_sizes[0]" and @checked="checked"] ' ));
115+ $ element ->click ();
116+ self ::$ driver ->wait (2 )->until (WebDriverExpectedCondition::textToBePresentInElement (
117+ WebDriverBy::cssSelector ('#tiny-image-sizes-notices ' ), 'With these settings you can compress 125 images for free each month. ' ));
118+ // Not really necessary anymore to assert this.
119+ $ elements = self ::$ driver ->findElement (WebDriverBy::id ('tiny-image-sizes-notices ' ))->findElements (WebDriverBy::tagName ('p ' ));
120+ $ statuses = array_map ('innerText ' , $ elements );
121+ $ this ->assertContains ('With these settings you can compress 125 images for free each month. ' , $ statuses );
122+ }
123+
124+ public function testShouldShowCorrectNoImageSizesInfo () {
125+ $ elements = self ::$ driver ->findElements (
126+ WebDriverBy::xpath ('//input[@type="checkbox" and starts-with(@name, "tinypng_sizes") and @checked="checked"] ' ));
127+ foreach ($ elements as $ element ) {
128+ $ element ->click ();
129+ }
130+ self ::$ driver ->wait (2 )->until (WebDriverExpectedCondition::textToBePresentInElement (
131+ WebDriverBy::cssSelector ('#tiny-image-sizes-notices ' ), 'With these settings no images will be compressed. ' ));
132+ // Not really necessary anymore to assert this.
133+ $ elements = self ::$ driver ->findElement (WebDriverBy::id ('tiny-image-sizes-notices ' ))->findElements (WebDriverBy::tagName ('p ' ));
134+ $ statuses = array_map ('innerText ' , $ elements );
135+ $ this ->assertContains ('With these settings no images will be compressed. ' , $ statuses );
136+ }
137+
89138 public function testStatusPresenceOK () {
90139 reset_webservice ();
91140 $ this ->set_api_key ('PNG123 ' );
0 commit comments