forked from Cavemanon/cavepaintings
a load more tests
This commit is contained in:
110
contrib/res_limit/test.php
Normal file
110
contrib/res_limit/test.php
Normal file
@@ -0,0 +1,110 @@
|
||||
<?php
|
||||
class ResLimitTest extends ShimmieWebTestCase {
|
||||
function testResLimitOK() {
|
||||
$this->log_in_as_admin();
|
||||
$this->get_page("setup");
|
||||
$this->setField("_config_upload_min_height", "0");
|
||||
$this->setField("_config_upload_min_width", "0");
|
||||
$this->setField("_config_upload_max_height", "1000");
|
||||
$this->setField("_config_upload_max_width", "1000");
|
||||
$this->setField("_config_upload_ratios", "4:3 16:9");
|
||||
$this->click("Save Settings");
|
||||
$this->log_out();
|
||||
|
||||
$this->log_in_as_user();
|
||||
$image_id = $this->post_image("ext/simpletest/data/pbx_screenshot.jpg", "pbx computer screenshot");
|
||||
$this->assertResponse(302);
|
||||
$this->log_out();
|
||||
|
||||
$this->log_in_as_admin();
|
||||
$this->delete_image($image_id);
|
||||
$this->log_out();
|
||||
}
|
||||
|
||||
function testResLimitSmall() {
|
||||
$this->log_in_as_admin();
|
||||
$this->get_page("setup");
|
||||
$this->setField("_config_upload_min_height", "900");
|
||||
$this->setField("_config_upload_min_width", "900");
|
||||
$this->setField("_config_upload_max_height", "1000");
|
||||
$this->setField("_config_upload_max_width", "1000");
|
||||
$this->setField("_config_upload_ratios", "4:3 16:9");
|
||||
$this->click("Save Settings");
|
||||
$this->log_out();
|
||||
|
||||
$this->log_in_as_user();
|
||||
$image_id = $this->post_image("ext/simpletest/data/pbx_screenshot.jpg", "pbx computer screenshot");
|
||||
$this->assertResponse(200);
|
||||
$this->assertTitle("Upload Status");
|
||||
$this->assertText("Image too small");
|
||||
$this->log_out();
|
||||
|
||||
# hopefully a noop, but just in case
|
||||
$this->log_in_as_admin();
|
||||
$this->delete_image($image_id);
|
||||
$this->log_out();
|
||||
}
|
||||
|
||||
function testResLimitLarge() {
|
||||
$this->log_in_as_admin();
|
||||
$this->get_page("setup");
|
||||
$this->setField("_config_upload_min_height", "0");
|
||||
$this->setField("_config_upload_min_width", "0");
|
||||
$this->setField("_config_upload_max_height", "100");
|
||||
$this->setField("_config_upload_max_width", "100");
|
||||
$this->setField("_config_upload_ratios", "4:3 16:9");
|
||||
$this->click("Save Settings");
|
||||
$this->log_out();
|
||||
|
||||
$this->log_in_as_user();
|
||||
$image_id = $this->post_image("ext/simpletest/data/pbx_screenshot.jpg", "pbx computer screenshot");
|
||||
$this->assertResponse(200);
|
||||
$this->assertTitle("Upload Status");
|
||||
$this->assertText("Image too large");
|
||||
$this->log_out();
|
||||
|
||||
# hopefully a noop, but just in case
|
||||
$this->log_in_as_admin();
|
||||
$this->delete_image($image_id);
|
||||
$this->log_out();
|
||||
}
|
||||
|
||||
function testResLimitRatio() {
|
||||
$this->log_in_as_admin();
|
||||
$this->get_page("setup");
|
||||
$this->setField("_config_upload_min_height", "0");
|
||||
$this->setField("_config_upload_min_width", "0");
|
||||
$this->setField("_config_upload_max_height", "1000");
|
||||
$this->setField("_config_upload_max_width", "1000");
|
||||
$this->setField("_config_upload_ratios", "16:9");
|
||||
$this->click("Save Settings");
|
||||
$this->log_out();
|
||||
|
||||
$this->log_in_as_user();
|
||||
$image_id = $this->post_image("ext/simpletest/data/pbx_screenshot.jpg", "pbx computer screenshot");
|
||||
$this->assertResponse(200);
|
||||
$this->assertTitle("Upload Status");
|
||||
$this->assertText("Image needs to be in one of these ratios");
|
||||
$this->log_out();
|
||||
|
||||
# hopefully a noop, but just in case
|
||||
$this->log_in_as_admin();
|
||||
$this->delete_image($image_id);
|
||||
$this->log_out();
|
||||
}
|
||||
|
||||
# reset to defaults, otherwise this can interfere with
|
||||
# other extensions' test suites
|
||||
public function tearDown() {
|
||||
$this->log_in_as_admin();
|
||||
$this->get_page("setup");
|
||||
$this->setField("_config_upload_min_height", "-1");
|
||||
$this->setField("_config_upload_min_width", "-1");
|
||||
$this->setField("_config_upload_max_height", "-1");
|
||||
$this->setField("_config_upload_max_width", "-1");
|
||||
$this->setField("_config_upload_ratios", "");
|
||||
$this->click("Save Settings");
|
||||
$this->log_out();
|
||||
}
|
||||
}
|
||||
?>
|
Reference in New Issue
Block a user