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/image/test.php
Shish 26bf4277e0 Separate out GET and POST more explicitly
- No longer allow uploading directly via GET, that is terrible for
  security. Instead, use the GET parameters to pre-fill the upload form.
- PageRequestEvent has a `method` property that can be checked in
  extensions
2024-01-01 03:30:21 +00:00

37 lines
1.1 KiB
PHP

<?php
declare(strict_types=1);
namespace Shimmie2;
class ImageIOTest extends ShimmiePHPUnitTestCase
{
public function testUserStats()
{
$this->log_in_as_user();
$image_id = $this->post_image("tests/pbx_screenshot.jpg", "test");
// broken with sqlite?
//$this->get_page("user/test");
//$this->assert_text("Images uploaded: 1");
//$this->click("Images uploaded");
//$this->assert_title("Image $image_id: test");
# test that serving manually doesn't cause errors
$page = $this->get_page("image/$image_id/moo.jpg");
$this->assertEquals(200, $page->code);
$page = $this->get_page("thumb/$image_id/moo.jpg");
$this->assertEquals(200, $page->code);
}
public function testDeleteRequest()
{
$this->log_in_as_admin();
$image_id = $this->post_image("tests/pbx_screenshot.jpg", "test");
$_POST['image_id'] = "$image_id";
send_event(new PageRequestEvent("POST", "image/delete"));
$this->assertTrue(true); // FIXME: assert image was deleted?
}
}