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 UserPageTest extends ShimmiePHPUnitTestCase
|
|
|
|
{
|
|
|
|
public function testUserPage()
|
|
|
|
{
|
|
|
|
$this->get_page('user');
|
|
|
|
$this->assert_title("Not Logged In");
|
2021-01-16 21:06:01 +00:00
|
|
|
$this->assert_no_text("Stats");
|
2008-10-11 07:09:42 +00:00
|
|
|
|
2019-05-28 16:59:38 +00:00
|
|
|
$this->get_page('user/demo');
|
|
|
|
$this->assert_title("demo's Page");
|
|
|
|
$this->assert_text("Joined:");
|
2021-01-16 21:06:01 +00:00
|
|
|
$this->assert_no_text("Operations");
|
2008-10-11 07:09:42 +00:00
|
|
|
|
2019-05-28 16:59:38 +00:00
|
|
|
$this->get_page('user/MauMau');
|
|
|
|
$this->assert_title("No Such User");
|
2008-10-11 07:09:42 +00:00
|
|
|
|
2019-05-28 16:59:38 +00:00
|
|
|
$this->log_in_as_user();
|
|
|
|
// should be on the user page
|
|
|
|
$this->get_page('user/test');
|
|
|
|
$this->assert_title("test's Page");
|
2021-01-16 21:06:01 +00:00
|
|
|
$this->assert_text("Operations");
|
2019-05-28 16:59:38 +00:00
|
|
|
// FIXME: check class
|
|
|
|
//$this->assert_no_text("Admin:");
|
|
|
|
$this->log_out();
|
2008-10-11 07:09:42 +00:00
|
|
|
|
2019-05-28 16:59:38 +00:00
|
|
|
$this->log_in_as_admin();
|
|
|
|
// should be on the user page
|
|
|
|
$this->get_page('user/demo');
|
|
|
|
$this->assert_title("demo's Page");
|
2021-01-16 21:06:01 +00:00
|
|
|
$this->assert_text("Operations");
|
2019-05-28 16:59:38 +00:00
|
|
|
// FIXME: check class
|
|
|
|
//$this->assert_text("Admin:");
|
|
|
|
$this->log_out();
|
2023-06-24 12:09:21 +00:00
|
|
|
}
|
2009-07-20 05:51:36 +00:00
|
|
|
|
2023-06-24 12:09:21 +00:00
|
|
|
# FIXME: test user creation
|
|
|
|
# FIXME: test adminifying
|
|
|
|
# FIXME: test password reset
|
|
|
|
public function testUserList()
|
|
|
|
{
|
2019-05-28 16:59:38 +00:00
|
|
|
$this->get_page('user_admin/list');
|
|
|
|
$this->assert_text("demo");
|
|
|
|
}
|
2023-06-24 12:09:21 +00:00
|
|
|
|
|
|
|
public function testUserClasses()
|
|
|
|
{
|
|
|
|
$this->get_page('user_admin/classes');
|
|
|
|
$this->assert_text("admin");
|
|
|
|
}
|
2024-01-07 17:33:30 +00:00
|
|
|
|
|
|
|
public function testCreateOther()
|
|
|
|
{
|
|
|
|
global $page;
|
|
|
|
|
|
|
|
$this->assertException(UserCreationException::class, function () {
|
|
|
|
$this->log_out();
|
|
|
|
$this->post_page('user_admin/create_other', [
|
|
|
|
'name' => 'testnew',
|
|
|
|
'pass1' => 'testnew',
|
|
|
|
'email' => '',
|
|
|
|
]);
|
|
|
|
});
|
|
|
|
$this->assertNull(User::by_name('testnew'), "Anon can't create others");
|
|
|
|
|
|
|
|
$this->log_in_as_admin();
|
|
|
|
$this->post_page('user_admin/create_other', [
|
|
|
|
'name' => 'testnew',
|
|
|
|
'pass1' => 'testnew',
|
|
|
|
'email' => '',
|
|
|
|
]);
|
|
|
|
$this->assertEquals(302, $page->code);
|
|
|
|
$this->assertNotNull(User::by_name('testnew'), "Admin can create others");
|
|
|
|
}
|
2008-10-11 07:09:42 +00:00
|
|
|
}
|