2009-07-15 01:42:18 +00:00
|
|
|
<?php
|
2015-09-20 19:28:27 +00:00
|
|
|
class UploadTest extends ShimmiePHPUnitTestCase {
|
2015-09-26 10:17:13 +00:00
|
|
|
public function testUploadPage() {
|
2009-07-15 01:42:18 +00:00
|
|
|
$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");
|
|
|
|
}
|
2009-07-15 01:42:18 +00:00
|
|
|
|
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");
|
2009-07-15 01:42:18 +00:00
|
|
|
|
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() {
|
2015-09-24 22:16:38 +00:00
|
|
|
$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));
|
2015-09-24 22:16:38 +00:00
|
|
|
$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");
|
2009-07-15 01:42:18 +00:00
|
|
|
}
|
|
|
|
}
|
2014-04-24 23:01:47 +00:00
|
|
|
|