@@ -128,33 +128,34 @@ public function test_db_should_replace_additional_skip_tables(string $table, str
128
128
}
129
129
130
130
/**
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.
133
132
*
134
133
* @covers ::admin_output_new_settings_by_page
135
134
*/
136
135
public function test_admin_output_new_settings_by_page () {
137
136
$ this ->resetAfterTest ();
138
137
$ this ->setAdminUser ();
139
138
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
+
140
147
// Add settings not set during PHPUnit init.
141
148
set_config ('supportemail ' , 'support@example.com ' );
142
149
$ frontpage = new \admin_setting_special_frontpagedesc ();
143
150
$ 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.
153
152
unset_config ('numbering ' , 'book ' );
154
- unset_config ( ' supportemail ' );
153
+
155
154
$ root = admin_get_root (true , true );
156
155
$ 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 );
158
159
}
159
160
160
161
/**
0 commit comments