2021-12-14 18:32:47 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
declare(strict_types=1);
|
2023-01-10 22:44:09 +00:00
|
|
|
|
|
|
|
namespace Shimmie2;
|
|
|
|
|
2019-05-28 16:59:38 +00:00
|
|
|
class ReportImageTest extends ShimmiePHPUnitTestCase
|
|
|
|
{
|
2024-01-15 14:31:51 +00:00
|
|
|
public function testReportImage(): void
|
2019-05-28 16:59:38 +00:00
|
|
|
{
|
2020-01-28 21:19:59 +00:00
|
|
|
global $config, $database, $user;
|
|
|
|
|
|
|
|
$this->log_in_as_admin();
|
2019-05-28 16:59:38 +00:00
|
|
|
$image_id = $this->post_image("tests/pbx_screenshot.jpg", "pbx computer screenshot");
|
|
|
|
$this->get_page("post/view/$image_id");
|
|
|
|
|
2020-01-28 21:19:59 +00:00
|
|
|
// Add image report
|
|
|
|
send_event(new AddReportedImageEvent(new ImageReport($image_id, $user->id, "report details")));
|
2019-05-28 16:59:38 +00:00
|
|
|
|
2020-01-28 21:19:59 +00:00
|
|
|
// Check that the report exists
|
|
|
|
$config->set_bool("report_image_show_thumbs", true);
|
2019-05-28 16:59:38 +00:00
|
|
|
$this->get_page("image_report/list");
|
2020-10-26 15:18:23 +00:00
|
|
|
$this->assert_title("Reported Posts");
|
2019-05-28 16:59:38 +00:00
|
|
|
$this->assert_text("report details");
|
|
|
|
|
2020-01-28 21:19:59 +00:00
|
|
|
$config->set_bool("report_image_show_thumbs", false);
|
2019-05-28 16:59:38 +00:00
|
|
|
$this->get_page("image_report/list");
|
2020-10-26 15:18:23 +00:00
|
|
|
$this->assert_title("Reported Posts");
|
2019-05-28 16:59:38 +00:00
|
|
|
$this->assert_text("report details");
|
|
|
|
$this->assert_text("$image_id");
|
|
|
|
|
2020-01-28 21:19:59 +00:00
|
|
|
// Remove report
|
|
|
|
$report_id = (int)$database->get_one("SELECT id FROM image_reports");
|
|
|
|
send_event(new RemoveReportedImageEvent($report_id));
|
|
|
|
|
|
|
|
// Check that the report is gone
|
2019-05-28 16:59:38 +00:00
|
|
|
$this->get_page("image_report/list");
|
2020-10-26 15:18:23 +00:00
|
|
|
$this->assert_title("Reported Posts");
|
2019-05-28 16:59:38 +00:00
|
|
|
$this->assert_no_text("report details");
|
|
|
|
|
|
|
|
# FIXME: test delete image from report screen
|
|
|
|
# FIXME: test that >>123 works
|
|
|
|
}
|
2009-07-19 03:48:25 +00:00
|
|
|
}
|