mirror of
https://github.com/catalyst/moodle-auth_outage.git
synced 2026-05-16 21:41:31 +02:00
Modify unit tests to declare expected output
This commit is contained in:
@@ -422,9 +422,6 @@ EOT;
|
||||
* @param outage|null $outage Outage or null if no scheduled outage.
|
||||
*/
|
||||
private static function maintenance_config_log(outage $outage) {
|
||||
// Not output logging info in php unit test.
|
||||
if (PHPUNIT_TEST) return;
|
||||
|
||||
mtrace(get_string('logformaintmodeconfig', 'auth_outage'));
|
||||
$timezone = ' (Timezone ' . \core_date::get_server_timezone_object()->getName() . ')';
|
||||
mtrace('... updated at ' . date('H:i:s'));
|
||||
|
||||
@@ -63,7 +63,11 @@ class auth_outage_installation_test extends auth_outage_base_testcase {
|
||||
'title' => 'Title',
|
||||
'description' => 'Description',
|
||||
]);
|
||||
ob_start();
|
||||
\auth_outage\dml\outagedb::save($outage);
|
||||
$text = trim(ob_get_contents());
|
||||
ob_end_clean();
|
||||
self::assertStringContainsString('Update maintenance mode configuration', $text);
|
||||
self::assertSame(1, $DB->count_records_select('event', "eventtype = 'auth_outage'", null));
|
||||
|
||||
// Uninstall plugin.
|
||||
|
||||
@@ -159,8 +159,8 @@ class auth_outage_create_test extends auth_outage_cli_testcase {
|
||||
$text = $this->execute($cli);
|
||||
self::assertStringContainsString('created', $text);
|
||||
// Check creted outage.
|
||||
list(, $id) = explode(':', $text);
|
||||
$id = (int)$id;
|
||||
$clioutput = explode(':', $text);
|
||||
$id = (int)end($clioutput);
|
||||
$outage = outagedb::get_by_id($id);
|
||||
self::assertSame($now, $outage->starttime);
|
||||
self::assertSame(10, $outage->get_warning_duration());
|
||||
@@ -223,8 +223,8 @@ class auth_outage_create_test extends auth_outage_cli_testcase {
|
||||
$text = $this->execute($cli);
|
||||
self::assertStringContainsString('created', $text);
|
||||
// Check creted outage.
|
||||
list(, $id) = explode(':', $text);
|
||||
$id = (int)$id;
|
||||
$clioutput = explode(':', $text);
|
||||
$id = (int)end($clioutput);
|
||||
$outage = outagedb::get_by_id($id);
|
||||
self::assertSame($now + 50, $outage->starttime, 'Wrong starttime.');
|
||||
self::assertSame($outage->starttime - 100, $outage->warntime, 'Wrong warntime.');
|
||||
|
||||
@@ -60,7 +60,11 @@ class auth_outage_outagelib_test extends auth_outage_base_testcase {
|
||||
]);
|
||||
|
||||
set_config('maintenance_message', 'A message.');
|
||||
ob_start();
|
||||
outagedb::save($outage);
|
||||
$text = trim(ob_get_contents());
|
||||
ob_end_clean();
|
||||
self::assertStringContainsString('Update maintenance mode configuration', $text);
|
||||
self::assertFalse((bool)get_config('moodle', 'maintenance_message'));
|
||||
self::assertCount(2, $this->getDebuggingMessages());
|
||||
$this->resetDebugging();
|
||||
@@ -94,7 +98,11 @@ class auth_outage_outagelib_test extends auth_outage_base_testcase {
|
||||
'title' => 'Title',
|
||||
'description' => 'Description',
|
||||
]);
|
||||
ob_start();
|
||||
$outage->id = outagedb::save($outage);
|
||||
$text = trim(ob_get_contents());
|
||||
ob_end_clean();
|
||||
self::assertStringContainsString('Update maintenance mode configuration', $text);
|
||||
|
||||
outagelib::reset_injectcalled();
|
||||
// Get full header to avoid interactions with other single inject plugins.
|
||||
@@ -136,7 +144,11 @@ class auth_outage_outagelib_test extends auth_outage_base_testcase {
|
||||
'title' => 'Title',
|
||||
'description' => 'Description',
|
||||
]);
|
||||
ob_start();
|
||||
$outage->id = outagedb::save($outage);
|
||||
$text = trim(ob_get_contents());
|
||||
ob_end_clean();
|
||||
self::assertStringContainsString('Update maintenance mode configuration', $text);
|
||||
|
||||
$_GET = ['auth_outage_preview' => (string)$outage->id];
|
||||
|
||||
@@ -175,8 +187,11 @@ class auth_outage_outagelib_test extends auth_outage_base_testcase {
|
||||
'title' => 'Title',
|
||||
'description' => 'Description',
|
||||
]);
|
||||
ob_start();
|
||||
$outage->id = outagedb::save($outage);
|
||||
|
||||
$text = trim(ob_get_contents());
|
||||
ob_end_clean();
|
||||
self::assertStringContainsString('Update maintenance mode configuration', $text);
|
||||
$_GET = ['auth_outage_preview' => (string)$outage->id, 'auth_outage_delta' => '500'];
|
||||
outagelib::reset_injectcalled();
|
||||
$header = outagelib::get_inject_code();
|
||||
@@ -282,7 +297,11 @@ class auth_outage_outagelib_test extends auth_outage_base_testcase {
|
||||
'title' => 'Title',
|
||||
'description' => 'Description',
|
||||
]);
|
||||
ob_start();
|
||||
$outage->id = outagedb::save($outage);
|
||||
$text = trim(ob_get_contents());
|
||||
ob_end_clean();
|
||||
self::assertStringContainsString('Update maintenance mode configuration', $text);
|
||||
|
||||
// Pretend we are there...
|
||||
$_SERVER['SCRIPT_FILENAME'] = '/var/www/alternativepath/admin/settings.php'; // Issue #88 regression test.
|
||||
@@ -538,8 +557,11 @@ EOT;
|
||||
'title' => 'Title',
|
||||
'description' => 'Description',
|
||||
]);
|
||||
ob_start();
|
||||
$outage->id = outagedb::save($outage);
|
||||
|
||||
$text = trim(ob_get_contents());
|
||||
ob_end_clean();
|
||||
self::assertStringContainsString('Update maintenance mode configuration', $text);
|
||||
// Pretend we are there...
|
||||
$_SERVER['SCRIPT_FILENAME'] = '/var/www/alternativepath/admin/settings.php'; // Issue #88 regression test.
|
||||
$_SERVER['SCRIPT_NAME'] = '/admin/settings.php';
|
||||
|
||||
Reference in New Issue
Block a user