MDL-81915 admin: Fix test_admin_output_new_settings_by_page unit test
This commit is contained in:
+14
-13
@@ -128,8 +128,7 @@ class adminlib_test extends \advanced_testcase {
|
||||
}
|
||||
|
||||
/**
|
||||
* Test method used by upgradesettings.php to make sure
|
||||
* there are no missing settings in PHPUnit and Behat tests.
|
||||
* Test admin_output_new_settings_by_page method.
|
||||
*
|
||||
* @covers ::admin_output_new_settings_by_page
|
||||
*/
|
||||
@@ -137,24 +136,26 @@ class adminlib_test extends \advanced_testcase {
|
||||
$this->resetAfterTest();
|
||||
$this->setAdminUser();
|
||||
|
||||
$root = admin_get_root(true, true);
|
||||
// The initial list of html pages with no default settings.
|
||||
$initialsettings = admin_output_new_settings_by_page($root);
|
||||
$this->assertArrayHasKey('supportcontact', $initialsettings);
|
||||
$this->assertArrayHasKey('frontpagesettings', $initialsettings);
|
||||
// Existing default setting.
|
||||
$this->assertArrayNotHasKey('modsettingbook', $initialsettings);
|
||||
|
||||
// Add settings not set during PHPUnit init.
|
||||
set_config('supportemail', '[email protected]');
|
||||
$frontpage = new \admin_setting_special_frontpagedesc();
|
||||
$frontpage->write_setting('test test');
|
||||
|
||||
// NOTE: if this test fails then it is most likely extra setting in
|
||||
// some additional plugin without default - developer needs to add
|
||||
// a workaround into their db/install.php for PHPUnit and Behat.
|
||||
|
||||
$root = admin_get_root(true, true);
|
||||
$new = admin_output_new_settings_by_page($root);
|
||||
$this->assertSame([], $new);
|
||||
|
||||
// Remove a default setting.
|
||||
unset_config('numbering', 'book');
|
||||
unset_config('supportemail');
|
||||
|
||||
$root = admin_get_root(true, true);
|
||||
$new = admin_output_new_settings_by_page($root);
|
||||
$this->assertCount(2, $new);
|
||||
$this->assertArrayNotHasKey('supportcontact', $new);
|
||||
$this->assertArrayNotHasKey('frontpagesettings', $new);
|
||||
$this->assertArrayHasKey('modsettingbook', $new);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user