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/upload/test.php

48 lines
1.3 KiB
PHP
Raw Normal View History

<?php
2015-09-20 19:28:27 +00:00
class UploadTest extends ShimmiePHPUnitTestCase {
2015-09-26 10:17:13 +00:00
public function testUploadPage() {
$this->log_in_as_user();
2009-09-20 03:10:34 +00:00
$this->get_page("upload");
$this->assert_title("Upload");
2015-09-20 19:28:27 +00:00
}
2009-09-20 03:10:34 +00:00
2015-09-26 10:17:13 +00:00
public function testUpload() {
2015-09-20 19:28:27 +00:00
$this->log_in_as_user();
$this->post_image("tests/pbx_screenshot.jpg", "pbx computer screenshot");
}
2015-09-26 10:17:13 +00:00
public function testRejectDupe() {
2015-09-20 19:28:27 +00:00
$this->post_image("tests/pbx_screenshot.jpg", "pbx computer screenshot");
2015-09-20 19:28:27 +00:00
try {
$this->post_image("tests/pbx_screenshot.jpg", "pbx computer screenshot");
}
catch(UploadException $e) {
$this->assertContains("already has hash", $e->getMessage());
}
}
2009-07-16 19:20:53 +00:00
2015-09-26 10:17:13 +00:00
public function testRejectUnknownFiletype() {
2015-09-20 19:28:27 +00:00
try {
$this->post_image("index.php", "test");
}
catch(UploadException $e) {
$this->assertContains("Invalid or corrupted file", $e->getMessage());
}
}
2015-09-26 10:17:13 +00:00
public function testRejectHuge() {
$this->markTestIncomplete();
2009-07-16 19:20:53 +00:00
// FIXME: huge.dat is rejected for other reasons; manual testing shows that this works
2015-08-09 11:14:28 +00:00
file_put_contents("huge.dat", file_get_contents("tests/pbx_screenshot.jpg") . str_repeat("U", 1024*1024*3));
$this->post_image("index.php", "test");
2009-08-19 00:28:48 +00:00
$this->assert_response(200);
$this->assert_title("Upload Status");
$this->assert_text("File too large");
2009-07-16 19:20:53 +00:00
unlink("huge.dat");
}
}