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

40 lines
1.2 KiB
PHP
Raw Normal View History

2020-01-26 13:19:35 +00:00
<?php declare(strict_types=1);
class ImageBanTest extends ShimmiePHPUnitTestCase
{
public function testBan()
{
$this->log_in_as_admin();
$hash = "feb01bab5698a11dd87416724c7a89e3";
// Post image
$image_id = $this->post_image("tests/pbx_screenshot.jpg", "pbx");
$page = $this->get_page("post/view/$image_id");
$this->assertEquals(200, $page->code);
2015-09-20 21:40:04 +00:00
// Ban & delete
send_event(new AddImageHashBanEvent($hash, "test hash ban"));
send_event(new ImageDeletionEvent(Image::by_id($image_id)));
2015-09-20 21:40:04 +00:00
// Check deleted
$page = $this->get_page("post/view/$image_id");
$this->assertEquals(404, $page->code);
2012-03-10 17:40:11 +00:00
// Can't repost
try {
$this->post_image("tests/pbx_screenshot.jpg", "pbx");
$this->assertTrue(false);
}
catch(UploadException $e) {
$this->assertTrue(true);
}
2012-03-10 17:51:56 +00:00
// Remove ban
send_event(new RemoveImageHashBanEvent($hash));
2012-03-10 17:51:56 +00:00
// Can repost
$image_id = $this->post_image("tests/pbx_screenshot.jpg", "pbx");
$page = $this->get_page("post/view/$image_id");
$this->assertEquals(200, $page->code);
}
2012-03-10 17:40:11 +00:00
}