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

82 lines
2.3 KiB
PHP
Raw Normal View History

2021-12-14 18:32:47 +00:00
<?php
declare(strict_types=1);
namespace Shimmie2;
class UserPageTest extends ShimmiePHPUnitTestCase
{
2024-01-15 14:31:51 +00:00
public function testUserPage(): void
{
2024-02-11 11:34:09 +00:00
$page = $this->get_page('user');
$this->assertEquals(PageMode::REDIRECT, $page->mode);
$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");
$this->get_page('user/MauMau');
$this->assert_title("No Such User");
$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");
// FIXME: check class
//$this->assert_no_text("Admin:");
$this->log_out();
$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");
// 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
2024-01-15 14:31:51 +00:00
public function testUserList(): void
2023-06-24 12:09:21 +00:00
{
$this->get_page('user_admin/list');
$this->assert_text("demo");
}
2023-06-24 12:09:21 +00:00
2024-01-15 14:31:51 +00:00
public function testUserClasses(): void
2023-06-24 12:09:21 +00:00
{
$this->get_page('user_admin/classes');
$this->assert_text("admin");
}
2024-01-15 14:31:51 +00:00
public function testCreateOther(): void
{
global $page;
2024-02-11 15:47:40 +00:00
$this->assertException(PermissionDenied::class, function () {
$this->log_out();
$this->post_page('user_admin/create_other', [
'name' => 'testnew',
'pass1' => 'testnew',
2024-04-26 22:35:48 +00:00
'pass2' => 'testnew',
'email' => '',
]);
});
$this->assertException(UserNotFound::class, function () {User::by_name('testnew');});
$this->log_in_as_admin();
$this->post_page('user_admin/create_other', [
'name' => 'testnew',
'pass1' => 'testnew',
2024-04-26 22:35:48 +00:00
'pass2' => 'testnew',
'email' => '',
]);
$this->assertEquals(302, $page->code);
$this->assertNotNull(User::by_name('testnew'));
}
}