Page Menu
Home
DevCentral
Search
Configure Global Search
Log In
Files
F3767360
D3219.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
50 KB
Referenced Files
None
Subscribers
None
D3219.diff
View Options
diff --git a/.gitignore b/.gitignore
--- a/.gitignore
+++ b/.gitignore
@@ -4,3 +4,4 @@
# Caches
.phpunit.result.cache
+.phpunit.cache/
diff --git a/_templates/phpunit.xml.in b/_templates/phpunit.xml.in
--- a/_templates/phpunit.xml.in
+++ b/_templates/phpunit.xml.in
@@ -19,11 +19,9 @@
-->
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.5/phpunit.xsd"
+ xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/10.3/phpunit.xsd"
bootstrap="vendor/autoload.php"
- convertErrorsToExceptions="true"
- convertNoticesToExceptions="true"
- convertWarningsToExceptions="true"
+ cacheDirectory=".phpunit.cache"
stopOnFailure="false">
<php>
<ini name="display_errors" value="On" />
@@ -38,12 +36,12 @@
</testsuite>
{%- endfor %}
</testsuites>
- <coverage processUncoveredFiles="true">
+ <source>
<include>
{%- for package in packages %}
<directory suffix=".php">{{ package }}/src/</directory>
{%- endfor %}
</include>
- </coverage>
+ </source>
</phpunit>
diff --git a/commands/composer.json b/commands/composer.json
--- a/commands/composer.json
+++ b/commands/composer.json
@@ -19,7 +19,7 @@
},
"require-dev": {
"phan/phan": "^5.3",
- "phpunit/phpunit": "^9.5.13",
+ "phpunit/phpunit": "^10.2",
"squizlabs/php_codesniffer": "^3"
}
}
diff --git a/commands/phpunit.xml b/commands/phpunit.xml
--- a/commands/phpunit.xml
+++ b/commands/phpunit.xml
@@ -1,18 +1,22 @@
<?xml version="1.0" encoding="UTF-8"?>
-<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" bootstrap="vendor/autoload.php" convertErrorsToExceptions="true" convertNoticesToExceptions="true" convertWarningsToExceptions="true" stopOnFailure="false" xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.3/phpunit.xsd">
- <coverage processUncoveredFiles="true">
- <include>
- <directory suffix=".php">src/</directory>
- </include>
- </coverage>
- <php>
- <ini name="display_errors" value="On"/>
- <ini name="display_startup_errors" value="On"/>
- <ini name="error_reporting" value="On"/>
- </php>
- <testsuites>
- <testsuite name="Unit tests">
- <directory suffix="Test.php">./tests</directory>
- </testsuite>
- </testsuites>
+<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/10.3/phpunit.xsd"
+ bootstrap="vendor/autoload.php"
+ cacheDirectory=".phpunit.cache"
+ stopOnFailure="false">
+ <php>
+ <ini name="display_errors" value="On" />
+ <ini name="display_startup_errors" value="On" />
+ <ini name="error_reporting" value="On" />
+ </php>
+ <testsuites>
+ <testsuite name="Unit tests">
+ <directory suffix="Test.php">./tests</directory>
+ </testsuite>
+ </testsuites>
+ <source>
+ <include>
+ <directory suffix=".php">src/</directory>
+ </include>
+ </source>
</phpunit>
diff --git a/composer.json b/composer.json
--- a/composer.json
+++ b/composer.json
@@ -26,7 +26,7 @@
"ext-xmlwriter": "*",
"nasqueron/codestyle": "^0.0.1",
"phan/phan": "^5.3.1",
- "phpunit/phpunit": "^9.5",
+ "phpunit/phpunit": "^10.2",
"symfony/yaml": "^6.0.3",
"squizlabs/php_codesniffer": "^3.6"
},
diff --git a/database/composer.json b/database/composer.json
--- a/database/composer.json
+++ b/database/composer.json
@@ -5,7 +5,7 @@
"require-dev": {
"phan/phan": "^5.3.2",
"squizlabs/php_codesniffer": "^3.6.2",
- "phpunit/phpunit": "^9.5",
+ "phpunit/phpunit": "^10.2",
"nasqueron/codestyle": "^0.0.1"
},
"scripts": {
diff --git a/database/phpunit.xml b/database/phpunit.xml
--- a/database/phpunit.xml
+++ b/database/phpunit.xml
@@ -1,10 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.5/phpunit.xsd"
+ xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/10.3/phpunit.xsd"
bootstrap="vendor/autoload.php"
- convertErrorsToExceptions="true"
- convertNoticesToExceptions="true"
- convertWarningsToExceptions="true"
+ cacheDirectory=".phpunit.cache"
stopOnFailure="false">
<php>
<ini name="display_errors" value="On" />
@@ -16,9 +14,9 @@
<directory suffix="Test.php">./tests</directory>
</testsuite>
</testsuites>
- <coverage processUncoveredFiles="true">
+ <source>
<include>
<directory suffix=".php">src/</directory>
</include>
- </coverage>
+ </source>
</phpunit>
diff --git a/database/tests/Engines/BlackholeEngineTest.php b/database/tests/Engines/BlackholeEngineTest.php
--- a/database/tests/Engines/BlackholeEngineTest.php
+++ b/database/tests/Engines/BlackholeEngineTest.php
@@ -5,6 +5,7 @@
use Keruald\Database\Database;
use Keruald\Database\Engines\BlackholeEngine;
+use PHPUnit\Framework\Attributes\DataProvider;
use PHPUnit\Framework\TestCase;
class BlackholeEngineTest extends TestCase {
@@ -31,15 +32,13 @@
$this->assertTrue($this->db->isExistingTable("quux", "quuxians"));
}
- public function provideStringsToEscape () : iterable {
+ public static function provideStringsToEscape () : iterable {
yield ["Lorem ipsum"];
yield [""];
yield ["\\\\ \n"];
}
- /**
- * @dataProvider provideStringsToEscape
- */
+ #[DataProvider('provideStringsToEscape')]
public function testEscape ($string) {
$this->assertEquals($string, $this->db->escape($string));
}
diff --git a/omnitools/composer.json b/omnitools/composer.json
--- a/omnitools/composer.json
+++ b/omnitools/composer.json
@@ -21,7 +21,7 @@
"require-dev": {
"nasqueron/codestyle": "^0.0.1",
"phan/phan": "^5.3.1",
- "phpunit/phpunit": "^9.5",
+ "phpunit/phpunit": "^10.2",
"squizlabs/php_codesniffer": "^3.6"
}
}
diff --git a/omnitools/phpunit.xml b/omnitools/phpunit.xml
--- a/omnitools/phpunit.xml
+++ b/omnitools/phpunit.xml
@@ -1,10 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.5/phpunit.xsd"
+ xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/10.3/phpunit.xsd"
bootstrap="vendor/autoload.php"
- convertErrorsToExceptions="true"
- convertNoticesToExceptions="true"
- convertWarningsToExceptions="true"
stopOnFailure="false">
<php>
<ini name="display_errors" value="On" />
@@ -16,9 +13,9 @@
<directory suffix="Test.php">./tests</directory>
</testsuite>
</testsuites>
- <coverage processUncoveredFiles="true">
+ <source>
<include>
<directory suffix=".php">src/</directory>
</include>
- </coverage>
+ </source>
</phpunit>
diff --git a/omnitools/tests/Collections/ArrayUtilitiesTest.php b/omnitools/tests/Collections/ArrayUtilitiesTest.php
--- a/omnitools/tests/Collections/ArrayUtilitiesTest.php
+++ b/omnitools/tests/Collections/ArrayUtilitiesTest.php
@@ -4,18 +4,17 @@
use Keruald\OmniTools\Collections\ArrayUtilities;
+use PHPUnit\Framework\Attributes\DataProvider;
use PHPUnit\Framework\TestCase;
class ArrayUtilitiesTest extends TestCase {
- /**
- * @dataProvider provideIntegersArray
- */
+ #[DataProvider('provideIntegersArray')]
public function testToIntegers ($expected, $toConvert) {
$this->assertEquals($expected, ArrayUtilities::toIntegers($toConvert));
}
- public function provideIntegersArray () : iterable {
+ public static function provideIntegersArray () : iterable {
yield [[1, 2, 3], ["1", "2", "3"]];
yield [[1, 2, 3], [1, 2, 3]];
diff --git a/omnitools/tests/Collections/BitsVectorTest.php b/omnitools/tests/Collections/BitsVectorTest.php
--- a/omnitools/tests/Collections/BitsVectorTest.php
+++ b/omnitools/tests/Collections/BitsVectorTest.php
@@ -6,6 +6,7 @@
use OutOfRangeException;
use Keruald\OmniTools\Collections\BitsVector;
+use PHPUnit\Framework\Attributes\DataProvider;
use PHPUnit\Framework\TestCase;
class BitsVectorTest extends TestCase {
@@ -85,7 +86,7 @@
);
}
- public function provideLengths () : iterable {
+ public static function provideLengths () : iterable {
yield [1];
yield [2];
yield [8];
@@ -95,9 +96,7 @@
yield [0];
}
- /**
- * @dataProvider provideLengths
- */
+ #[DataProvider('provideLengths')]
public function testRandom($length) : void {
$bits = BitsVector::random($length);
$this->assertEquals($length, $bits->count());
@@ -158,7 +157,7 @@
$this->assertEquals([1, 0, 0, 1], $bits->toArray());
}
- public function provideShapeArrays () : iterable {
+ public static function provideShapeArrays () : iterable {
yield [[1, 0, 0, 1, 0, 0, 0, 0], 4, [1, 0, 0, 1]];
yield [[1, 0, 0, 1], 4, [1, 0, 0, 1]];
yield [[1, 0, 0, 1], 3, [1, 0, 0]];
@@ -168,9 +167,7 @@
yield [[], 4, [0, 0, 0, 0]];
}
- /**
- * @dataProvider provideShapeArrays
- */
+ #[DataProvider('provideShapeArrays')]
public function testShapeCapacity (array $initial, int $length, array $final) : void {
$bits = new BitsVector($initial);
$bits->shapeCapacity($length);
diff --git a/omnitools/tests/Collections/HashMapTest.php b/omnitools/tests/Collections/HashMapTest.php
--- a/omnitools/tests/Collections/HashMapTest.php
+++ b/omnitools/tests/Collections/HashMapTest.php
@@ -5,6 +5,7 @@
use Keruald\OmniTools\Collections\BitsVector;
use Keruald\OmniTools\Collections\HashMap;
+use PHPUnit\Framework\Attributes\DataProvider;
use PHPUnit\Framework\TestCase;
use InvalidArgumentException;
@@ -59,7 +60,7 @@
$this->assertSame($expected, $map->toArray());
}
- private function provideDeepArrays() : iterable {
+ public static function provideDeepArrays() : iterable {
yield [self::MAP_CONTENT, self::MAP_CONTENT];
yield [[], []];
@@ -84,9 +85,7 @@
]];
}
- /**
- * @dataProvider provideDeepArrays
- */
+ #[DataProvider('provideDeepArrays')]
public function testFrom($from, array $expected) : void {
$map = HashMap::from($from);
$this->assertEquals($expected, $map->toArray());
diff --git a/omnitools/tests/Collections/TraversableUtilitiesTest.php b/omnitools/tests/Collections/TraversableUtilitiesTest.php
--- a/omnitools/tests/Collections/TraversableUtilitiesTest.php
+++ b/omnitools/tests/Collections/TraversableUtilitiesTest.php
@@ -5,6 +5,7 @@
use Keruald\OmniTools\Collections\TraversableUtilities;
+use PHPUnit\Framework\Attributes\DataProvider;
use PHPUnit\Framework\TestCase;
use Countable;
@@ -14,33 +15,25 @@
class TraversableUtilitiesTest extends TestCase {
- /**
- * @dataProvider provideCountables
- */
+ #[DataProvider('provideCountables')]
public function testCount ($expectedCount, $countable) {
$this->assertEquals(
$expectedCount, TraversableUtilities::count($countable)
);
}
- /**
- * @dataProvider provideNotCountables
- */
+ #[DataProvider('provideNotCountables')]
public function testCountWithNotCountables ($notCountable) {
$this->expectException("TypeError");
TraversableUtilities::count($notCountable);
}
- /**
- * @dataProvider providePureCountables
- */
+ #[DataProvider('providePureCountables')]
public function testIsCountable ($countable) {
$this->assertTrue(TraversableUtilities::isCountable($countable));
}
- /**
- * @dataProvider provideIterableAndFirst
- */
+ #[DataProvider('provideIterableAndFirst')]
public function testIsFirst($expected, $iterable) {
$this->assertEquals($expected, TraversableUtilities::first($iterable));
}
@@ -51,9 +44,7 @@
TraversableUtilities::first([]);
}
- /**
- * @dataProvider provideIterableAndFirst
- */
+ #[DataProvider('provideIterableAndFirst')]
public function testIsFirstOr($expected, $iterable) {
$actual = TraversableUtilities::firstOr($iterable, 666);
$this->assertEquals($expected, $actual);
@@ -68,7 +59,7 @@
/// Data providers
///
- public function provideCountables () : iterable {
+ public static function provideCountables () : iterable {
yield [0, null];
yield [0, false];
yield [0, []];
@@ -81,7 +72,7 @@
];
}
- public function providePureCountables () : iterable {
+ public static function providePureCountables () : iterable {
yield [[]];
yield [["a", "b", "c"]];
yield [new class implements Countable {
@@ -92,7 +83,7 @@
];
}
- public function provideNotCountables () : iterable {
+ public static function provideNotCountables () : iterable {
yield [true];
yield [new \stdClass];
yield [0];
@@ -100,7 +91,7 @@
yield ["abc"];
}
- public function provideIterableAndFirst() : iterable {
+ public static function provideIterableAndFirst() : iterable {
yield ["a", ["a", "b", "c"]];
yield ["apple", ["fruit" => "apple", "vegetable" => "leeks"]];
diff --git a/omnitools/tests/Collections/VectorTest.php b/omnitools/tests/Collections/VectorTest.php
--- a/omnitools/tests/Collections/VectorTest.php
+++ b/omnitools/tests/Collections/VectorTest.php
@@ -3,9 +3,12 @@
namespace Keruald\OmniTools\Tests\Collections;
+use Keruald\OmniTools\Collections\BaseVector;
use Keruald\OmniTools\Collections\HashMap;
use Keruald\OmniTools\Collections\Vector;
+use PHPUnit\Framework\Attributes\CoversClass;
+use PHPUnit\Framework\Attributes\DataProvider;
use PHPUnit\Framework\TestCase;
use InvalidArgumentException;
@@ -13,10 +16,8 @@
use OutOfRangeException;
use Traversable;
-/**
- * @covers \Keruald\OmniTools\Collections\Vector
- * @covers \Keruald\OmniTools\Collections\BaseVector
- */
+#[CoversClass(Vector::class)]
+#[CoversClass(BaseVector::class)]
class VectorTest extends TestCase {
private Vector $vector;
@@ -329,29 +330,25 @@
$this->assertEquals($expected, $this->vector->ngrams(1));
}
- private function provideLowN () : iterable {
+ public static function provideLowN () : iterable {
yield [0];
yield [-1];
yield [PHP_INT_MIN];
}
- /**
- * @dataProvider provideLowN
- */
+ #[DataProvider('provideLowN')]
public function testNgramsWithTooLowN ($n) : void {
$this->expectException(InvalidArgumentException::class);
$this->vector->ngrams($n);
}
- private function provideLargeN () : iterable {
+ public static function provideLargeN () : iterable {
yield [5];
yield [6];
yield [PHP_INT_MAX];
}
- /**
- * @dataProvider provideLargeN
- */
+ #[DataProvider('provideLargeN')]
public function testNgramsWithTooLargeN ($n) : void {
$expected = Vector::from([
[1, 2, 3, 4, 5],
diff --git a/omnitools/tests/Collections/WeightedValueTest.php b/omnitools/tests/Collections/WeightedValueTest.php
--- a/omnitools/tests/Collections/WeightedValueTest.php
+++ b/omnitools/tests/Collections/WeightedValueTest.php
@@ -4,6 +4,7 @@
namespace Keruald\OmniTools\Tests\Collections;
use Keruald\OmniTools\Collections\WeightedValue;
+use PHPUnit\Framework\Attributes\DataProvider;
use PHPUnit\Framework\TestCase;
class WeightedValueTest extends TestCase {
@@ -76,9 +77,7 @@
$this->highValue->compareTo(new \stdClass);
}
- /**
- * @dataProvider provideExpressionsToParse
- */
+ #[DataProvider('provideExpressionsToParse')]
public function testParse ($expression, $expectedValue, $expectedWeight) : void {
$value = WeightedValue::Parse($expression);
@@ -90,7 +89,7 @@
/// Data providers
///
- public function provideExpressionsToParse () : iterable {
+ public static function provideExpressionsToParse () : iterable {
yield ["", "", 1.0];
yield ["de", "de", 1.0];
yield ["de;q=1.0", "de", 1.0];
diff --git a/omnitools/tests/Culture/Rome/RomanNumeralsTest.php b/omnitools/tests/Culture/Rome/RomanNumeralsTest.php
--- a/omnitools/tests/Culture/Rome/RomanNumeralsTest.php
+++ b/omnitools/tests/Culture/Rome/RomanNumeralsTest.php
@@ -4,14 +4,13 @@
namespace Keruald\OmniTools\Tests\Culture\Rome;
use Keruald\OmniTools\Culture\Rome\RomanNumerals;
+use PHPUnit\Framework\Attributes\DataProvider;
use PHPUnit\Framework\TestCase;
use InvalidArgumentException;
class RomanNumeralsTest extends TestCase {
- /**
- * @dataProvider provideRomanAndHinduArabicNumerals
- */
+ #[DataProvider('provideRomanAndHinduArabicNumerals')]
public function testFromHindiArabicNumeral (
string $roman,
int $hinduArabic
@@ -22,7 +21,7 @@
);
}
- public function provideRomanAndHinduArabicNumerals () : iterable {
+ public static function provideRomanAndHinduArabicNumerals () : iterable {
yield ['i', 1];
yield ['xi', 11];
yield ['xlii', 42];
diff --git a/omnitools/tests/DateTime/DateStampTest.php b/omnitools/tests/DateTime/DateStampTest.php
--- a/omnitools/tests/DateTime/DateStampTest.php
+++ b/omnitools/tests/DateTime/DateStampTest.php
@@ -4,6 +4,7 @@
namespace Keruald\OmniTools\Tests\DateTime;
use Keruald\OmniTools\DateTime\DateStamp;
+use PHPUnit\Framework\Attributes\DataProvider;
use PHPUnit\Framework\TestCase;
use DateTime;
@@ -68,9 +69,7 @@
);
}
- /**
- * @dataProvider provideInvalidDateStamps
- */
+ #[DataProvider('provideInvalidDateStamps')]
public function testParseWithInvalidFormat ($dateStamp) : void {
$this->expectException("InvalidArgumentException");
DateStamp::parse($dateStamp);
@@ -80,7 +79,7 @@
/// Data provider
///
- public function provideInvalidDateStamps () : iterable {
+ public static function provideInvalidDateStamps () : iterable {
yield ["10-11-25"];
yield ["2010-41-25"];
yield ["2010-11-99"];
diff --git a/omnitools/tests/Debug/DebuggerTest.php b/omnitools/tests/Debug/DebuggerTest.php
--- a/omnitools/tests/Debug/DebuggerTest.php
+++ b/omnitools/tests/Debug/DebuggerTest.php
@@ -4,6 +4,7 @@
namespace Keruald\OmniTools\Tests\Debug;
use Keruald\OmniTools\Debug\Debugger;
+use PHPUnit\Framework\Attributes\DataProvider;
use PHPUnit\Framework\TestCase;
class DebuggerTest extends TestCase {
@@ -30,10 +31,7 @@
///
/// Integration tests
///
-
- /**
- * @dataProvider provideDebuggerScripts
- */
+ #[DataProvider('provideDebuggerScripts')]
public function testDebuggerScript ($script, $message) : void {
$this->assertProgramMatchesOutput($script, $message);
}
@@ -47,7 +45,7 @@
$this->assertSame($expected, $actual, $message);
}
- public function provideDebuggerScripts () : iterable {
+ public static function provideDebuggerScripts () : iterable {
yield ["dump_integer", "Can't dump a variable"];
yield ["dump_array", "Can't dump an array"];
yield ["dump_object", "Can't dump an object"];
diff --git a/omnitools/tests/HTTP/Requests/RemoteAddressTest.php b/omnitools/tests/HTTP/Requests/RemoteAddressTest.php
--- a/omnitools/tests/HTTP/Requests/RemoteAddressTest.php
+++ b/omnitools/tests/HTTP/Requests/RemoteAddressTest.php
@@ -4,6 +4,7 @@
namespace Keruald\OmniTools\Tests\HTTP\Requests;
use Keruald\OmniTools\HTTP\Requests\RemoteAddress;
+use PHPUnit\Framework\Attributes\DataProvider;
use PHPUnit\Framework\TestCase;
class RemoteAddressTest extends TestCase {
@@ -12,11 +13,6 @@
/// Tests
///
- /**
- * @covers \Keruald\OmniTools\HTTP\Requests\RemoteAddress::getClientAddress
- * @covers \Keruald\OmniTools\HTTP\Requests\RemoteAddress::getAll
- * @covers \Keruald\OmniTools\HTTP\Requests\RemoteAddress::has
- */
public function testEmptyRequest () : void {
$address = new RemoteAddress;
@@ -25,30 +21,21 @@
$this->assertFalse($address->has());
}
- /**
- * @covers \Keruald\OmniTools\HTTP\Requests\RemoteAddress::getClientAddress
- * @dataProvider provideTenZeroZeroThreeHeaderValues
- */
+ #[DataProvider("provideTenZeroZeroThreeHeaderValues")]
public function testGetOne (string $value) : void {
$address = new RemoteAddress($value);
$this->assertEquals('10.0.0.3', $address->getClientAddress());
}
- /**
- * @covers \Keruald\OmniTools\HTTP\Requests\RemoteAddress::getClientAddress
- * @dataProvider provideTenZeroZeroThreeHeaderValues
- */
+ #[DataProvider("provideTenZeroZeroThreeHeaderValues")]
public function testGetAll (string $value) : void {
$address = new RemoteAddress($value);
$this->assertEquals($value, $address->getAll());
}
- /**
- * @covers \Keruald\OmniTools\HTTP\Requests\RemoteAddress::has
- * @dataProvider provideTenZeroZeroThreeHeaderValues
- */
+ #[DataProvider("provideTenZeroZeroThreeHeaderValues")]
public function testHas (string $value) : void {
$address = new RemoteAddress($value);
@@ -59,7 +46,7 @@
/// Data provider
///
- public function provideTenZeroZeroThreeHeaderValues () : iterable {
+ public static function provideTenZeroZeroThreeHeaderValues () : iterable {
return [
// Each value should return 10.0.0.3
['10.0.0.3'],
diff --git a/omnitools/tests/HTTP/Requests/RequestTest.php b/omnitools/tests/HTTP/Requests/RequestTest.php
--- a/omnitools/tests/HTTP/Requests/RequestTest.php
+++ b/omnitools/tests/HTTP/Requests/RequestTest.php
@@ -4,6 +4,8 @@
namespace Keruald\OmniTools\Tests\HTTP\Requests;
use Keruald\OmniTools\HTTP\Requests\Request;
+use PHPUnit\Framework\Attributes\BackupGlobals;
+use PHPUnit\Framework\Attributes\DataProvider;
use PHPUnit\Framework\TestCase;
class RequestTest extends TestCase {
@@ -11,11 +13,7 @@
///
/// Tests
///
-
- /**
- * @covers \Keruald\OmniTools\HTTP\Requests\Request::getRemoteAddress
- * @backupGlobals enabled
- */
+ #[BackupGlobals(true)]
public function testGetRemoteAddress () : void {
$this->assertEmpty(Request::getRemoteAddress());
@@ -34,10 +32,7 @@
);
}
- /**
- * @covers \Keruald\OmniTools\HTTP\Requests\Request::getClientAddress
- * @backupGlobals enabled
- */
+ #[BackupGlobals(true)]
public function testGetRemoteAddressWithSeveralAddresses () : void {
$_SERVER = [
'HTTP_X_FORWARDED_FOR' => '10.0.0.2 10.0.0.3',
@@ -54,10 +49,7 @@
);
}
- /**
- * @covers \Keruald\OmniTools\HTTP\Requests\Request::getAcceptedLanguages
- * @backupGlobals enabled
- */
+ #[BackupGlobals(true)]
public function testGetAcceptedLanguages () : void {
$_SERVER = [
'HTTP_ACCEPT_LANGUAGE' => 'fr,en-US;q=0.7,en;q=0.3',
@@ -69,20 +61,16 @@
);
}
- /**
- * @backupGlobals enabled
- * @dataProvider provideServerURLs
- */
+ #[DataProvider('provideServerURLs')]
+ #[BackupGlobals(true)]
public function testGetServerURL (array $server, string $url) : void {
$_SERVER = $server;
$this->assertEquals($url, Request::getServerURL());
}
- /**
- * @backupGlobals enabled
- * @dataProvider provideServerURLs
- */
+ #[DataProvider('provideServerURLs')]
+ #[BackupGlobals(true)]
public function testCreateLocalURL (array $server, string $url) : void {
$_SERVER = $server;
@@ -101,7 +89,7 @@
/// Data providers
///
- public function provideServerURLs () : iterable {
+ public static function provideServerURLs () : iterable {
yield [[], "http://localhost"];
yield [["UNRELATED" => "ANYTHING"], "http://localhost"];
diff --git a/omnitools/tests/HTTP/URLTest.php b/omnitools/tests/HTTP/URLTest.php
--- a/omnitools/tests/HTTP/URLTest.php
+++ b/omnitools/tests/HTTP/URLTest.php
@@ -4,31 +4,26 @@
namespace Keruald\OmniTools\Tests\HTTP;
use Keruald\OmniTools\HTTP\URL;
+use PHPUnit\Framework\Attributes\DataProvider;
use PHPUnit\Framework\TestCase;
class URLTest extends TestCase {
- /**
- * @dataProvider provideURLsAndComponents
- */
+ #[DataProvider('provideURLsAndComponents')]
public function testGetDomain ($url, $expectedDomain) : void {
$url = new URL($url);
$this->assertEquals($expectedDomain, $url->getDomain());
}
- /**
- * @dataProvider provideURLsAndComponents
- */
+ #[DataProvider('provideURLsAndComponents')]
public function testGetProtocol ($url, $_, $expectedProtocol) : void {
$url = new URL($url);
$this->assertEquals($expectedProtocol, $url->getProtocol());
}
- /**
- * @dataProvider provideURLsAndComponents
- */
+ #[DataProvider('provideURLsAndComponents')]
public function testGetQuery ($url, $_, $__, $expectedQuery) : void {
$url = new URL($url);
@@ -63,9 +58,7 @@
$this->assertEquals("/xizzy", $url->getQuery());
}
- /**
- * @dataProvider provideURLsAndComponents
- */
+ #[DataProvider('provideURLsAndComponents')]
public function testCompose ($url, $domain, $protocol, $query,
$expectedUrl = null) {
$this->assertEquals(
@@ -74,7 +67,7 @@
);
}
- public function provideURLsAndComponents () : iterable {
+ public static function provideURLsAndComponents () : iterable {
// base URL, domain, protocol, query[, expected URL]
// When omitted, the expected URL is the base URL.
diff --git a/omnitools/tests/IO/FileTest.php b/omnitools/tests/IO/FileTest.php
--- a/omnitools/tests/IO/FileTest.php
+++ b/omnitools/tests/IO/FileTest.php
@@ -4,6 +4,7 @@
use Keruald\OmniTools\IO\File;
use Keruald\OmniTools\OS\CurrentOS;
+use PHPUnit\Framework\Attributes\DataProvider;
use PHPUnit\Framework\TestCase;
use TypeError;
@@ -13,10 +14,7 @@
///
/// Tests
///
-
- /**
- * @dataProvider provideFilesAndDirectories
- */
+ #[DataProvider('provideFilesAndDirectories')]
public function testGetDirectory (string $filename, string $expected) : void {
if (CurrentOS::isPureWindows()) {
$this->markTestSkipped("This test is intended for UNIX systems.");
@@ -25,23 +23,17 @@
$this->assertSame($expected, File::from($filename)->getDirectory());
}
- /**
- * @dataProvider provideFilesAndFileNames
- */
+ #[DataProvider('provideFilesAndFileNames')]
public function testGetFileName (string $filename, string $expected) : void {
$this->assertSame($expected, File::from($filename)->getFileName());
}
- /**
- * @dataProvider provideFilesAndFileNamesWithoutExtension
- */
+ #[DataProvider('provideFilesAndFileNamesWithoutExtension')]
public function testGetFileNameWithoutExtension (string $filename, string $expected) : void {
$this->assertSame($expected, File::from($filename)->getFileNameWithoutExtension());
}
- /**
- * @dataProvider provideFilesAndExtensions
- */
+ #[DataProvider('provideFilesAndExtensions')]
public function testGetExtension (string $filename, string $expected) : void {
$this->assertSame($expected, File::from($filename)->getExtension());
}
@@ -63,7 +55,7 @@
/// Data providers
///
- public function provideFilesAndDirectories () : iterable {
+ public static function provideFilesAndDirectories () : iterable {
yield ['', ''];
yield ['/', '/'];
yield ['/foo', '/'];
@@ -72,7 +64,7 @@
yield ['/full/path/to/foo.php', '/full/path/to'];
}
- public function provideFilesAndFileNames () : iterable {
+ public static function provideFilesAndFileNames () : iterable {
yield ['', ''];
yield ['foo', 'foo'];
yield ['foo', 'foo'];
@@ -80,7 +72,7 @@
yield ['/full/path/to/foo.php', 'foo.php'];
}
- public function provideFilesAndFileNamesWithoutExtension () : iterable {
+ public static function provideFilesAndFileNamesWithoutExtension () : iterable {
yield ['', ''];
yield ['foo', 'foo'];
yield ['foo.php', 'foo'];
@@ -89,7 +81,7 @@
}
- public function provideFilesAndExtensions () : iterable {
+ public static function provideFilesAndExtensions () : iterable {
yield ['', ''];
yield ['foo', ''];
yield ['foo.php', 'php'];
diff --git a/omnitools/tests/Identifiers/RandomTest.php b/omnitools/tests/Identifiers/RandomTest.php
--- a/omnitools/tests/Identifiers/RandomTest.php
+++ b/omnitools/tests/Identifiers/RandomTest.php
@@ -4,7 +4,8 @@
namespace Keruald\OmniTools\Tests\Identifiers;
use Keruald\OmniTools\Identifiers\Random;
-use Phpunit\Framework\TestCase;
+use PHPUnit\Framework\Attributes\DataProvider;
+use PHPUnit\Framework\TestCase;
class RandomTest extends TestCase {
@@ -30,9 +31,7 @@
);
}
- /**
- * @dataProvider provideRandomStringFormats
- */
+ #[DataProvider('provideRandomStringFormats')]
public function testRandomString($format, $re, $len) : void {
$string = Random::generateString($format);
@@ -51,7 +50,7 @@
/// Data providers
///
- public function provideRandomStringFormats() : iterable {
+ public static function provideRandomStringFormats() : iterable {
yield ["AAA111", "/^[A-Z]{3}[0-9]{3}$/", 6];
yield ["AAA123", "/^[A-Z]{3}[0-9]{3}$/", 6];
yield ["ABC123", "/^[A-Z]{3}[0-9]{3}$/", 6];
diff --git a/omnitools/tests/Identifiers/UUIDTest.php b/omnitools/tests/Identifiers/UUIDTest.php
--- a/omnitools/tests/Identifiers/UUIDTest.php
+++ b/omnitools/tests/Identifiers/UUIDTest.php
@@ -9,7 +9,8 @@
use Keruald\OmniTools\Collections\Vector;
use Keruald\OmniTools\DateTime\UUIDv1TimeStamp;
use Keruald\OmniTools\Identifiers\UUID;
-use Phpunit\Framework\TestCase;
+use PHPUnit\Framework\Attributes\DataProvider;
+use PHPUnit\Framework\TestCase;
class UUIDTest extends TestCase {
@@ -110,15 +111,13 @@
);
}
- public function provideUUIDV8OverflowValues () : iterable {
+ public static function provideUUIDV8OverflowValues () : iterable {
yield [PHP_INT_MAX, 0x75B, 0xEC932D5F69181C0];
yield [0x320C3D4DCC00, PHP_INT_MAX, 0xEC932D5F69181C0];
yield [0x320C3D4DCC00, 0x75B, PHP_INT_MAX];
}
- /**
- * @dataProvider provideUUIDV8OverflowValues
- */
+ #[DataProvider('provideUUIDV8OverflowValues')]
public function testUUIDV8WithOverflowValues ($a, $b, $c) : void {
$this->expectException(InvalidArgumentException::class);
UUID::UUIDv8($a, $b, $c);
@@ -172,7 +171,7 @@
/// Tests for helper methods
///
- public function provideFormattedUUID () : iterable {
+ public static function provideFormattedUUID () : iterable {
yield [
"320c3d4dcc00875b8ec932d5f69181c0",
"320c3d4d-cc00-875b-8ec9-32d5f69181c0",
@@ -189,9 +188,7 @@
];
}
- /**
- * @dataProvider provideFormattedUUID
- */
+ #[DataProvider('provideFormattedUUID')]
public function testReformat($uuidToReformat, $expected) {
$this->assertEquals($expected, UUID::reformat($uuidToReformat));
}
@@ -205,7 +202,7 @@
$this->assertFalse(UUID::isUUID("d825a90a27e7f161a07161c3a37dce8e"));
}
- private function provideUUIDsWithVersionAndVariant () : iterable {
+ public static function provideUUIDsWithVersionAndVariant () : iterable {
// RFC 4122
yield ["c232ab00-9414-11ec-b3c8-9e6bdeced846", 1, 2];
yield ["f6244210-bbc3-3689-bb54-76528802d4d5", 3, 2];
@@ -222,16 +219,12 @@
yield [UUID::MAX, 15, 3];
}
- /**
- * @dataProvider provideUUIDsWithVersionAndVariant
- */
+ #[DataProvider('provideUUIDsWithVersionAndVariant')]
public function testGetVersion (string $uuid, int $version, int $variant) : void {
$this->assertEquals($version, UUID::getVersion($uuid));
}
- /**
- * @dataProvider provideUUIDsWithVersionAndVariant
- */
+ #[DataProvider('provideUUIDsWithVersionAndVariant')]
public function testGetVariant (string $uuid, int $version, int $variant) : void {
$this->assertEquals($variant, UUID::getVariant($uuid));
}
diff --git a/omnitools/tests/Network/IPTest.php b/omnitools/tests/Network/IPTest.php
--- a/omnitools/tests/Network/IPTest.php
+++ b/omnitools/tests/Network/IPTest.php
@@ -4,6 +4,7 @@
namespace Keruald\OmniTools\Tests\Network;
use Keruald\OmniTools\Network\IP;
+use PHPUnit\Framework\Attributes\DataProvider;
use PHPUnit\Framework\TestCase;
class IPTest extends TestCase {
@@ -18,24 +19,24 @@
/// Source: https://web.archive.org/web/20110515134717/http://forums.dartware.com/viewtopic.php?t=452
///
- public function provideValidIP () : iterable {
+ public static function provideValidIP () : iterable {
yield ["0.0.0.0"];
yield ["17.17.17.17"];
yield ["fe80:0000:0000:0000:0204:61ff:fe9d:f156"];
}
- public function provideInvalidIP () : iterable {
+ public static function provideInvalidIP () : iterable {
yield [""];
yield ["1"];
yield ["17.17"];
yield ["17.17.17.256"];
}
- public function provideValidIPv4 () : iterable {
+ public static function provideValidIPv4 () : iterable {
return [["0.0.0.0"], ["17.17.17.17"]];
}
- public function provideInvalidIPv4 () : iterable {
+ public static function provideInvalidIPv4 () : iterable {
yield [""];
yield ["1"];
yield ["17.17"];
@@ -43,7 +44,7 @@
yield ["fe80:0000:0000:0000:0204:61ff:fe9d:f156"];
}
- public function provideValidIPv6 () : iterable {
+ public static function provideValidIPv6 () : iterable {
yield ["::1"];
yield ["::ffff:192.0.2.128"];
yield ["fe80:0000:0000:0000:0204:61ff:fe9d:f156"];
@@ -51,7 +52,7 @@
yield ["::ffff:192.0.2.128", "IPv4 represented as dotted-quads"];
}
- public function provideInvalidIPv6 () : iterable {
+ public static function provideInvalidIPv6 () : iterable {
yield ["0.0.0.0"];
yield [""];
yield ["1"];
@@ -64,13 +65,13 @@
yield ["1.2.3.4:1111:2222:3333:4444::5555"];
}
- public function provideValidLoopbackIP () : iterable {
+ public static function provideValidLoopbackIP () : iterable {
yield ["127.0.0.1"];
yield ["127.0.0.3"];
yield ["::1"];
}
- public function provideInvalidLoopbackIP () : iterable {
+ public static function provideInvalidLoopbackIP () : iterable {
yield ["0.0.0.0"];
yield ["1.2.3.4"];
yield ["192.168.1.1"];
@@ -81,66 +82,42 @@
/// Test cases
///
- /**
- * @covers \Keruald\OmniTools\Network\IP::isIP
- * @dataProvider provideValidIP
- */
+ #[DataProvider("provideValidIP")]
public function testIsIP ($ip) {
$this->assertTrue(IP::isIP($ip));
}
- /**
- * @covers \Keruald\OmniTools\Network\IP::isIP
- * @dataProvider provideInvalidIP
- */
+ #[DataProvider("provideInvalidIP")]
public function testIsIPWhenItIsNot ($ip) {
$this->assertFalse(IP::isIP($ip));
}
- /**
- * @covers \Keruald\OmniTools\Network\IP::isIPv4
- * @dataProvider provideValidIPv4
- */
+ #[DataProvider("provideValidIPv4")]
public function testIsIPv4 ($ip) {
$this->assertTrue(IP::isIPv4($ip));
}
- /**
- * @covers \Keruald\OmniTools\Network\IP::isIPv4
- * @dataProvider provideInvalidIPv4
- */
+ #[DataProvider("provideInvalidIPv4")]
public function testIsIPv4WhenItIsNot ($ip) {
$this->assertFalse(IP::isIPv4($ip));
}
- /**
- * @covers \Keruald\OmniTools\Network\IP::isIPv6
- * @dataProvider provideValidIPv6
- */
+ #[DataProvider("provideValidIPv6")]
public function testIsIPv6 (string $ip, string $message = "") {
$this->assertTrue(IP::isIPv6($ip), $message);
}
- /**
- * @covers \Keruald\OmniTools\Network\IP::isIPv6
- * @dataProvider provideInvalidIPv6
- */
+ #[DataProvider("provideInvalidIPv6")]
public function testIsIPv6WhenItIsNot (string $ip, string $message = "") : void {
$this->assertFalse(IP::isIPv6($ip), $message);
}
- /**
- * @covers \Keruald\OmniTools\Network\IP::isLoopback
- * @dataProvider provideValidLoopbackIP
- */
+ #[DataProvider("provideValidLoopbackIP")]
public function testIsLoopback (string $ip) : void {
$this->assertTrue(IP::isLoopback($ip));
}
- /**
- * @covers \Keruald\OmniTools\Network\IP::isLoopback
- * @dataProvider provideInvalidLoopbackIP
- */
+ #[DataProvider("provideInvalidLoopbackIP")]
public function testIsLoopbackWhenItIsNot (string $ip) : void {
$this->assertFalse(IP::isLoopback($ip));
}
diff --git a/omnitools/tests/OS/EnvironmentTest.php b/omnitools/tests/OS/EnvironmentTest.php
--- a/omnitools/tests/OS/EnvironmentTest.php
+++ b/omnitools/tests/OS/EnvironmentTest.php
@@ -4,6 +4,7 @@
use InvalidArgumentException;
use Keruald\OmniTools\OS\Environment;
+use PHPUnit\Framework\Attributes\DataProvider;
use PHPUnit\Framework\TestCase;
class EnvironmentTest extends TestCase {
@@ -20,35 +21,29 @@
// And quux isn't defined.
}
- public function provideEnvironment () : iterable {
+ public static function provideEnvironment () : iterable {
yield ["foo", "bar"];
yield ["bar", "lorem"];
yield ["baz", "ipsum"];
}
- public function provideEnvironmentKeys () : iterable {
- foreach ($this->provideEnvironment() as $kv) {
+ public static function provideEnvironmentKeys () : iterable {
+ foreach (self::provideEnvironment() as $kv) {
yield [$kv[0]];
}
}
- /**
- * @dataProvider provideEnvironmentKeys
- */
+ #[DataProvider('provideEnvironmentKeys')]
public function testHas (string $key) : void {
self::assertTrue(Environment::has($key));
}
- /**
- * @dataProvider provideEnvironment
- */
+ #[DataProvider('provideEnvironment')]
public function testGet (string $key, string $value) : void {
self::assertSame($value, Environment::get($key));
}
- /**
- * @dataProvider provideEnvironment
- */
+ #[DataProvider('provideEnvironment')]
public function testGetOrWhenKeyExists (string $key, string $value) : void {
self::assertSame($value, Environment::getOr($key, "default"));
}
diff --git a/omnitools/tests/Reflection/CodeFunctionTest.php b/omnitools/tests/Reflection/CodeFunctionTest.php
--- a/omnitools/tests/Reflection/CodeFunctionTest.php
+++ b/omnitools/tests/Reflection/CodeFunctionTest.php
@@ -3,6 +3,7 @@
namespace Keruald\OmniTools\Tests\Reflection;
use Keruald\OmniTools\Reflection\CodeFunction;
+use PHPUnit\Framework\Attributes\DataProvider;
use PHPUnit\Framework\TestCase;
use InvalidArgumentException;
@@ -11,9 +12,7 @@
class CodeFunctionTest extends TestCase {
- /**
- * @dataProvider provideFunctionParameters
- */
+ #[DataProvider('provideFunctionParameters')]
public function testGetParameterType (ReflectionParameter $parameter, string $type) {
$this->assertEquals($type, CodeFunction::getParameterType($parameter));
}
@@ -31,7 +30,7 @@
/// Data provider
///
- public function provideFunctionParameters () : iterable {
+ public static function provideFunctionParameters () : iterable {
// array_change_key_case(array $array, int $case = CASE_LOWER): array
$function = new ReflectionFunction("array_change_key_case");
$parameters = $function->getParameters();
diff --git a/omnitools/tests/Reflection/CodeVariableTest.php b/omnitools/tests/Reflection/CodeVariableTest.php
--- a/omnitools/tests/Reflection/CodeVariableTest.php
+++ b/omnitools/tests/Reflection/CodeVariableTest.php
@@ -4,6 +4,7 @@
use Keruald\OmniTools\Collections\Vector;
use Keruald\OmniTools\Reflection\CodeVariable;
+use PHPUnit\Framework\Attributes\DataProvider;
use PHPUnit\Framework\TestCase;
class CodeVariableTest extends TestCase {
@@ -15,18 +16,14 @@
$this->assertTrue($variable->hasType(Vector::class));
}
- /**
- * @dataProvider provideScalarsAndTypes
- */
+ #[DataProvider('provideScalarsAndTypes')]
public function testHasTypeWithScalar (mixed $scalar, string $type) {
$variable = CodeVariable::from($scalar);
$this->assertTrue($variable->hasType($type));
}
- /**
- * @dataProvider provideScalars
- */
+ #[DataProvider('provideScalars')]
public function testFromWithScalar (mixed $scalar) {
$variable = CodeVariable::from($scalar);
@@ -44,7 +41,7 @@
/// Data providers
///
- private function provideScalars () : iterable {
+ public static function provideScalars () : iterable {
yield [0];
yield [""];
yield [19];
@@ -54,7 +51,7 @@
yield [null];
}
- private function provideScalarsAndTypes () : iterable {
+ public static function provideScalarsAndTypes () : iterable {
yield [0, "integer"];
yield ["", "string"];
yield [19, "integer"];
diff --git a/omnitools/tests/Registration/PSR4/PSR4NamespaceTest.php b/omnitools/tests/Registration/PSR4/PSR4NamespaceTest.php
--- a/omnitools/tests/Registration/PSR4/PSR4NamespaceTest.php
+++ b/omnitools/tests/Registration/PSR4/PSR4NamespaceTest.php
@@ -6,6 +6,7 @@
use Keruald\OmniTools\Registration\PSR4\PSR4Namespace;
use Keruald\OmniTools\Tests\WithData;
+use PHPUnit\Framework\Attributes\DataProvider;
use PHPUnit\Framework\TestCase;
class PSR4NamespaceTest extends TestCase {
@@ -23,9 +24,7 @@
"Acme\\SolarSystemLib\\Planets\\Inner\\Venus",
];
- /**
- * @dataProvider provideClasses
- */
+ #[DataProvider('provideClasses')]
public function testDiscover (
string $path, string $prefix, array $expected
) : void {
@@ -55,7 +54,7 @@
/// Data providers
///
- public function provideClasses () : iterable {
+ public static function provideClasses () : iterable {
// [string $path, string $prefix, string[] $expectedClasses]
yield ["MockLib", "Acme\\MockLib", [
"Acme\\MockLib\\Bar",
diff --git a/omnitools/tests/Registration/PSR4AutoloaderTest.php b/omnitools/tests/Registration/PSR4AutoloaderTest.php
--- a/omnitools/tests/Registration/PSR4AutoloaderTest.php
+++ b/omnitools/tests/Registration/PSR4AutoloaderTest.php
@@ -4,6 +4,7 @@
namespace Keruald\OmniTools\Tests\Registration;
use Keruald\OmniTools\Registration\PSR4\Solver;
+use PHPUnit\Framework\Attributes\DataProvider;
use PHPUnit\Framework\TestCase;
class PSR4AutoloaderTest extends TestCase {
@@ -11,10 +12,7 @@
///
/// Tests
///
-
- /**
- * @dataProvider providePaths
- */
+ #[DataProvider('providePaths')]
public function testGetPathFor (string $class, string $expected) : void {
$this->assertEquals($expected, Solver::getPathFor($class));
}
@@ -23,7 +21,7 @@
/// Data provider
///
- public function providePaths () : iterable {
+ public static function providePaths () : iterable {
// Example from PSR-4 canonical document
yield ['File_Writer', 'File_Writer.php'];
yield ['Response\Status', 'Response/Status.php'];
diff --git a/omnitools/tests/Strings/Multibyte/OmniStringTest.php b/omnitools/tests/Strings/Multibyte/OmniStringTest.php
--- a/omnitools/tests/Strings/Multibyte/OmniStringTest.php
+++ b/omnitools/tests/Strings/Multibyte/OmniStringTest.php
@@ -4,6 +4,7 @@
namespace Keruald\OmniTools\Tests\Strings\Multibyte;
use Keruald\OmniTools\Strings\Multibyte\OmniString;
+use PHPUnit\Framework\Attributes\DataProvider;
use PHPUnit\Framework\TestCase;
class OmniStringTest extends TestCase {
@@ -49,27 +50,21 @@
$this->assertEquals(3, $this->string->len());
}
- /**
- * @dataProvider provideCharactersArrays
- */
+ #[DataProvider('provideCharactersArrays')]
public function testGetChars (string $string, array $expectedCharacters) : void {
$actualCharacters = (new OmniString($string))->getChars();
$this->assertEquals($expectedCharacters, $actualCharacters);
}
- /**
- * @dataProvider provideCharactersBigrams
- */
+ #[DataProvider('provideCharactersBigrams')]
public function testBigrams (string $string, array $expectedBigrams) : void {
$actualBigrams = (new OmniString($string))->getBigrams();
$this->assertEquals($expectedBigrams, $actualBigrams);
}
- /**
- * @dataProvider provideExplosions
- */
+ #[DataProvider('provideExplosions')]
public function testExplode (string $delimiter, string $imploded, array $exploded) : void {
$actual = (new OmniString($imploded))
->explode($delimiter)
@@ -89,7 +84,7 @@
/// Data providers
///
- public function provideCharactersArrays () : iterable {
+ public static function provideCharactersArrays () : iterable {
yield ["foo", ['f', 'o', 'o']];
yield [
@@ -102,7 +97,7 @@
yield ["", []];
}
- public function provideCharactersBigrams () : iterable {
+ public static function provideCharactersBigrams () : iterable {
yield ["foo", ['fo', 'oo']];
yield ["night", ['ni', 'ig', 'gh', 'ht']];
@@ -111,7 +106,7 @@
yield ["", []];
}
- public function provideExplosions () : iterable {
+ public static function provideExplosions () : iterable {
yield ["/", "a/b/c", ['a', 'b', 'c']];
yield ["/", "abc", ['abc']];
yield ["/", "/b/c", ['', 'b', 'c']];
diff --git a/omnitools/tests/Strings/Multibyte/StringUtilitiesTest.php b/omnitools/tests/Strings/Multibyte/StringUtilitiesTest.php
--- a/omnitools/tests/Strings/Multibyte/StringUtilitiesTest.php
+++ b/omnitools/tests/Strings/Multibyte/StringUtilitiesTest.php
@@ -4,6 +4,7 @@
namespace Keruald\OmniTools\Tests\Strings\Multibyte;
use Keruald\OmniTools\Strings\Multibyte\StringUtilities;
+use PHPUnit\Framework\Attributes\DataProvider;
use PHPUnit\Framework\TestCase;
class StringUtilitiesTest extends TestCase {
@@ -11,10 +12,7 @@
///
/// Tests
///
-
- /**
- * @dataProvider providePadding
- */
+ #[DataProvider('providePadding')]
public function testPad (
string $expected,
string $input, int $padLength, string $padString, int $padType
@@ -54,17 +52,13 @@
$this->assertFalse(StringUtilities::endsWith("foo", "bar"));
}
- /**
- * @dataProvider provideBase64
- */
+ #[DataProvider('provideBase64')]
public function testEncodeInBase64 (string $decoded, string $encoded) : void {
$actual = StringUtilities::encodeInBase64($decoded);
$this->assertEquals($encoded, $actual);
}
- /**
- * @dataProvider provideBase64
- */
+ #[DataProvider('provideBase64')]
public function testDecodeFromBase64 (string $decoded, string $encoded) : void {
$actual = StringUtilities::decodeFromBase64($encoded);
$this->assertEquals($decoded, $actual);
@@ -74,7 +68,7 @@
/// Data providers
///
- public function providePadding () : iterable {
+ public static function providePadding () : iterable {
// Tests from http://3v4l.org/UnXTF
// http://web.archive.org/web/20150711100913/http://3v4l.org/UnXTF
@@ -106,7 +100,7 @@
yield ['FOOBAR', "FOOBAR", -10, "àèò", STR_PAD_RIGHT];
}
- public function provideBase64 () : iterable {
+ public static function provideBase64 () : iterable {
yield ['foo', 'Zm9v', "This is the regular base test without any exception."];
yield ['', '', "An empty string should remain an empty string."];
yield [
diff --git a/phpunit.xml b/phpunit.xml
--- a/phpunit.xml
+++ b/phpunit.xml
@@ -19,11 +19,9 @@
-->
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.5/phpunit.xsd"
+ xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/10.3/phpunit.xsd"
bootstrap="vendor/autoload.php"
- convertErrorsToExceptions="true"
- convertNoticesToExceptions="true"
- convertWarningsToExceptions="true"
+ cacheDirectory=".phpunit.cache"
stopOnFailure="false">
<php>
<ini name="display_errors" value="On" />
@@ -44,12 +42,13 @@
<directory suffix="Test.php">./report/tests</directory>
</testsuite>
</testsuites>
- <coverage processUncoveredFiles="true">
+ <source>
<include>
+ <directory suffix=".php">cache/src/</directory>
<directory suffix=".php">commands/src/</directory>
<directory suffix=".php">database/src/</directory>
<directory suffix=".php">omnitools/src/</directory>
<directory suffix=".php">report/src/</directory>
</include>
- </coverage>
+ </source>
</phpunit>
diff --git a/report/composer.json b/report/composer.json
--- a/report/composer.json
+++ b/report/composer.json
@@ -5,7 +5,7 @@
"require-dev": {
"nasqueron/codestyle": "^0.0.1",
"phan/phan": "^5.3",
- "phpunit/phpunit": "^9.5",
+ "phpunit/phpunit": "^10.2",
"squizlabs/php_codesniffer": "^3.6"
},
"license": "BSD-2-Clause",
diff --git a/report/phpunit.xml b/report/phpunit.xml
--- a/report/phpunit.xml
+++ b/report/phpunit.xml
@@ -1,10 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.5/phpunit.xsd"
+ xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/10.3/phpunit.xsd"
bootstrap="vendor/autoload.php"
- convertErrorsToExceptions="true"
- convertNoticesToExceptions="true"
- convertWarningsToExceptions="true"
stopOnFailure="false">
<php>
<ini name="display_errors" value="On" />
@@ -16,9 +13,9 @@
<directory suffix="Test.php">./tests</directory>
</testsuite>
</testsuites>
- <coverage processUncoveredFiles="true">
+ <source>
<include>
<directory suffix=".php">src/</directory>
</include>
- </coverage>
+ </source>
</phpunit>
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Sat, Nov 23, 23:45 (19 h, 52 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2259201
Default Alt Text
D3219.diff (50 KB)
Attached To
Mode
D3219: Upgrade to PHPUnit 10
Attached
Detach File
Event Timeline
Log In to Comment