This repository has been archived on 2024-09-05. You can view files and clone it, but cannot push or open issues or pull requests.
shimmie2/ext/rating/test.php

39 lines
1.3 KiB
PHP
Raw Normal View History

2021-12-14 18:32:47 +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 20:22:50 +00:00
$this->assert_search_results(["rating=Safe"], [$image_id]);
$this->assert_search_results(["rating=s"], [$image_id]);
$this->assert_search_results(["rating=sqe"], [$image_id]);
# test that search by tag still works
2020-01-29 20:22:50 +00:00
$this->assert_search_results(["pbx"], [$image_id]);
# searching for a different rating should return nothing
2020-01-29 20:22:50 +00:00
$this->assert_search_results(["rating=q"], []);
2020-01-29 01:47:43 +00:00
}
2020-01-29 01:47:43 +00:00
public function testRatingExplicit()
{
global $config;
$config->set_array("ext_rating_anonymous_privs", ["s", "q"]);
2020-01-29 01:47:43 +00:00
$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();
2020-01-29 20:22:50 +00:00
$this->assert_search_results(["pbx"], []);
}
2009-08-13 20:42:48 +00:00
}