Skip to content

Commit

Permalink
Fix named arguments in data providers
Browse files Browse the repository at this point in the history
  • Loading branch information
derrabus committed Sep 20, 2024
1 parent 9de29a7 commit b58efe8
Showing 1 changed file with 30 additions and 30 deletions.
60 changes: 30 additions & 30 deletions Tests/TextSanitizer/UrlSanitizerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public function testSanitize(?string $input, ?array $allowedSchemes, ?array $all
$this->assertSame($expected, UrlSanitizer::sanitize($input, $allowedSchemes, $forceHttps, $allowedHosts, $allowRelative));
}

public static function provideSanitize()
public static function provideSanitize(): iterable
{
// Simple accepted cases
yield [
Expand All @@ -33,7 +33,7 @@ public static function provideSanitize()
'allowedHosts' => null,
'forceHttps' => false,
'allowRelative' => false,
'output' => null,
'expected' => null,
];

yield [
Expand All @@ -42,7 +42,7 @@ public static function provideSanitize()
'allowedHosts' => null,
'forceHttps' => false,
'allowRelative' => false,
'output' => null,
'expected' => null,
];

yield [
Expand All @@ -51,7 +51,7 @@ public static function provideSanitize()
'allowedHosts' => null,
'forceHttps' => false,
'allowRelative' => false,
'output' => 'http://trusted.com/link.php',
'expected' => 'http://trusted.com/link.php',
];

yield [
Expand All @@ -60,7 +60,7 @@ public static function provideSanitize()
'allowedHosts' => null,
'forceHttps' => false,
'allowRelative' => false,
'output' => 'https://trusted.com/link.php',
'expected' => 'https://trusted.com/link.php',
];

yield [
Expand All @@ -69,7 +69,7 @@ public static function provideSanitize()
'allowedHosts' => null,
'forceHttps' => false,
'allowRelative' => false,
'output' => 'data:text/plain;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7',
'expected' => 'data:text/plain;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7',
];

yield [
Expand All @@ -78,7 +78,7 @@ public static function provideSanitize()
'allowedHosts' => null,
'forceHttps' => false,
'allowRelative' => false,
'output' => 'https://trusted.com/link.php',
'expected' => 'https://trusted.com/link.php',
];

yield [
Expand All @@ -87,7 +87,7 @@ public static function provideSanitize()
'allowedHosts' => ['trusted.com'],
'forceHttps' => false,
'allowRelative' => false,
'output' => 'https://trusted.com/link.php',
'expected' => 'https://trusted.com/link.php',
];

yield [
Expand All @@ -96,7 +96,7 @@ public static function provideSanitize()
'allowedHosts' => ['trusted.com'],
'forceHttps' => false,
'allowRelative' => false,
'output' => 'http://trusted.com/link.php',
'expected' => 'http://trusted.com/link.php',
];

yield [
Expand All @@ -105,7 +105,7 @@ public static function provideSanitize()
'allowedHosts' => null,
'forceHttps' => false,
'allowRelative' => false,
'output' => 'data:text/plain;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7',
'expected' => 'data:text/plain;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7',
];

// Simple filtered cases
Expand All @@ -115,7 +115,7 @@ public static function provideSanitize()
'allowedHosts' => null,
'forceHttps' => false,
'allowRelative' => false,
'output' => null,
'expected' => null,
];

yield [
Expand All @@ -124,7 +124,7 @@ public static function provideSanitize()
'allowedHosts' => null,
'forceHttps' => false,
'allowRelative' => false,
'output' => null,
'expected' => null,
];

yield [
Expand All @@ -133,7 +133,7 @@ public static function provideSanitize()
'allowedHosts' => null,
'forceHttps' => false,
'allowRelative' => true,
'output' => 'http:link.php',
'expected' => 'http:link.php',
];

yield [
Expand All @@ -142,7 +142,7 @@ public static function provideSanitize()
'allowedHosts' => ['trusted.com'],
'forceHttps' => false,
'allowRelative' => false,
'output' => null,
'expected' => null,
];

yield [
Expand All @@ -151,7 +151,7 @@ public static function provideSanitize()
'allowedHosts' => null,
'forceHttps' => false,
'allowRelative' => false,
'output' => null,
'expected' => null,
];

yield [
Expand All @@ -160,7 +160,7 @@ public static function provideSanitize()
'allowedHosts' => ['trusted.com'],
'forceHttps' => false,
'allowRelative' => false,
'output' => null,
'expected' => null,
];

yield [
Expand All @@ -169,7 +169,7 @@ public static function provideSanitize()
'allowedHosts' => ['trusted.com'],
'forceHttps' => false,
'allowRelative' => false,
'output' => null,
'expected' => null,
];

yield [
Expand All @@ -178,7 +178,7 @@ public static function provideSanitize()
'allowedHosts' => null,
'forceHttps' => false,
'allowRelative' => false,
'output' => null,
'expected' => null,
];

yield [
Expand All @@ -187,7 +187,7 @@ public static function provideSanitize()
'allowedHosts' => ['trusted.com'],
'forceHttps' => false,
'allowRelative' => false,
'output' => null,
'expected' => null,
];

// Allow null host (data scheme for instance)
Expand All @@ -197,7 +197,7 @@ public static function provideSanitize()
'allowedHosts' => ['trusted.com', null],
'forceHttps' => false,
'allowRelative' => false,
'output' => 'data:text/plain;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7',
'expected' => 'data:text/plain;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7',
];

// Force HTTPS
Expand All @@ -207,7 +207,7 @@ public static function provideSanitize()
'allowedHosts' => ['trusted.com'],
'forceHttps' => true,
'allowRelative' => false,
'output' => 'https://trusted.com/link.php',
'expected' => 'https://trusted.com/link.php',
];

yield [
Expand All @@ -216,7 +216,7 @@ public static function provideSanitize()
'allowedHosts' => ['trusted.com'],
'forceHttps' => true,
'allowRelative' => false,
'output' => 'https://trusted.com/link.php',
'expected' => 'https://trusted.com/link.php',
];

yield [
Expand All @@ -225,7 +225,7 @@ public static function provideSanitize()
'allowedHosts' => null,
'forceHttps' => true,
'allowRelative' => false,
'output' => 'data:text/plain;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7',
'expected' => 'data:text/plain;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7',
];

yield [
Expand All @@ -234,7 +234,7 @@ public static function provideSanitize()
'allowedHosts' => ['trusted.com', null],
'forceHttps' => true,
'allowRelative' => false,
'output' => 'data:text/plain;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7',
'expected' => 'data:text/plain;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7',
];

// Domain matching
Expand All @@ -244,7 +244,7 @@ public static function provideSanitize()
'allowedHosts' => ['trusted.com'],
'forceHttps' => false,
'allowRelative' => false,
'output' => 'https://subdomain.trusted.com/link.php',
'expected' => 'https://subdomain.trusted.com/link.php',
];

yield [
Expand All @@ -253,7 +253,7 @@ public static function provideSanitize()
'allowedHosts' => ['trusted.com'],
'forceHttps' => false,
'allowRelative' => false,
'output' => null,
'expected' => null,
];

yield [
Expand All @@ -262,7 +262,7 @@ public static function provideSanitize()
'allowedHosts' => ['trusted.com'],
'forceHttps' => false,
'allowRelative' => false,
'output' => 'https://deep.subdomain.trusted.com/link.php',
'expected' => 'https://deep.subdomain.trusted.com/link.php',
];

yield [
Expand All @@ -271,7 +271,7 @@ public static function provideSanitize()
'allowedHosts' => ['trusted.com'],
'forceHttps' => false,
'allowRelative' => false,
'output' => null,
'expected' => null,
];

// Allow relative
Expand All @@ -281,7 +281,7 @@ public static function provideSanitize()
'allowedHosts' => ['trusted.com'],
'forceHttps' => true,
'allowRelative' => true,
'output' => '/link.php',
'expected' => '/link.php',
];

yield [
Expand All @@ -290,7 +290,7 @@ public static function provideSanitize()
'allowedHosts' => ['trusted.com'],
'forceHttps' => true,
'allowRelative' => false,
'output' => null,
'expected' => null,
];
}

Expand Down

0 comments on commit b58efe8

Please sign in to comment.