forked from moodle/moodle
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
MDL-81915 admin: Fix test_admin_output_new_settings_by_page unit test
- Loading branch information
1 parent
bcae216
commit c6d083f
Showing
1 changed file
with
14 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -128,33 +128,34 @@ public function test_db_should_replace_additional_skip_tables(string $table, str | |
} | ||
|
||
/** | ||
* 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 | ||
*/ | ||
public function test_admin_output_new_settings_by_page() { | ||
$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); | ||
} | ||
|
||
/** | ||
|