This repository has been archived on 2024-09-05. You can view files and clone it, but cannot push or open issues or pull requests.
shimmie2/ext/res_limit/test.php

114 lines
3.7 KiB
PHP
Raw Normal View History

2009-07-19 03:48:25 +00:00
<?php
class ResLimitTest extends ShimmieWebTestCase {
function testResLimitOK() {
$this->log_in_as_admin();
$this->get_page("setup");
2009-08-19 00:28:48 +00:00
$this->set_field("_config_upload_min_height", "0");
$this->set_field("_config_upload_min_width", "0");
$this->set_field("_config_upload_max_height", "2000");
$this->set_field("_config_upload_max_width", "2000");
$this->set_field("_config_upload_ratios", "4:3 16:9");
2009-07-19 03:48:25 +00:00
$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");
2009-08-19 00:28:48 +00:00
$this->assert_response(302);
$this->assert_no_text("Image too large");
$this->assert_no_text("Image too small");
$this->assert_no_text("ratio");
2009-07-19 03:48:25 +00:00
$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");
2009-08-19 00:28:48 +00:00
$this->set_field("_config_upload_min_height", "900");
$this->set_field("_config_upload_min_width", "900");
$this->set_field("_config_upload_max_height", "-1");
$this->set_field("_config_upload_max_width", "-1");
$this->set_field("_config_upload_ratios", "4:3 16:9");
2009-07-19 03:48:25 +00:00
$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");
2009-08-19 00:28:48 +00:00
$this->assert_response(200);
$this->assert_title("Upload Status");
$this->assert_text("Image too small");
2009-07-19 03:48:25 +00:00
$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");
2009-08-19 00:28:48 +00:00
$this->set_field("_config_upload_min_height", "0");
$this->set_field("_config_upload_min_width", "0");
$this->set_field("_config_upload_max_height", "100");
$this->set_field("_config_upload_max_width", "100");
$this->set_field("_config_upload_ratios", "4:3 16:9");
2009-07-19 03:48:25 +00:00
$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");
2009-08-19 00:28:48 +00:00
$this->assert_response(200);
$this->assert_title("Upload Status");
$this->assert_text("Image too large");
2009-07-19 03:48:25 +00:00
$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");
2009-08-19 00:28:48 +00:00
$this->set_field("_config_upload_min_height", "-1");
$this->set_field("_config_upload_min_width", "-1");
$this->set_field("_config_upload_max_height", "-1");
$this->set_field("_config_upload_max_width", "-1");
$this->set_field("_config_upload_ratios", "16:9");
2009-07-19 03:48:25 +00:00
$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");
2009-08-19 00:28:48 +00:00
$this->assert_response(200);
$this->assert_title("Upload Status");
$this->assert_text("Image needs to be in one of these ratios");
2009-07-19 03:48:25 +00:00
$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");
2009-08-19 00:28:48 +00:00
$this->set_field("_config_upload_min_height", "-1");
$this->set_field("_config_upload_min_width", "-1");
$this->set_field("_config_upload_max_height", "-1");
$this->set_field("_config_upload_max_width", "-1");
$this->set_field("_config_upload_ratios", "");
2009-07-19 03:48:25 +00:00
$this->click("Save Settings");
$this->log_out();
}
}
?>