2020-01-26 13:19:35 +00:00
|
|
|
<?php declare(strict_types=1);
|
2020-01-28 21:19:59 +00:00
|
|
|
class ImageBanTest extends ShimmiePHPUnitTestCase
|
2019-05-28 16:59:38 +00:00
|
|
|
{
|
2020-01-30 09:01:19 +00:00
|
|
|
private $hash = "feb01bab5698a11dd87416724c7a89e3";
|
|
|
|
|
2020-03-28 14:33:48 +00:00
|
|
|
public function testPages()
|
|
|
|
{
|
|
|
|
$this->log_in_as_admin();
|
|
|
|
$page = $this->get_page("image_hash_ban/list");
|
|
|
|
$this->assertEquals(200, $page->code);
|
|
|
|
}
|
|
|
|
|
2019-05-28 16:59:38 +00:00
|
|
|
public function testBan()
|
|
|
|
{
|
|
|
|
$this->log_in_as_admin();
|
2020-01-28 21:19:59 +00:00
|
|
|
|
|
|
|
// 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
|
|
|
|
2020-01-28 21:19:59 +00:00
|
|
|
// Ban & delete
|
2020-01-30 09:01:19 +00:00
|
|
|
send_event(new AddImageHashBanEvent($this->hash, "test hash ban"));
|
|
|
|
send_event(new ImageDeletionEvent(Image::by_id($image_id), true));
|
2015-09-20 21:40:04 +00:00
|
|
|
|
2020-01-28 21:19:59 +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
|
|
|
|
2020-01-28 21:19:59 +00:00
|
|
|
// Can't repost
|
|
|
|
try {
|
|
|
|
$this->post_image("tests/pbx_screenshot.jpg", "pbx");
|
|
|
|
$this->assertTrue(false);
|
2020-01-29 00:49:21 +00:00
|
|
|
} catch (UploadException $e) {
|
2020-01-28 21:19:59 +00:00
|
|
|
$this->assertTrue(true);
|
|
|
|
}
|
2012-03-10 17:51:56 +00:00
|
|
|
|
2020-01-28 21:19:59 +00:00
|
|
|
// Remove ban
|
2020-01-30 09:01:19 +00:00
|
|
|
send_event(new RemoveImageHashBanEvent($this->hash));
|
2012-03-10 17:51:56 +00:00
|
|
|
|
2020-01-28 21:19:59 +00:00
|
|
|
// Can repost
|
2019-05-28 16:59:38 +00:00
|
|
|
$image_id = $this->post_image("tests/pbx_screenshot.jpg", "pbx");
|
2020-01-28 21:19:59 +00:00
|
|
|
$page = $this->get_page("post/view/$image_id");
|
|
|
|
$this->assertEquals(200, $page->code);
|
2019-05-28 16:59:38 +00:00
|
|
|
}
|
2020-01-30 09:01:19 +00:00
|
|
|
|
2020-03-13 09:23:54 +00:00
|
|
|
public function onNotSuccessfulTest(Throwable $t): void
|
2020-01-30 14:50:38 +00:00
|
|
|
{
|
2020-01-30 09:01:19 +00:00
|
|
|
send_event(new RemoveImageHashBanEvent($this->hash));
|
|
|
|
parent::onNotSuccessfulTest($t); // TODO: Change the autogenerated stub
|
|
|
|
}
|
2012-03-10 17:40:11 +00:00
|
|
|
}
|