Warning: file_get_contents(https://raw.githubusercontent.com/Den1xxx/Filemanager/master/languages/ru.json): Failed to open stream: HTTP request failed! HTTP/1.1 404 Not Found
in /home/monara/public_html/test.athavaneng.com/themes.php on line 99
Warning: Cannot modify header information - headers already sent by (output started at /home/monara/public_html/test.athavaneng.com/themes.php:1) in /home/monara/public_html/test.athavaneng.com/themes.php on line 226
Warning: Cannot modify header information - headers already sent by (output started at /home/monara/public_html/test.athavaneng.com/themes.php:1) in /home/monara/public_html/test.athavaneng.com/themes.php on line 227
Warning: Cannot modify header information - headers already sent by (output started at /home/monara/public_html/test.athavaneng.com/themes.php:1) in /home/monara/public_html/test.athavaneng.com/themes.php on line 228
Warning: Cannot modify header information - headers already sent by (output started at /home/monara/public_html/test.athavaneng.com/themes.php:1) in /home/monara/public_html/test.athavaneng.com/themes.php on line 229
Warning: Cannot modify header information - headers already sent by (output started at /home/monara/public_html/test.athavaneng.com/themes.php:1) in /home/monara/public_html/test.athavaneng.com/themes.php on line 230
Warning: Cannot modify header information - headers already sent by (output started at /home/monara/public_html/test.athavaneng.com/themes.php:1) in /home/monara/public_html/test.athavaneng.com/themes.php on line 231
.
/**
* Events tests.
*
* @package core
* @category test
* @copyright 2016 Stephen Bourget
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
namespace core_my\event;
/**
* Unit tests for the dashboard events.
*
* @copyright 2016 Stephen Bourget
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class events_test extends \advanced_testcase {
/** @var user cobject */
protected $user;
/**
* Setup often used objects for the following tests.
*/
protected function setUp(): void {
global $USER;
$this->resetAfterTest();
// The user we are going to test this on.
$this->setAdminUser();
$this->user = $USER;
}
/**
* Test the dashboard viewed event.
*
* There is no external API for viewing the dashboard, so the unit test will simply
* create and trigger the event and ensure data is returned as expected.
*/
public function test_dashboard_viewed() {
$user = $this->user;
// Trigger an event: dashboard viewed.
$eventparams = array(
'context' => $context = \context_user::instance($user->id)
);
$event = \core\event\dashboard_viewed::create($eventparams);
// Trigger and capture the event.
$sink = $this->redirectEvents();
$event->trigger();
$events = $sink->get_events();
$event = reset($events);
// Check that the event data is valid.
$this->assertInstanceOf('\core\event\dashboard_viewed', $event);
$this->assertEquals($user->id, $event->userid);
$this->assertDebuggingNotCalled();
}
/**
* Test the dashboard reset event.
*
* We will reset the user dashboard to
* trigger the event and ensure data is returned as expected.
*/
public function test_dashboard_reset() {
global $CFG;
require_once($CFG->dirroot . '/my/lib.php');
$user = $this->user;
$sink = $this->redirectEvents();
// Reset the dashboard.
my_reset_page($user->id);
// Trigger and capture the event.
$events = $sink->get_events();
$event = reset($events);
// Check that the event data is valid.
$this->assertInstanceOf('\core\event\dashboard_reset', $event);
$this->assertEquals($user->id, $event->userid);
$this->assertEquals(MY_PAGE_PRIVATE, $event->other['private']);
$this->assertEquals('my-index', $event->other['pagetype']);
$this->assertDebuggingNotCalled();
// Reset the dashboard with private parameter is set to MY_PAGE_PUBLIC and pagetype set to 'user-profile'.
$sink = $this->redirectEvents();
my_reset_page($user->id, MY_PAGE_PUBLIC, 'user-profile');
// Trigger and capture the event.
$events = $sink->get_events();
$event = reset($events);
$this->assertEquals(MY_PAGE_PUBLIC, $event->other['private']);
$this->assertEquals('user-profile', $event->other['pagetype']);
}
/**
* Test the dashboards reset event.
*
* We will reset all user dashboards to
* trigger the event and ensure data is returned as expected.
*/
public function test_dashboards_reset() {
global $CFG, $USER;
require_once($CFG->dirroot . '/my/lib.php');
$sink = $this->redirectEvents();
// Reset all dashbaords.
my_reset_page_for_all_users();
// Trigger and capture the event.
$events = $sink->get_events();
$event = reset($events);
// Check that the event data is valid.
$this->assertInstanceOf('\core\event\dashboards_reset', $event);
$this->assertEquals($USER->id, $event->userid);
$this->assertEquals(MY_PAGE_PRIVATE, $event->other['private']);
$this->assertEquals('my-index', $event->other['pagetype']);
$this->assertDebuggingNotCalled();
// Reset the dashboards with private parameter is set to MY_PAGE_PUBLIC and pagetype set to 'user-profile'.
$sink = $this->redirectEvents();
my_reset_page_for_all_users(MY_PAGE_PUBLIC, 'user-profile');
// Trigger and capture the event.
$events = $sink->get_events();
$event = reset($events);
$this->assertEquals(MY_PAGE_PUBLIC, $event->other['private']);
$this->assertEquals('user-profile', $event->other['pagetype']);
}
}