Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: update tests for phpunit 10 and 11 #208

Merged
merged 1 commit into from
Dec 7, 2024
Merged
Changes from all commits
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
16 changes: 11 additions & 5 deletions tests/SecurityTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

namespace tests;

use PHPUnit\Framework\Attributes\DataProvider;
use PHPUnit\Framework\TestCase;
use Rancoud\Security\Security;
use Rancoud\Security\SecurityException;
Expand All @@ -13,7 +14,7 @@
*/
class SecurityTest extends TestCase
{
public function dataHTML(): array
public static function dataHTML(): array
{
return [
'backtick' => ['`', '`'],
Expand Down Expand Up @@ -56,7 +57,7 @@ public function dataHTML(): array
];
}

public function dataAttr(): array
public static function dataAttr(): array
{
return [
'backtick' => ['`', '`'],
Expand Down Expand Up @@ -100,7 +101,7 @@ public function dataAttr(): array
];
}

public function dataJS(): array
public static function dataJS(): array
{
return [
'backtick' => ['`', '\\x60'],
Expand Down Expand Up @@ -143,7 +144,7 @@ public function dataJS(): array
];
}

public function dataURL(): array
public static function dataURL(): array
{
return [
'<' => ['<', '%3C'],
Expand Down Expand Up @@ -175,7 +176,7 @@ public function dataURL(): array
];
}

public function dataCSS(): array
public static function dataCSS(): array
{
return [
'<' => ['<', '\\3C '],
Expand Down Expand Up @@ -210,6 +211,7 @@ public function dataCSS(): array
*
* @throws SecurityException
*/
#[DataProvider('dataHTML')]
public function testEscHTML(string $input, string $expected): void
{
self::assertSame($expected, Security::escHTML($input));
Expand All @@ -223,6 +225,7 @@ public function testEscHTML(string $input, string $expected): void
*
* @throws SecurityException
*/
#[DataProvider('dataAttr')]
public function testEscAttr(string $input, string $expected): void
{
self::assertSame($expected, Security::escAttr($input));
Expand All @@ -236,6 +239,7 @@ public function testEscAttr(string $input, string $expected): void
*
* @throws SecurityException
*/
#[DataProvider('dataJS')]
public function testEscJS(string $input, string $expected): void
{
self::assertSame($expected, Security::escJS($input));
Expand All @@ -249,6 +253,7 @@ public function testEscJS(string $input, string $expected): void
*
* @throws SecurityException
*/
#[DataProvider('dataURL')]
public function testEscURL(string $input, string $expected): void
{
self::assertSame($expected, Security::escURL($input));
Expand All @@ -262,6 +267,7 @@ public function testEscURL(string $input, string $expected): void
*
* @throws SecurityException
*/
#[DataProvider('dataCSS')]
public function testEscCSS(string $input, string $expected): void
{
self::assertSame($expected, Security::escCSS($input));
Expand Down
Loading