fix all the tests (for sqlite, php7.4, osx, at least)

This commit is contained in:
Shish
2020-01-28 21:19:59 +00:00
parent ac1076b3f3
commit 615da9e9d2
57 changed files with 665 additions and 859 deletions

View File

@ -3,59 +3,55 @@ class NumericScoreTest extends ShimmiePHPUnitTestCase
{
public function testNumericScore()
{
global $user;
$this->log_in_as_user();
$image_id = $this->post_image("tests/pbx_screenshot.jpg", "pbx");
$this->get_page("post/view/$image_id");
$this->markTestIncomplete();
$this->assert_text("Current Score: 0");
$this->click("Vote Down");
send_event(new NumericScoreSetEvent($image_id, $user, -1));
$this->get_page("post/view/$image_id");
$this->assert_text("Current Score: -1");
$this->click("Vote Up");
send_event(new NumericScoreSetEvent($image_id, $user, 1));
$this->get_page("post/view/$image_id");
$this->assert_text("Current Score: 1");
# FIXME: "remove vote" button?
# FIXME: test that up and down are hidden if already voted up or down
# test search by score
$this->get_page("post/list/score=1/1");
$this->assert_title("Image $image_id: pbx");
$page = $this->get_page("post/list/score=1/1");
$this->assertEquals(PageMode::REDIRECT, $page->mode);
$this->get_page("post/list/score>0/1");
$this->assert_title("Image $image_id: pbx");
$page = $this->get_page("post/list/score>0/1");
$this->assertEquals(PageMode::REDIRECT, $page->mode);
$this->get_page("post/list/score>-5/1");
$this->assert_title("Image $image_id: pbx");
$page = $this->get_page("post/list/score>-5/1");
$this->assertEquals(PageMode::REDIRECT, $page->mode);
$this->get_page("post/list/-score>5/1");
$this->assert_title("Image $image_id: pbx");
$page = $this->get_page("post/list/-score>5/1");
$this->assertEquals(PageMode::REDIRECT, $page->mode);
$this->get_page("post/list/-score<-5/1");
$this->assert_title("Image $image_id: pbx");
$page = $this->get_page("post/list/-score<-5/1");
$this->assertEquals(PageMode::REDIRECT, $page->mode);
# test search by vote
$this->get_page("post/list/upvoted_by=test/1");
$this->assert_title("Image $image_id: pbx");
$this->assert_no_text("No Images Found");
$page = $this->get_page("post/list/upvoted_by=test/1");
$this->assertEquals(PageMode::REDIRECT, $page->mode);
# and downvote
$this->get_page("post/list/downvoted_by=test/1");
$this->assert_text("No Images Found");
$page = $this->get_page("post/list/downvoted_by=test/1");
$this->assertEquals(404, $page->code);
# test errors
$this->get_page("post/list/upvoted_by=asdfasdf/1");
$this->assert_text("No Images Found");
$this->get_page("post/list/downvoted_by=asdfasdf/1");
$this->assert_text("No Images Found");
$this->get_page("post/list/upvoted_by_id=0/1");
$this->assert_text("No Images Found");
$this->get_page("post/list/downvoted_by_id=0/1");
$this->assert_text("No Images Found");
$this->log_out();
$this->log_in_as_admin();
$this->delete_image($image_id);
$this->log_out();
$page = $this->get_page("post/list/upvoted_by=asdfasdf/1");
$this->assertEquals(404, $page->code);
$page = $this->get_page("post/list/downvoted_by=asdfasdf/1");
$this->assertEquals(404, $page->code);
$page = $this->get_page("post/list/upvoted_by_id=0/1");
$this->assertEquals(404, $page->code);
$page = $this->get_page("post/list/downvoted_by_id=0/1");
$this->assertEquals(404, $page->code);
}
}