This commit is contained in:
Shish
2020-01-29 01:47:43 +00:00
parent 6d3ca01424
commit aa1637d128
5 changed files with 49 additions and 129 deletions

View File

@@ -1,55 +1,42 @@
<?php declare(strict_types=1);
class RatingsTest extends ShimmiePHPUnitTestCase
{
public function testRating()
public function testRatingSafe()
{
$this->log_in_as_user();
$image_id = $this->post_image("tests/pbx_screenshot.jpg", "pbx");
# test for bug #735: user forced to set rating, can't
# set tags and leave unrated
$this->get_page("post/view/$image_id");
$this->assert_title("Image $image_id: pbx");
$this->markTestIncomplete();
$this->set_field("tag_edit__tags", "new");
$this->click("Set");
$this->assert_title("Image $image_id: new");
# set safe
$this->set_field("rating", "s");
$this->click("Set");
$this->assert_title("Image $image_id: new");
$image = Image::by_id($image_id);
send_event(new RatingSetEvent($image, "s"));
# search for it in various ways
$this->get_page("post/list/rating=Safe/1");
$this->assert_title("Image $image_id: new");
$page = $this->get_page("post/list/rating=Safe/1");
$this->assertEquals("/post/view/1", $page->redirect);
$this->get_page("post/list/rating=s/1");
$this->assert_title("Image $image_id: new");
$page = $this->get_page("post/list/rating=s/1");
$this->assertEquals("/post/view/1", $page->redirect);
$this->get_page("post/list/rating=sqe/1");
$this->assert_title("Image $image_id: new");
$page = $this->get_page("post/list/rating=sqe/1");
$this->assertEquals("/post/view/1", $page->redirect);
# test that search by tag still works
$this->get_page("post/list/new/1");
$this->assert_title("Image $image_id: new");
$page = $this->get_page("post/list/pbx/1");
$this->assertEquals("/post/view/1", $page->redirect);
# searching for a different rating should return nothing
$this->get_page("post/list/rating=q/1");
$this->assert_text("No Images Found");
$page = $this->get_page("post/list/rating=q/1");
$this->assertEquals("No Images Found", $page->heading);
}
# now set explicit, for the next test
$this->get_page("post/view/$image_id");
$this->set_field("rating", "e");
$this->click("Set");
$this->assert_title("Image $image_id: new");
$this->log_out();
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
$this->get_page("post/list/new/1");
$this->assert_text("No Images Found");
$this->log_out();
$page = $this->get_page("post/list/pbx/1");
$this->assertEquals("No Images Found", $page->heading);
}
}