Skip to content

Commit 27ae6e7

Browse files
Removed 'large' image fixtures, which overcomplicated things, and use correct combination of api key and image fixture for all resize integration tests.
1 parent f34ff37 commit 27ae6e7

10 files changed

Lines changed: 24 additions & 47 deletions

File tree

test/fixtures/input-large.jpg

-105 KB
Binary file not shown.

test/fixtures/input-large.png

-78.6 KB
Binary file not shown.

test/integration/BulkCompressIntegrationTest.php

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,10 @@ private function prepare($normal=1, $large=0) {
2929
$this->enable_compression_sizes(array());
3030

3131
for ($i = 0; $i < $normal; $i++) {
32-
$this->upload_image(dirname(__FILE__) . '/../fixtures/input-example.png');
32+
$this->upload_image(dirname(__FILE__) . '/../fixtures/input-example.jpg');
3333
}
3434
for ($i = 0; $i < $large; $i++) {
35-
$this->upload_image(dirname(__FILE__) . '/../fixtures/input-large.png');
35+
$this->upload_image(dirname(__FILE__) . '/../fixtures/input-example.png');
3636
}
3737

3838
$this->enable_compression_sizes(array('thumbnail', 'medium', 'large'));
@@ -70,10 +70,9 @@ public function testBulkCompressShouldCompressAll() {
7070
$filenames = array_map('innerText', $elements);
7171

7272
$this->assertEquals(2, count($filenames));
73-
$this->assertContains('input-large', $filenames);
7473
$this->assertContains('input-example', $filenames);
7574

7675
$this->assertEquals('2', self::$driver->findElement(WebDriverBy::cssSelector('#tiny-progress span'))->getText());
77-
$this->assertEquals('5', self::$driver->findElement(WebDriverBy::cssSelector('#tiny-status span'))->getText());
76+
$this->assertEquals('4', self::$driver->findElement(WebDriverBy::cssSelector('#tiny-status span'))->getText());
7877
}
7978
}

test/integration/CompressIntegrationTest.php

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -87,80 +87,80 @@ public function testIncorrectJsonButton() {
8787
}
8888

8989
public function testResizeFitShouldDisplayResizedTextInMediaLibrary() {
90-
$this->set_api_key('JPG123');
90+
$this->set_api_key('PNG123');
9191
$this->enable_resize(300, 200);
92-
$this->upload_image(dirname(__FILE__) . '/../fixtures/input-large.png');
92+
$this->upload_image(dirname(__FILE__) . '/../fixtures/input-example.png');
9393
self::$driver->findElement(WebDriverBy::cssSelector('td.tiny-compress-images a.thickbox'))->click();
9494
$this->assertContains('resized to 300x200',
9595
self::$driver->findElement(WebDriverBy::cssSelector('div.tiny-compression-details'))->getText());
9696
}
9797

9898
public function testResizeFitShouldDisplayResizedTextInEditScreen() {
99-
$this->set_api_key('JPG123');
99+
$this->set_api_key('PNG123');
100100
$this->enable_resize(300, 200);
101-
$this->upload_image(dirname(__FILE__) . '/../fixtures/input-large.png');
101+
$this->upload_image(dirname(__FILE__) . '/../fixtures/input-example.png');
102102
$this->view_edit_image();
103103
$this->assertContains('Dimensions: 300 × 200',
104104
self::$driver->findElement(WebDriverBy::cssSelector('div.misc-pub-dimensions'))->getText());
105105
}
106106

107107
public function testResizeScaleShouldDisplayResizedTextInMediaLibrary() {
108-
$this->set_api_key('JPG123');
108+
$this->set_api_key('PNG123');
109109
$this->enable_resize(0, 200);
110-
$this->upload_image(dirname(__FILE__) . '/../fixtures/input-large.jpg');
110+
$this->upload_image(dirname(__FILE__) . '/../fixtures/input-example.png');
111111
self::$driver->findElement(WebDriverBy::cssSelector('td.tiny-compress-images a.thickbox'))->click();
112112
$this->assertContains('resized to 300x200', self::$driver->findElement(
113113
WebDriverBy::cssSelector('div.tiny-compression-details'))->getText());
114114
}
115115

116116
public function testResizeScaleShouldDisplayResizedTextInEditScreen() {
117-
$this->set_api_key('JPG123');
117+
$this->set_api_key('PNG123');
118118
$this->enable_resize(0, 200);
119-
$this->upload_image(dirname(__FILE__) . '/../fixtures/input-large.jpg');
119+
$this->upload_image(dirname(__FILE__) . '/../fixtures/input-example.png');
120120
$this->view_edit_image();
121121
$this->assertContains('Dimensions: 300 × 200',
122122
self::$driver->findElement(WebDriverBy::cssSelector('div.misc-pub-dimensions'))->getText());
123123
}
124124

125125
public function testResizeNotNeededShouldNotDisplayResizedTextInMediaLibrary()
126126
{
127-
$this->set_api_key('JPG123');
127+
$this->set_api_key('PNG123');
128128
$this->enable_resize(30000, 20000);
129-
$this->upload_image(dirname(__FILE__) . '/../fixtures/input-large.jpg');
129+
$this->upload_image(dirname(__FILE__) . '/../fixtures/input-example.png');
130130
self::$driver->findElement(WebDriverBy::cssSelector('td.tiny-compress-images a.thickbox'))->click();
131131
$this->assertNotContains('resized',
132132
self::$driver->findElement(WebDriverBy::cssSelector('div.tiny-compression-details'))->getText());
133133
}
134134

135135
public function testResizeNotNeededShouldDisplayOriginalDimensionsInEditScreen()
136136
{
137-
$this->set_api_key('JPG123');
137+
$this->set_api_key('PNG123');
138138
$this->enable_resize(30000, 20000);
139-
$this->upload_image(dirname(__FILE__) . '/../fixtures/input-large.jpg');
139+
$this->upload_image(dirname(__FILE__) . '/../fixtures/input-example.png');
140140
$this->view_edit_image();
141-
$this->assertContains('Dimensions: 1080 × 330',
141+
$this->assertContains('Dimensions: 1080 × 720',
142142
self::$driver->findElement(WebDriverBy::cssSelector('div.misc-pub-dimensions'))->getText());
143143
}
144144

145145
public function testResizeDisabledShouldNotDisplayResizedTextInMediaLibrary()
146146
{
147-
$this->set_api_key('JPG123');
147+
$this->set_api_key('PNG123');
148148
$this->enable_resize(300, 200);
149149
$this->disable_resize();
150-
$this->upload_image(dirname(__FILE__) . '/../fixtures/input-large.jpg');
150+
$this->upload_image(dirname(__FILE__) . '/../fixtures/input-example.png');
151151
self::$driver->findElement(WebDriverBy::cssSelector('td.tiny-compress-images a.thickbox'))->click();
152152
$this->assertNotContains('resized',
153153
self::$driver->findElement(WebDriverBy::cssSelector('div.tiny-compression-details'))->getText());
154154
}
155155

156156
public function testResizeDisabledShouldDisplayOriginalDimensionsInEditScreen()
157157
{
158-
$this->set_api_key('JPG123');
158+
$this->set_api_key('PNG123');
159159
$this->enable_resize(300, 200);
160160
$this->disable_resize();
161-
$this->upload_image(dirname(__FILE__) . '/../fixtures/input-large.jpg');
161+
$this->upload_image(dirname(__FILE__) . '/../fixtures/input-example.png');
162162
$this->view_edit_image();
163-
$this->assertContains('Dimensions: 1080 × 330',
163+
$this->assertContains('Dimensions: 1080 × 720',
164164
self::$driver->findElement(WebDriverBy::cssSelector('div.misc-pub-dimensions'))->getText());
165165
}
166166
}

test/integration/IntegrationTestCase.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ protected function disable_resize() {
9494
self::$driver->findElement(WebDriverBy::tagName('form'))->submit();
9595
}
9696

97-
protected function view_edit_image($image_title = 'input-large') {
97+
protected function view_edit_image($image_title = 'input-example') {
9898
$url = wordpress('/wp-admin/upload.php');
9999
if (self::$driver->getCurrentUrl() != $url) {
100100
self::$driver->get($url);
-68.6 KB
Binary file not shown.
-13.9 KB
Binary file not shown.
23.9 KB
Loading

test/mock-tinypng-webservice/output.php

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,6 @@
1414
$api_key = get_api_key();
1515
if (!is_null($api_key)) {
1616
$data = get_json_body();
17-
if (is_null($data) || $api_key != 'JPG123') {
18-
mock_invalid_response();
19-
ob_end_flush();
20-
exit();
21-
}
22-
2317
$resize = $data->resize;
2418
if ($resize->method) {
2519
$file = "output-resized.$ext";
@@ -36,4 +30,4 @@
3630
header("HTTP/1.1 404 Not Found");
3731
}
3832

39-
ob_end_flush();
33+
ob_end_flush();

test/mock-tinypng-webservice/shrink.php

Lines changed: 1 addition & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -34,22 +34,6 @@ function mock_jpg_response() {
3434
return json_encode($response);
3535
}
3636

37-
function mock_large_response() {
38-
global $session;
39-
40-
$session['Compression-Count'] += 1;
41-
header('HTTP/1.1 201 Created');
42-
header("Location: http://webservice/output/large.png");
43-
header("Content-Type: application/json; charset=utf-8");
44-
header("Compression-Count: {$session['Compression-Count']}");
45-
46-
$response = array(
47-
"input" => array("size" => 80506, "type" => "image/jpg"),
48-
"output" => array("size" => 70200, "type" => "image/jpg", "ratio" => 0.872)
49-
);
50-
return json_encode($response);
51-
}
52-
5337
function mock_empty_response() {
5438
global $session;
5539

@@ -114,4 +98,4 @@ function mock_invalid_json_response() {
11498
echo mock_invalid_response();
11599
}
116100

117-
ob_end_flush();
101+
ob_end_flush();

0 commit comments

Comments
 (0)