forked from Cavemanon/cavepaintings
A ton of tests, figured out how to test uploads \o/
This commit is contained in:
@@ -8,7 +8,7 @@
|
||||
* Some data is being uploaded. Should be caught by a file handler.
|
||||
*/
|
||||
class DataUploadEvent extends Event {
|
||||
var $user, $tmpname, $metadata, $hash, $type;
|
||||
var $user, $tmpname, $metadata, $hash, $type, $image_id = -1;
|
||||
|
||||
public function DataUploadEvent($user, $tmpname, $metadata) {
|
||||
$this->user = $user;
|
||||
@@ -150,6 +150,7 @@ class Upload implements Extension {
|
||||
$event = new DataUploadEvent($user, $file['tmp_name'], $metadata);
|
||||
try {
|
||||
send_event($event);
|
||||
header("X-Shimmie-Image-ID: ".int_escape($event->image_id));
|
||||
}
|
||||
catch(UploadException $ex) {
|
||||
$this->theme->display_upload_error($page, "Error with ".html_escape($file['name']),
|
||||
|
21
ext/upload/test.php
Normal file
21
ext/upload/test.php
Normal file
@@ -0,0 +1,21 @@
|
||||
<?php
|
||||
class UploadTest extends ShimmieWebTestCase {
|
||||
function testUpload() {
|
||||
$this->log_in_as_user();
|
||||
|
||||
$image_id_1 = $this->post_image("ext/simpletest/data/pbx_screenshot.jpg", "pbx computer screenshot");
|
||||
$this->assertResponse(302);
|
||||
|
||||
$image_id_2 = $this->post_image("ext/simpletest/data/pbx_screenshot.jpg", "pbx computer screenshot");
|
||||
$this->assertTitle("Upload Status");
|
||||
$this->assertText("already has hash");
|
||||
|
||||
$this->log_out();
|
||||
|
||||
$this->log_in_as_admin();
|
||||
$this->delete_image($image_id_1);
|
||||
$this->delete_image($image_id_2);
|
||||
$this->log_out();
|
||||
}
|
||||
}
|
||||
?>
|
Reference in New Issue
Block a user