Skip to content

Commit

Permalink
Fix failing test
Browse files Browse the repository at this point in the history
  • Loading branch information
swissspidy committed Jan 22, 2025
1 parent c0768bc commit 9025884
Showing 1 changed file with 4 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -457,39 +457,35 @@ public function test_get_allowed_mime_types(): void {
* Test that validate_url validates URLs.
*
* @param string $url The URL to validate.
* @param string $expected Expected result.
* @param false|callable $cb_safe_ports The name of the callback to http_allowed_safe_ports or false if none.
* Default false.
* Default false.
*
* @dataProvider data_validate_url_should_validate
* @covers ::validate_url
*/
public function test_validate_url_should_validate( string $url, string $expected, $cb_safe_ports = false ): void {
public function test_validate_url_should_validate( string $url, $cb_safe_ports = false ): void {
if ( $cb_safe_ports ) {
add_filter( 'http_allowed_safe_ports', $cb_safe_ports );
}

$this->assertSame( $expected, $this->call_private_method( [ $this->controller, 'validate_url' ], [ $url ] ) );
$this->assertNotFalse( $this->call_private_method( [ $this->controller, 'validate_url' ], [ $url ] ) );
}

/**
* Data provider.
*
* @return array<string, array{url: string, expected: string, cb_safe_ports?: callable}>
* @return array<string, array{url: string, cb_safe_ports?: callable}>
*/
public function data_validate_url_should_validate(): array {
return [
'no port specified' => [
'url' => 'http://example.com/caniload.php',

Check failure on line 482 in tests/phpunit/integration/tests/REST_API/Hotlinking_Controller.php

View workflow job for this annotation

GitHub Actions / Lint

Array double arrow not aligned correctly; expected 1 space(s) between "'url'" and double arrow, but found 6.
'expected' => '93.184.215.14',
],
'a port considered safe by default' => [
'url' => 'https://example.com:8080/caniload.php',

Check failure on line 485 in tests/phpunit/integration/tests/REST_API/Hotlinking_Controller.php

View workflow job for this annotation

GitHub Actions / Lint

Array double arrow not aligned correctly; expected 1 space(s) between "'url'" and double arrow, but found 6.
'expected' => '93.184.215.14',
],
'a port considered safe by filter' => [
'url' => 'https://example.com:81/caniload.php',
'expected' => '93.184.215.14',
'cb_safe_ports' => [ $this, 'callback_custom_safe_ports' ],
],
];
Expand Down

0 comments on commit 9025884

Please sign in to comment.