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/tips/test.php

71 lines
1.9 KiB
PHP
Raw Normal View History

2021-12-14 18:32:47 +00:00
<?php
declare(strict_types=1);
namespace Shimmie2;
class TipsTest extends ShimmiePHPUnitTestCase
{
2019-11-14 18:24:09 +00:00
public function setUp(): void
{
parent::setUp();
// Delete default tips so we can test from a blank slate
global $database;
$database->execute("DELETE FROM tips");
}
2010-03-12 18:34:37 +00:00
2024-01-15 14:31:51 +00:00
public function testImageless(): void
{
global $database;
$this->log_in_as_admin();
2010-03-12 18:34:37 +00:00
$this->get_page("tips/list");
$this->assert_title("Tips List");
2015-09-20 21:40:04 +00:00
2020-10-26 15:20:49 +00:00
send_event(new CreateTipEvent(true, "", "a postless tip"));
$this->get_page("post/list");
2020-10-26 15:20:49 +00:00
$this->assert_text("a postless tip");
2010-03-12 18:34:37 +00:00
$tip_id = (int)$database->get_one("SELECT id FROM tips");
send_event(new DeleteTipEvent($tip_id));
$this->get_page("post/list");
2020-10-26 15:20:49 +00:00
$this->assert_no_text("a postless tip");
}
2010-03-12 18:34:37 +00:00
2024-01-15 14:31:51 +00:00
public function testImaged(): void
{
global $database;
$this->log_in_as_admin();
2010-03-12 18:34:37 +00:00
$this->get_page("tips/list");
$this->assert_title("Tips List");
2015-09-20 21:40:04 +00:00
2020-10-26 15:20:49 +00:00
send_event(new CreateTipEvent(true, "coins.png", "a postless tip"));
$this->get_page("post/list");
2020-10-26 15:20:49 +00:00
$this->assert_text("a postless tip");
2010-03-12 18:34:37 +00:00
$tip_id = (int)$database->get_one("SELECT id FROM tips");
send_event(new DeleteTipEvent($tip_id));
$this->get_page("post/list");
2020-10-26 15:20:49 +00:00
$this->assert_no_text("a postless tip");
}
2010-03-12 18:34:37 +00:00
2024-01-15 14:31:51 +00:00
public function testDisabled(): void
{
global $database;
$this->log_in_as_admin();
2010-03-12 18:34:37 +00:00
$this->get_page("tips/list");
$this->assert_title("Tips List");
2015-09-20 21:40:04 +00:00
2020-10-26 15:20:49 +00:00
send_event(new CreateTipEvent(false, "", "a postless tip"));
$this->get_page("post/list");
2020-10-26 15:20:49 +00:00
$this->assert_no_text("a postless tip");
2010-03-12 18:34:37 +00:00
$tip_id = (int)$database->get_one("SELECT id FROM tips");
send_event(new DeleteTipEvent($tip_id));
$this->get_page("post/list");
2020-10-26 15:20:49 +00:00
$this->assert_no_text("a postless tip");
}
2009-09-27 13:00:29 +00:00
}