test a couple extra branches

This commit is contained in:
Shish 2020-04-24 14:10:45 +01:00
parent 78710166a1
commit b0cb46abca
2 changed files with 20 additions and 0 deletions

View file

@ -247,6 +247,7 @@ class User
public function check_auth_token(): bool
{
if(defined("UNITTEST")) return true;
return (isset($_POST["auth_token"]) && $_POST["auth_token"] == $this->get_auth_token());
}

View file

@ -20,4 +20,23 @@ class ImageIOTest extends ShimmiePHPUnitTestCase
$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("image/delete"));
$this->assertTrue(true); // FIXME: assert image was deleted?
}
public function testReplaceRequest()
{
global $page;
$this->log_in_as_admin();
$image_id = $this->post_image("tests/pbx_screenshot.jpg", "test");
$_POST['image_id'] = "$image_id";
send_event(new PageRequestEvent("image/replace"));
$this->assertEquals("redirect", $page->mode);
}
}