Skip to content

Commit 049cca9

Browse files
MDL-81915 admin: Fix test_admin_output_new_settings_by_page unit test
1 parent f49d120 commit 049cca9

File tree

1 file changed

+14
-13
lines changed

1 file changed

+14
-13
lines changed

lib/tests/adminlib_test.php

+14-13
Original file line numberDiff line numberDiff line change
@@ -128,33 +128,34 @@ public function test_db_should_replace_additional_skip_tables(string $table, str
128128
}
129129

130130
/**
131-
* Test method used by upgradesettings.php to make sure
132-
* there are no missing settings in PHPUnit and Behat tests.
131+
* Test admin_output_new_settings_by_page method.
133132
*
134133
* @covers ::admin_output_new_settings_by_page
135134
*/
136135
public function test_admin_output_new_settings_by_page() {
137136
$this->resetAfterTest();
138137
$this->setAdminUser();
139138

139+
$root = admin_get_root(true, true);
140+
// The initial list of html pages with no default settings.
141+
$initialsettings = admin_output_new_settings_by_page($root);
142+
$this->assertArrayHasKey('supportcontact', $initialsettings);
143+
$this->assertArrayHasKey('frontpagesettings', $initialsettings);
144+
// Existing default setting.
145+
$this->assertArrayNotHasKey('modsettingbook', $initialsettings);
146+
140147
// Add settings not set during PHPUnit init.
141148
set_config('supportemail', 'support@example.com');
142149
$frontpage = new \admin_setting_special_frontpagedesc();
143150
$frontpage->write_setting('test test');
144-
145-
// NOTE: if this test fails then it is most likely extra setting in
146-
// some additional plugin without default - developer needs to add
147-
// a workaround into their db/install.php for PHPUnit and Behat.
148-
149-
$root = admin_get_root(true, true);
150-
$new = admin_output_new_settings_by_page($root);
151-
$this->assertSame([], $new);
152-
151+
// Remove a default setting.
153152
unset_config('numbering', 'book');
154-
unset_config('supportemail');
153+
155154
$root = admin_get_root(true, true);
156155
$new = admin_output_new_settings_by_page($root);
157-
$this->assertCount(2, $new);
156+
$this->assertArrayNotHasKey('supportcontact', $new);
157+
$this->assertArrayNotHasKey('frontpagesettings', $new);
158+
$this->assertArrayHasKey('modsettingbook', $new);
158159
}
159160

160161
/**

0 commit comments

Comments
 (0)