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 PrivMsgTest extends ShimmiePHPUnitTestCase
|
|
|
|
{
|
2024-01-15 14:31:51 +00:00
|
|
|
public function testUserReadOwnMessage(): void
|
2019-05-28 16:59:38 +00:00
|
|
|
{
|
2020-01-28 21:19:59 +00:00
|
|
|
// Send from admin to user
|
2019-05-28 16:59:38 +00:00
|
|
|
$this->log_in_as_admin();
|
2020-01-28 21:19:59 +00:00
|
|
|
send_event(new SendPMEvent(new PM(
|
2020-01-29 20:22:50 +00:00
|
|
|
User::by_name(self::$admin_name)->id,
|
2020-01-28 21:19:59 +00:00
|
|
|
"0.0.0.0",
|
2020-01-29 20:22:50 +00:00
|
|
|
User::by_name(self::$user_name)->id,
|
2023-02-04 14:47:26 +00:00
|
|
|
"message demo to test",
|
|
|
|
"test body"
|
2020-01-28 21:19:59 +00:00
|
|
|
)));
|
|
|
|
|
|
|
|
// Check that user can see own messages
|
2019-05-28 16:59:38 +00:00
|
|
|
$this->log_in_as_user();
|
2024-02-11 11:34:09 +00:00
|
|
|
$this->get_page("user/" . self::$user_name);
|
2019-05-28 16:59:38 +00:00
|
|
|
$this->assert_text("message demo to test");
|
|
|
|
|
2020-01-28 21:19:59 +00:00
|
|
|
// FIXME: read PM
|
|
|
|
// $this->get_page("pm/read/0");
|
|
|
|
// $this->assert_text("No such PM");
|
2019-05-28 16:59:38 +00:00
|
|
|
|
2020-01-28 21:19:59 +00:00
|
|
|
// FIXME: delete PM
|
|
|
|
// send_event();
|
|
|
|
// $this->get_page("user");
|
|
|
|
// $this->assert_no_text("message demo to test");
|
2019-05-28 16:59:38 +00:00
|
|
|
|
2020-01-28 21:19:59 +00:00
|
|
|
// FIXME: verify deleted
|
|
|
|
// $this->get_page("pm/read/0");
|
|
|
|
// $this->assert_text("No such PM");
|
2019-05-28 16:59:38 +00:00
|
|
|
}
|
2023-02-04 14:16:32 +00:00
|
|
|
|
2024-01-15 14:31:51 +00:00
|
|
|
public function testAdminReadOtherMessage(): void
|
2023-02-04 14:16:32 +00:00
|
|
|
{
|
|
|
|
// Send from admin to user
|
|
|
|
$this->log_in_as_admin();
|
|
|
|
send_event(new SendPMEvent(new PM(
|
|
|
|
User::by_name(self::$admin_name)->id,
|
|
|
|
"0.0.0.0",
|
|
|
|
User::by_name(self::$user_name)->id,
|
2023-02-04 14:47:26 +00:00
|
|
|
"message demo to test",
|
|
|
|
"test body"
|
2023-02-04 14:16:32 +00:00
|
|
|
)));
|
|
|
|
|
|
|
|
// Check that admin can see user's messages
|
|
|
|
$this->get_page("user/" . self::$user_name);
|
|
|
|
$this->assert_text("message demo to test");
|
|
|
|
}
|
2009-07-19 03:48:25 +00:00
|
|
|
}
|