Changeset 61090
- Timestamp:
- 10/30/2025 04:01:56 PM (2 weeks ago)
- Location:
- trunk
- Files:
-
- 2 edited
-
src/wp-includes/class-wp-block-templates-registry.php (modified) (2 diffs)
-
tests/phpunit/tests/block-template.php (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/class-wp-block-templates-registry.php
r60904 r61090 61 61 62 62 if ( $error_message ) { 63 _doing_it_wrong( 64 __METHOD__, 65 $error_message, 66 '6.7.0' 67 ); 63 _doing_it_wrong( __METHOD__, $error_message, '6.7.0' ); 64 68 65 return new WP_Error( $error_code, $error_message ); 69 66 } … … 222 219 public function unregister( $template_name ) { 223 220 if ( ! $this->is_registered( $template_name ) ) { 224 _doing_it_wrong(225 __METHOD__,226 /* translators: %s: Template name. */227 sprintf( __( 'Template "%s" is not registered.' ), $template_name ),228 '6.7.0'229 );230 221 /* translators: %s: Template name. */ 231 return new WP_Error( 'template_not_registered', __( 'Template "%s" is not registered.' ) ); 222 $error_message = sprintf( __( 'Template "%s" is not registered.' ), $template_name ); 223 224 _doing_it_wrong( __METHOD__, $error_message, '6.7.0' ); 225 226 return new WP_Error( 'template_not_registered', $error_message ); 232 227 } 233 228 -
trunk/tests/phpunit/tests/block-template.php
r60729 r61090 480 480 481 481 /** 482 * Tests that unregister_block_template() returns a WP_Error when trying to unregister 483 * a non-registered template, and that the error message includes the template name. 484 * 485 * @ticket 64072 486 * 487 * @covers ::unregister_block_template 488 */ 489 public function test_unregister_block_template_error_message_includes_template_name() { 490 $template_name = 'test-plugin//unregistered-template'; 491 492 // Ensure template is not registered. 493 unregister_block_template( $template_name ); 494 495 // Expect _doing_it_wrong() notice. 496 $this->setExpectedIncorrectUsage( 'WP_Block_Templates_Registry::unregister' ); 497 498 // Try to unregister again, should return WP_Error. 499 $error = unregister_block_template( $template_name ); 500 501 $this->assertInstanceOf( 'WP_Error', $error ); 502 $this->assertStringContainsString( 503 $template_name, 504 $error->get_error_message(), 505 'Error message should include the template name.' 506 ); 507 } 508 509 /** 482 510 * Registers a test block to log `in_the_loop()` results. 483 511 *
Note: See TracChangeset
for help on using the changeset viewer.