Changeset 42146
- Timestamp:
- 11/10/2017 10:29:45 PM (7 years ago)
- Location:
- trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-admin/includes/template.php
r41906 r42146 1458 1458 1459 1459 // Check global in case errors have been added on this pageload. 1460 if ( ! count( $wp_settings_errors ) )1460 if ( empty( $wp_settings_errors ) ) { 1461 1461 return array(); 1462 } 1462 1463 1463 1464 // Filter the results to those of a specific setting if one was set. -
trunk/tests/phpunit/tests/option/sanitize-option.php
r37747 r42146 158 158 ); 159 159 } 160 161 /** 162 * Test calling get_settings_errors() with variations on where it gets errors from. 163 * 164 * @ticket 42498 165 * @covers get_settings_errors() 166 * @global array $wp_settings_errors 167 */ 168 public function test_get_settings_errors_sources() { 169 global $wp_settings_errors; 170 171 $blogname_error = array( 172 'setting' => 'blogname', 173 'code' => 'blogname', 174 'message' => 'Capital P dangit!', 175 'type' => 'error', 176 ); 177 $blogdescription_error = array( 178 'setting' => 'blogdescription', 179 'code' => 'blogdescription', 180 'message' => 'Too short', 181 'type' => 'error', 182 ); 183 184 $wp_settings_errors = null; 185 $this->assertSame( array(), get_settings_errors( 'blogname' ) ); 186 187 // Test getting errors from transient. 188 $_GET['settings-updated'] = '1'; 189 set_transient( 'settings_errors', array( $blogname_error ) ); 190 $wp_settings_errors = null; 191 $this->assertSame( array( $blogname_error ), get_settings_errors( 'blogname' ) ); 192 193 // Test getting errors from transient and from global. 194 $_GET['settings-updated'] = '1'; 195 set_transient( 'settings_errors', array( $blogname_error ) ); 196 $wp_settings_errors = null; 197 add_settings_error( $blogdescription_error['setting'], $blogdescription_error['code'], $blogdescription_error['message'], $blogdescription_error['type'] ); 198 $this->assertEqualSets( array( $blogname_error, $blogdescription_error ), get_settings_errors() ); 199 200 $wp_settings_errors = null; 201 } 160 202 }
Note: See TracChangeset
for help on using the changeset viewer.