Skip to content
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Update or fix tests
The test for removing redundant leading slashes is likely redundant itself.
It checks that something that does not require escaping is not escaped.
  • Loading branch information
sirreal committed Aug 19, 2025
commit 97d3098c76635bb13480431edd584ccdef9a8ad2
18 changes: 9 additions & 9 deletions tests/phpunit/tests/blocks/editor.php
Original file line number Diff line number Diff line change
Expand Up @@ -630,13 +630,13 @@ function filter_add_preload_paths( $preload_paths, WP_Block_Editor_Context $cont

$after = implode( '', wp_scripts()->registered['wp-api-fetch']->extra['after'] );
$this->assertStringContainsString( 'wp.apiFetch.createPreloadingMiddleware', $after );
$this->assertStringContainsString( '"\/wp\/v2\/blocks"', $after );
$this->assertStringContainsString( '"\/wp\/v2\/types"', $after );
$this->assertStringContainsString( '"/wp/v2/blocks"', $after );
$this->assertStringContainsString( '"/wp/v2/types"', $after );
}

/**
* @ticket 54558
* @dataProvider data_block_editor_rest_api_preload_adds_missing_leading_slash
* @dataProvider data_block_editor_rest_api_preload_does_not_add_redundant_leading_slash
*
* @covers ::block_editor_rest_api_preload
*
Expand Down Expand Up @@ -692,31 +692,31 @@ public function test_get_classic_theme_supports_block_editor_settings() {
*
* @return array
*/
public function data_block_editor_rest_api_preload_adds_missing_leading_slash() {
public function data_block_editor_rest_api_preload_does_not_add_redundant_leading_slash() {
return array(
'a string without a slash' => array(
'preload_paths' => array( 'wp/v2/blocks' ),
'expected' => '\/wp\/v2\/blocks',
'expected' => '/wp/v2/blocks',
),
'a string with a slash' => array(
'preload_paths' => array( '/wp/v2/blocks' ),
'expected' => '\/wp\/v2\/blocks',
'expected' => '/wp/v2/blocks',
),
'a string starting with a question mark' => array(
'preload_paths' => array( '?context=edit' ),
'expected' => '/?context=edit',
),
'an array with a string without a slash' => array(
'preload_paths' => array( array( 'wp/v2/blocks', 'OPTIONS' ) ),
'expected' => '\/wp\/v2\/blocks',
'expected' => '/wp/v2/blocks',
),
'an array with a string with a slash' => array(
'preload_paths' => array( array( '/wp/v2/blocks', 'OPTIONS' ) ),
'expected' => '\/wp\/v2\/blocks',
'expected' => '/wp/v2/blocks',
),
'an array with a string starting with a question mark' => array(
'preload_paths' => array( array( '?context=edit', 'OPTIONS' ) ),
'expected' => '\/?context=edit',
'expected' => '/?context=edit',
),
);
}
Expand Down