2021-12-14 18:32:47 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
declare(strict_types=1);
|
2023-01-10 22:44:09 +00:00
|
|
|
|
|
|
|
namespace Shimmie2;
|
|
|
|
|
2019-05-28 16:59:38 +00:00
|
|
|
class TipsTest extends ShimmiePHPUnitTestCase
|
|
|
|
{
|
2019-11-14 18:24:09 +00:00
|
|
|
public function setUp(): void
|
2019-05-28 16:59:38 +00:00
|
|
|
{
|
|
|
|
parent::setUp();
|
2020-01-28 21:19:59 +00:00
|
|
|
// Delete default tips so we can test from a blank slate
|
|
|
|
global $database;
|
|
|
|
$database->execute("DELETE FROM tips");
|
2019-05-28 16:59:38 +00:00
|
|
|
}
|
2010-03-12 18:34:37 +00:00
|
|
|
|
2024-01-15 14:31:51 +00:00
|
|
|
public function testImageless(): void
|
2019-05-28 16:59:38 +00:00
|
|
|
{
|
2020-01-28 21:19:59 +00:00
|
|
|
global $database;
|
2019-05-28 16:59:38 +00:00
|
|
|
$this->log_in_as_admin();
|
2010-03-12 18:34:37 +00:00
|
|
|
|
2019-05-28 16:59:38 +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"));
|
2019-05-28 16:59:38 +00:00
|
|
|
$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
|
|
|
|
2020-01-28 21:19:59 +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");
|
2019-05-28 16:59:38 +00:00
|
|
|
}
|
2010-03-12 18:34:37 +00:00
|
|
|
|
2024-01-15 14:31:51 +00:00
|
|
|
public function testImaged(): void
|
2019-05-28 16:59:38 +00:00
|
|
|
{
|
2020-01-28 21:19:59 +00:00
|
|
|
global $database;
|
2019-05-28 16:59:38 +00:00
|
|
|
$this->log_in_as_admin();
|
2010-03-12 18:34:37 +00:00
|
|
|
|
2019-05-28 16:59:38 +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"));
|
2019-05-28 16:59:38 +00:00
|
|
|
$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
|
|
|
|
2020-01-28 21:19:59 +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");
|
2019-05-28 16:59:38 +00:00
|
|
|
}
|
2010-03-12 18:34:37 +00:00
|
|
|
|
2024-01-15 14:31:51 +00:00
|
|
|
public function testDisabled(): void
|
2019-05-28 16:59:38 +00:00
|
|
|
{
|
2020-01-28 21:19:59 +00:00
|
|
|
global $database;
|
2019-05-28 16:59:38 +00:00
|
|
|
$this->log_in_as_admin();
|
2010-03-12 18:34:37 +00:00
|
|
|
|
2019-05-28 16:59:38 +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"));
|
2019-05-28 16:59:38 +00:00
|
|
|
$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
|
|
|
|
2020-01-28 21:19:59 +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");
|
2019-05-28 16:59:38 +00:00
|
|
|
}
|
2009-09-27 13:00:29 +00:00
|
|
|
}
|