res_limit testing and fixing

This commit is contained in:
Shish 2009-07-19 17:18:06 +01:00
parent d8c394c7a5
commit 6799f436ee
2 changed files with 13 additions and 10 deletions

View file

@ -20,8 +20,8 @@ class ResolutionLimit implements Extension {
if($min_w > 0 && $image->width < $min_w) throw new UploadException("Image too small");
if($min_h > 0 && $image->height < $min_h) throw new UploadException("Image too small");
if($max_w > 0 && $image->width > $min_w) throw new UploadException("Image too large");
if($max_h > 0 && $image->height > $min_h) throw new UploadException("Image too large");
if($max_w > 0 && $image->width > $max_w) throw new UploadException("Image too large");
if($max_h > 0 && $image->height > $max_h) throw new UploadException("Image too large");
if(count($ratios) > 0) {
$ok = false;

View file

@ -5,8 +5,8 @@ class ResLimitTest extends ShimmieWebTestCase {
$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_max_height", "2000");
$this->setField("_config_upload_max_width", "2000");
$this->setField("_config_upload_ratios", "4:3 16:9");
$this->click("Save Settings");
$this->log_out();
@ -14,6 +14,9 @@ class ResLimitTest extends ShimmieWebTestCase {
$this->log_in_as_user();
$image_id = $this->post_image("ext/simpletest/data/pbx_screenshot.jpg", "pbx computer screenshot");
$this->assertResponse(302);
$this->assertNoText("Image too large");
$this->assertNoText("Image too small");
$this->assertNoText("ratio");
$this->log_out();
$this->log_in_as_admin();
@ -26,8 +29,8 @@ class ResLimitTest extends ShimmieWebTestCase {
$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_max_height", "-1");
$this->setField("_config_upload_max_width", "-1");
$this->setField("_config_upload_ratios", "4:3 16:9");
$this->click("Save Settings");
$this->log_out();
@ -72,10 +75,10 @@ class ResLimitTest extends ShimmieWebTestCase {
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_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", "16:9");
$this->click("Save Settings");
$this->log_out();