fembooru/ext/rating/test.php

43 lines
1.5 KiB
PHP
Raw Normal View History

2020-01-26 13:19:35 +00:00
<?php declare(strict_types=1);
class RatingsTest extends ShimmiePHPUnitTestCase
{
2020-01-29 01:47:43 +00:00
public function testRatingSafe()
{
$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"));
# 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);
2020-01-29 01:47:43 +00:00
$page = $this->get_page("post/list/rating=s/1");
$this->assertEquals("/post/view/1", $page->redirect);
2020-01-29 01:47:43 +00:00
$page = $this->get_page("post/list/rating=sqe/1");
$this->assertEquals("/post/view/1", $page->redirect);
# 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);
# 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);
}
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"));
# 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);
}
2009-08-13 21:42:48 +01:00
}