2020-01-26 13:19:35 +00:00
|
|
|
<?php declare(strict_types=1);
|
2020-01-28 21:19:59 +00:00
|
|
|
class RatingsTest extends ShimmiePHPUnitTestCase
|
2019-05-28 17:59:38 +01:00
|
|
|
{
|
2020-01-29 01:47:43 +00:00
|
|
|
public function testRatingSafe()
|
2019-05-28 17:59:38 +01:00
|
|
|
{
|
|
|
|
$this->log_in_as_user();
|
|
|
|
$image_id = $this->post_image("tests/pbx_screenshot.jpg", "pbx");
|
2020-01-29 01:47:43 +00:00
|
|
|
$image = Image::by_id($image_id);
|
|
|
|
send_event(new RatingSetEvent($image, "s"));
|
2019-05-28 17:59:38 +01:00
|
|
|
|
|
|
|
# search for it in various ways
|
2020-01-29 01:47:43 +00:00
|
|
|
$page = $this->get_page("post/list/rating=Safe/1");
|
|
|
|
$this->assertEquals("/post/view/1", $page->redirect);
|
2019-05-28 17:59:38 +01:00
|
|
|
|
2020-01-29 01:47:43 +00:00
|
|
|
$page = $this->get_page("post/list/rating=s/1");
|
|
|
|
$this->assertEquals("/post/view/1", $page->redirect);
|
2019-05-28 17:59:38 +01:00
|
|
|
|
2020-01-29 01:47:43 +00:00
|
|
|
$page = $this->get_page("post/list/rating=sqe/1");
|
|
|
|
$this->assertEquals("/post/view/1", $page->redirect);
|
2019-05-28 17:59:38 +01:00
|
|
|
|
|
|
|
# test that search by tag still works
|
2020-01-29 01:47:43 +00:00
|
|
|
$page = $this->get_page("post/list/pbx/1");
|
|
|
|
$this->assertEquals("/post/view/1", $page->redirect);
|
2019-05-28 17:59:38 +01:00
|
|
|
|
|
|
|
# searching for a different rating should return nothing
|
2020-01-29 01:47:43 +00:00
|
|
|
$page = $this->get_page("post/list/rating=q/1");
|
|
|
|
$this->assertEquals("No Images Found", $page->heading);
|
|
|
|
}
|
2019-05-28 17:59:38 +01:00
|
|
|
|
2020-01-29 01:47:43 +00:00
|
|
|
public function testRatingExplicit()
|
|
|
|
{
|
|
|
|
$this->log_in_as_user();
|
|
|
|
$image_id = $this->post_image("tests/pbx_screenshot.jpg", "pbx");
|
|
|
|
$image = Image::by_id($image_id);
|
|
|
|
send_event(new RatingSetEvent($image, "e"));
|
2019-05-28 17:59:38 +01:00
|
|
|
|
|
|
|
# the explicit image shouldn't show up in anon's searches
|
2020-01-29 01:47:43 +00:00
|
|
|
$this->log_out();
|
|
|
|
$page = $this->get_page("post/list/pbx/1");
|
|
|
|
$this->assertEquals("No Images Found", $page->heading);
|
2019-05-28 17:59:38 +01:00
|
|
|
}
|
2009-08-13 21:42:48 +01:00
|
|
|
}
|