Skip to content

Commit

Permalink
Tests: fix PHPUnit deprecation notices [3]
Browse files Browse the repository at this point in the history
Make sure data providers only pass the arguments supported by the test.

This fixes a number of PHPUnit (10.5+) deprecation notices along the lines of "Providing invalid named argument $* for method WpOrg\Requests\Tests\*\*Test::test*() is deprecated and will not be supported in PHPUnit 11.0.".
  • Loading branch information
jrfnl committed Jun 3, 2024
1 parent 39f5506 commit eb2a058
Showing 1 changed file with 18 additions and 3 deletions.
21 changes: 18 additions & 3 deletions tests/Cookie/Jar/NormalizeCookieTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ final class NormalizeCookieTest extends TestCase {
/**
* Verify that cookie normalization works on both prebaked and unbaked cookies when not passing a key.
*
* @dataProvider dataNormalization
* @dataProvider dataNormalizationWithoutKey
*
* @param mixed $cookie Cookie header value, possibly pre-parsed (object).
*
Expand All @@ -30,10 +30,25 @@ public function testNormalizationWithoutKey($cookie) {
$this->assertSame(self::COOKIE_VALUE, (string) $result, 'Cookie value is not the expected value');
}

/**
* Data provider.
*
* @return array
*/
public static function dataNormalizationWithoutKey() {
$data = self::dataNormalizationWithKey();

Check failure on line 40 in tests/Cookie/Jar/NormalizeCookieTest.php

View workflow job for this annotation

GitHub Actions / PHPCS

Whitespace found at end of line

Check failure on line 40 in tests/Cookie/Jar/NormalizeCookieTest.php

View workflow job for this annotation

GitHub Actions / PHPCS

Whitespace found at end of line
foreach ($data as $setName => $setValue) {

Check failure on line 41 in tests/Cookie/Jar/NormalizeCookieTest.php

View workflow job for this annotation

GitHub Actions / PHPCS

Variable "$setName" is not in valid snake_case format, try "$set_name"

Check failure on line 41 in tests/Cookie/Jar/NormalizeCookieTest.php

View workflow job for this annotation

GitHub Actions / PHPCS

Variable "$setValue" is not in valid snake_case format, try "$set_value"

Check failure on line 41 in tests/Cookie/Jar/NormalizeCookieTest.php

View workflow job for this annotation

GitHub Actions / PHPCS

Variable "$setName" is not in valid snake_case format, try "$set_name"

Check failure on line 41 in tests/Cookie/Jar/NormalizeCookieTest.php

View workflow job for this annotation

GitHub Actions / PHPCS

Variable "$setValue" is not in valid snake_case format, try "$set_value"
unset($data[$setName]['expected_name']);

Check failure on line 42 in tests/Cookie/Jar/NormalizeCookieTest.php

View workflow job for this annotation

GitHub Actions / PHPCS

Variable "$setName" is not in valid snake_case format, try "$set_name"

Check failure on line 42 in tests/Cookie/Jar/NormalizeCookieTest.php

View workflow job for this annotation

GitHub Actions / PHPCS

Variable "$setName" is not in valid snake_case format, try "$set_name"
}

Check failure on line 44 in tests/Cookie/Jar/NormalizeCookieTest.php

View workflow job for this annotation

GitHub Actions / PHPCS

Whitespace found at end of line

Check failure on line 44 in tests/Cookie/Jar/NormalizeCookieTest.php

View workflow job for this annotation

GitHub Actions / PHPCS

Whitespace found at end of line
return $data;
}

/**
* Verify that cookie normalization works on both prebaked and unbaked cookies when passing a key.
*
* @dataProvider dataNormalization
* @dataProvider dataNormalizationWithKey
*
* @param mixed $cookie Cookie header value, possibly pre-parsed (object).
*
Expand All @@ -55,7 +70,7 @@ public function testNormalizationWithKey($cookie, $expected_name) {
*
* @return array
*/
public static function dataNormalization() {
public static function dataNormalizationWithKey() {
return [
'unbaked cookie (string)' => [
'cookie' => self::COOKIE_VALUE,
Expand Down

0 comments on commit eb2a058

Please sign in to comment.