2021-12-14 18:32:47 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
declare(strict_types=1);
|
2019-05-28 16:59:38 +00:00
|
|
|
class AdminPageTest extends ShimmiePHPUnitTestCase
|
|
|
|
{
|
|
|
|
public function testAuth()
|
|
|
|
{
|
2020-01-29 20:22:50 +00:00
|
|
|
send_event(new UserLoginEvent(User::by_name(self::$anon_name)));
|
2020-01-28 21:19:59 +00:00
|
|
|
$page = $this->get_page('admin');
|
|
|
|
$this->assertEquals(403, $page->code);
|
|
|
|
$this->assertEquals("Permission Denied", $page->title);
|
2019-05-28 16:59:38 +00:00
|
|
|
|
2020-01-29 20:22:50 +00:00
|
|
|
send_event(new UserLoginEvent(User::by_name(self::$user_name)));
|
2020-01-28 21:19:59 +00:00
|
|
|
$page = $this->get_page('admin');
|
|
|
|
$this->assertEquals(403, $page->code);
|
|
|
|
$this->assertEquals("Permission Denied", $page->title);
|
2019-05-28 16:59:38 +00:00
|
|
|
|
2020-01-29 20:22:50 +00:00
|
|
|
send_event(new UserLoginEvent(User::by_name(self::$admin_name)));
|
2020-01-28 21:19:59 +00:00
|
|
|
$page = $this->get_page('admin');
|
|
|
|
$this->assertEquals(200, $page->code);
|
|
|
|
$this->assertEquals("Admin Tools", $page->title);
|
2019-05-28 16:59:38 +00:00
|
|
|
}
|
|
|
|
|
2020-01-28 21:19:59 +00:00
|
|
|
public function testCommands()
|
2019-05-28 16:59:38 +00:00
|
|
|
{
|
2020-01-29 20:22:50 +00:00
|
|
|
send_event(new UserLoginEvent(User::by_name(self::$admin_name)));
|
2020-01-28 21:19:59 +00:00
|
|
|
ob_start();
|
|
|
|
send_event(new CommandEvent(["index.php", "help"]));
|
|
|
|
send_event(new CommandEvent(["index.php", "get-page", "post/list"]));
|
|
|
|
send_event(new CommandEvent(["index.php", "post-page", "post/list", "foo=bar"]));
|
|
|
|
send_event(new CommandEvent(["index.php", "get-token"]));
|
|
|
|
send_event(new CommandEvent(["index.php", "regen-thumb", "42"]));
|
|
|
|
ob_end_clean();
|
2020-01-29 20:22:50 +00:00
|
|
|
|
|
|
|
// don't crash
|
|
|
|
$this->assertTrue(true);
|
2019-05-28 16:59:38 +00:00
|
|
|
}
|
2008-10-11 07:09:42 +00:00
|
|
|
}
|