diff --git a/tests/Unit/Option/BooleanTest.php b/tests/Unit/Option/BooleanTest.php index 4c460eb..45d7331 100644 --- a/tests/Unit/Option/BooleanTest.php +++ b/tests/Unit/Option/BooleanTest.php @@ -4,6 +4,7 @@ use PHPUnit\Framework\Assert; use PHPUnit\Framework\TestCase; +use PHPUnit\Framework\Attributes\DataProvider; use TH\Maybe\Option; use TH\Maybe\Tests\Provider; @@ -12,24 +13,24 @@ final class BooleanTest extends TestCase use Provider\Options; /** - * @dataProvider andMatrix * @template T * @param Option $left * @param Option $right * @param Option $expected */ + #[DataProvider('andMatrix')] public function testAnd(Option $left, Option $right, Option $expected): void { Assert::assertSame($expected, $left->and($right)); } /** - * @dataProvider andMatrix * @template T * @param Option $left * @param Option $right * @param Option $expected */ + #[DataProvider('andMatrix')] public function testAndThen(Option $left, Option $right, Option $expected): void { $calls = []; @@ -47,12 +48,12 @@ public function testAndThen(Option $left, Option $right, Option $expected): void } /** - * @dataProvider orMatrix * @template T * @param Option $left * @param Option $right * @param Option $expected */ + #[DataProvider('orMatrix')] public function testOrElse(Option $left, Option $right, Option $expected): void { $calls = 0; @@ -70,24 +71,24 @@ public function testOrElse(Option $left, Option $right, Option $expected): void } /** - * @dataProvider orMatrix * @template T * @param Option $left * @param Option $right * @param Option $expected */ + #[DataProvider('orMatrix')] public function testOr(Option $left, Option $right, Option $expected): void { Assert::assertSame($expected, $left->or($right)); } /** - * @dataProvider xorMatrix * @template T * @param Option $left * @param Option $right * @param Option $expected */ + #[DataProvider('xorMatrix')] public function testXor(Option $left, Option $right, Option $expected): void { Assert::assertEquals($expected, $left->xor($right)); diff --git a/tests/Unit/Option/ContainsTest.php b/tests/Unit/Option/ContainsTest.php index 1f32d83..c9211b2 100644 --- a/tests/Unit/Option/ContainsTest.php +++ b/tests/Unit/Option/ContainsTest.php @@ -4,6 +4,7 @@ use PHPUnit\Framework\Assert; use PHPUnit\Framework\TestCase; +use PHPUnit\Framework\Attributes\DataProvider; use TH\Maybe\Option; use TH\Maybe\Tests\Provider; @@ -12,9 +13,9 @@ final class ContainsTest extends TestCase use Provider\Values; /** - * @dataProvider containsMatrix * @param Option $option */ + #[DataProvider('containsMatrix')] public function testContains(Option $option, mixed $value, bool $expect, bool $strict = true): void { Assert::assertSame($expect, $option->contains($value, strict: $strict)); diff --git a/tests/Unit/Option/ConvertToResultTest.php b/tests/Unit/Option/ConvertToResultTest.php index f637db2..a59124a 100644 --- a/tests/Unit/Option/ConvertToResultTest.php +++ b/tests/Unit/Option/ConvertToResultTest.php @@ -3,6 +3,7 @@ namespace TH\Maybe\Tests\Unit\Option; use PHPUnit\Framework\TestCase; +use PHPUnit\Framework\Attributes\DataProvider; use TH\Maybe\Option; use TH\Maybe\Result; use TH\Maybe\Tests\Assert; @@ -13,10 +14,10 @@ final class ConvertToResultTest extends TestCase use Provider\Transpose; /** - * @dataProvider okOrMatrix * @param Option $option * @param Result $expected */ + #[DataProvider('okOrMatrix')] public function testOkOr(Option $option, mixed $err, Result $expected): void { Assert::assertEquals($expected, $result = $option->okOr($err)); @@ -26,10 +27,10 @@ public function testOkOr(Option $option, mixed $err, Result $expected): void } /** - * @dataProvider okOrMatrix * @param Option $option * @param Result $expected */ + #[DataProvider('okOrElseMatrix')] public function testOkOrElse(Option $option, mixed $err, Result $expected, int $expectedCalls): void { $calls = 0; @@ -47,7 +48,7 @@ public function testOkOrElse(Option $option, mixed $err, Result $expected, int $ } /** - * @return iterable, mixed, Result, int}> + * @return iterable, mixed, Result}> */ public static function okOrMatrix(): iterable { @@ -55,22 +56,35 @@ public static function okOrMatrix(): iterable Option\none(), "Don't panic !", Result\err("Don't panic !"), - 1, ]; yield "some" => [ Option\some(42), "Don't panic !", Result\ok(42), - 0, ]; } /** - * @dataProvider transposeMatrix + * @return iterable, mixed, Result, int}> + */ + public static function okOrElseMatrix(): iterable + { + foreach (self::okOrMatrix() as $key => [$option, $err, $result]) { + yield $key => [ + $option, + $err, + $result, + $option instanceof Option\None ? 1 : 0, + ]; + } + } + + /** * @param Option> $option * @param Result $expected */ + #[DataProvider('transposeMatrix')] public function testTranspose(Option $option, Result $expected): void { Assert::assertEquals($expected, $result = Option\transpose($option)); diff --git a/tests/Unit/Option/FilterTest.php b/tests/Unit/Option/FilterTest.php index 853a1a4..2e73939 100644 --- a/tests/Unit/Option/FilterTest.php +++ b/tests/Unit/Option/FilterTest.php @@ -4,16 +4,17 @@ use PHPUnit\Framework\Assert; use PHPUnit\Framework\TestCase; +use PHPUnit\Framework\Attributes\DataProvider; use TH\Maybe\Option; final class FilterTest extends TestCase { /** - * @dataProvider filterMatrix * @template T * @param Option $option * @param array $expectedCalls */ + #[DataProvider('filterMatrix')] public function testFilter(Option $option, bool $filterResult, bool $expectNone, array $expectedCalls): void { $calls = []; diff --git a/tests/Unit/Option/FlattenTest.php b/tests/Unit/Option/FlattenTest.php index e6989c0..b85a2ec 100644 --- a/tests/Unit/Option/FlattenTest.php +++ b/tests/Unit/Option/FlattenTest.php @@ -4,15 +4,16 @@ use PHPUnit\Framework\Assert; use PHPUnit\Framework\TestCase; +use PHPUnit\Framework\Attributes\DataProvider; use TH\Maybe\Option; final class FlattenTest extends TestCase { /** - * @dataProvider flattenMatrix * @param Option $expected * @param Option> $option */ + #[DataProvider('flattenMatrix')] public function testFlatten(Option $expected, Option $option): void { Assert::assertEquals($expected, Option\flatten($option)); diff --git a/tests/Unit/Option/FromValueTest.php b/tests/Unit/Option/FromValueTest.php index 83d35c8..7ff362a 100644 --- a/tests/Unit/Option/FromValueTest.php +++ b/tests/Unit/Option/FromValueTest.php @@ -4,6 +4,7 @@ use PHPUnit\Framework\Assert; use PHPUnit\Framework\TestCase; +use PHPUnit\Framework\Attributes\DataProvider; use TH\Maybe\Option; use TH\Maybe\Tests\Provider; @@ -12,9 +13,9 @@ final class FromValueTest extends TestCase use Provider\Options; /** - * @dataProvider fromValueMatrix * @param Option $expected */ + #[DataProvider('fromValueMatrix')] public function testFromValue(Option $expected, mixed $value, mixed $noneValue, bool $strict = true): void { Assert::assertEquals($expected, Option\fromValue($value, $noneValue, strict: $strict)); diff --git a/tests/Unit/Option/InspectTest.php b/tests/Unit/Option/InspectTest.php index 5d45aba..42c9d28 100644 --- a/tests/Unit/Option/InspectTest.php +++ b/tests/Unit/Option/InspectTest.php @@ -4,6 +4,7 @@ use PHPUnit\Framework\Assert; use PHPUnit\Framework\TestCase; +use PHPUnit\Framework\Attributes\DataProvider; use TH\Maybe\Option; use TH\Maybe\Tests\Provider; @@ -12,8 +13,8 @@ final class InspectTest extends TestCase use Provider\Values; /** - * @dataProvider values */ + #[DataProvider('values')] public function testInspectSome(mixed $value): void { $option = Option\some($value); diff --git a/tests/Unit/Option/IsTest.php b/tests/Unit/Option/IsTest.php index d0666b4..e9f9612 100644 --- a/tests/Unit/Option/IsTest.php +++ b/tests/Unit/Option/IsTest.php @@ -3,6 +3,7 @@ namespace TH\Maybe\Tests\Unit\Option; use PHPUnit\Framework\TestCase; +use PHPUnit\Framework\Attributes\DataProvider; use TH\Maybe\Option; use TH\Maybe\Tests\Assert; use TH\Maybe\Tests\Provider; @@ -12,8 +13,8 @@ final class IsTest extends TestCase use Provider\Values; /** - * @dataProvider values */ + #[DataProvider('values')] public function testIsSome(mixed $value): void { $option = Option\some($value); @@ -26,8 +27,8 @@ public function testIsSome(mixed $value): void } /** - * @dataProvider values */ + #[DataProvider('values')] public function testIsNone(mixed $value): void { $option = Option\some($value); @@ -40,8 +41,8 @@ public function testIsNone(mixed $value): void } /** - * @dataProvider values */ + #[DataProvider('values')] public function testIsSomeAnd(mixed $value): void { $option = Option\some($value); diff --git a/tests/Unit/Option/MapTest.php b/tests/Unit/Option/MapTest.php index a83e03b..110106d 100644 --- a/tests/Unit/Option/MapTest.php +++ b/tests/Unit/Option/MapTest.php @@ -4,12 +4,12 @@ use PHPUnit\Framework\Assert; use PHPUnit\Framework\TestCase; +use PHPUnit\Framework\Attributes\DataProvider; use TH\Maybe\Option; final class MapTest extends TestCase { /** - * @dataProvider mapMatrix * @template T * @template U * @param Option $option @@ -17,6 +17,7 @@ final class MapTest extends TestCase * @param Option $expected * @param array $expectedCalls */ + #[DataProvider('mapMatrix')] public function testMap(Option $option, mixed $mapResult, Option $expected, array $expectedCalls): void { $calls = []; @@ -59,7 +60,6 @@ public static function mapMatrix(): iterable } /** - * @dataProvider mapOrMatrix * @template T * @template U * @param Option $option @@ -68,6 +68,7 @@ public static function mapMatrix(): iterable * @param U $expected * @param array $expectedCalls */ + #[DataProvider('mapOrMatrix')] public function testMapOr( Option $option, mixed $mapResult, diff --git a/tests/Unit/Option/OfTest.php b/tests/Unit/Option/OfTest.php index e055ed2..b0b9dab 100644 --- a/tests/Unit/Option/OfTest.php +++ b/tests/Unit/Option/OfTest.php @@ -4,6 +4,7 @@ use PHPUnit\Framework\Assert; use PHPUnit\Framework\TestCase; +use PHPUnit\Framework\Attributes\DataProvider; use TH\Maybe\Option; use TH\Maybe\Tests\Provider; @@ -12,18 +13,18 @@ final class OfTest extends TestCase use Provider\Options; /** - * @dataProvider fromValueMatrix * @param Option $expected */ + #[DataProvider('fromValueMatrix')] public function testOf(Option $expected, mixed $value, mixed $noneValue, bool $strict = true): void { Assert::assertEquals($expected, Option\of(static fn () => $value, $noneValue, strict: $strict)); } /** - * @dataProvider fromValueMatrix * @param Option $expected */ + #[DataProvider('fromValueMatrix')] public function testTryOf(Option $expected, mixed $value, mixed $noneValue, bool $strict = true): void { Assert::assertEquals($expected, Option\tryOf(static fn () => $value, $noneValue, strict: $strict)); diff --git a/tests/Unit/Option/SerializationTest.php b/tests/Unit/Option/SerializationTest.php index 9b96717..a6db3c0 100644 --- a/tests/Unit/Option/SerializationTest.php +++ b/tests/Unit/Option/SerializationTest.php @@ -4,6 +4,7 @@ use PHPUnit\Framework\Assert; use PHPUnit\Framework\TestCase; +use PHPUnit\Framework\Attributes\DataProvider; use TH\Maybe\Option; use TH\Maybe\Tests\Provider; @@ -20,8 +21,8 @@ public function testWithNone(): void } /** - * @dataProvider serializableValues */ + #[DataProvider('serializableValues')] public function testWithSomeValidValues(mixed $value): void { $this->testSerializableOption(Option\some($value)); diff --git a/tests/Unit/Option/UnwrapTest.php b/tests/Unit/Option/UnwrapTest.php index ce0de3b..a80311e 100644 --- a/tests/Unit/Option/UnwrapTest.php +++ b/tests/Unit/Option/UnwrapTest.php @@ -4,6 +4,7 @@ use PHPUnit\Framework\Assert; use PHPUnit\Framework\TestCase; +use PHPUnit\Framework\Attributes\DataProvider; use TH\Maybe\Option; use TH\Maybe\Tests\Provider; @@ -19,8 +20,8 @@ public function testExpectNone(): void } /** - * @dataProvider values */ + #[DataProvider('values')] public function testExpectSome(mixed $value): void { Assert::assertSame($value, Option\some($value)->expect("This should succeed")); @@ -34,40 +35,40 @@ public function testUnwrapNone(): void } /** - * @dataProvider values */ + #[DataProvider('values')] public function testUnwrapSome(mixed $value): void { Assert::assertSame($value, Option\some($value)->unwrap()); } /** - * @dataProvider values */ + #[DataProvider('values')] public function testUnwrapOrNone(mixed $value): void { Assert::assertSame($value, Option\none()->unwrapOr($value)); } /** - * @dataProvider values */ + #[DataProvider('values')] public function testUnwrapOrSome(mixed $value): void { Assert::assertSame($value, Option\some($value)->unwrapOr(false)); } /** - * @dataProvider values */ + #[DataProvider('values')] public function testUnwrapOrElseNone(mixed $value): void { Assert::assertSame($value, Option\none()->unwrapOrElse(static fn () => $value)); } /** - * @dataProvider values */ + #[DataProvider('values')] public function testUnwrapOrElseSome(mixed $value): void { Assert::assertSame($value, Option\some($value)->unwrapOrElse(static fn () => false)); diff --git a/tests/Unit/Option/ZipTest.php b/tests/Unit/Option/ZipTest.php index 714391b..5c6036e 100644 --- a/tests/Unit/Option/ZipTest.php +++ b/tests/Unit/Option/ZipTest.php @@ -4,18 +4,19 @@ use PHPUnit\Framework\Assert; use PHPUnit\Framework\TestCase; +use PHPUnit\Framework\Attributes\DataProvider; use TH\Maybe\Option; final class ZipTest extends TestCase { /** - * @dataProvider zipMatrix * @template L * @template R * @param Option $left * @param Option $right * @param Option $expected */ + #[DataProvider('zipMatrix')] public function testZip(Option $left, Option $right, Option $expected): void { Assert::assertEquals($expected, $left->zip($right)); @@ -56,13 +57,13 @@ public static function zipMatrix(): iterable } /** - * @dataProvider unzipMatrix * @template L * @template R * @param Option $zipped * @param Option $left * @param Option $right */ + #[DataProvider('unzipMatrix')] public function testUnzip(Option $zipped, Option $left, Option $right): void { Assert::assertEquals([$left, $right], Option\unzip($zipped)); diff --git a/tests/Unit/Result/BooleanTest.php b/tests/Unit/Result/BooleanTest.php index 22470f1..79a5965 100644 --- a/tests/Unit/Result/BooleanTest.php +++ b/tests/Unit/Result/BooleanTest.php @@ -3,6 +3,7 @@ namespace TH\Maybe\Tests\Unit\Result; use PHPUnit\Framework\TestCase; +use PHPUnit\Framework\Attributes\DataProvider; use TH\Maybe\Result; use TH\Maybe\Tests\Assert; use TH\Maybe\Tests\Provider; @@ -12,12 +13,12 @@ final class BooleanTest extends TestCase use Provider\Results; /** - * @dataProvider andMatrix * @template T * @param Result $left * @param Result $right * @param Result $expected */ + #[DataProvider('andMatrix')] public function testAnd(Result $left, Result $right, Result $expected): void { Assert::assertEquals($expected, $result = $left->and($right)); @@ -29,12 +30,12 @@ public function testAnd(Result $left, Result $right, Result $expected): void } /** - * @dataProvider andMatrix * @template T * @param Result $left * @param Result $right * @param Result $expected */ + #[DataProvider('andMatrix')] public function testAndThen(Result $left, Result $right, Result $expected): void { $calls = []; @@ -64,12 +65,12 @@ static function (mixed $value) use ($right, &$calls): mixed { } /** - * @dataProvider orMatrix * @template T * @param Result $left * @param Result $right * @param Result $expected */ + #[DataProvider('orMatrix')] public function testOrElse(Result $left, Result $right, Result $expected): void { $calls = 0; @@ -97,12 +98,12 @@ public function testOrElse(Result $left, Result $right, Result $expected): void } /** - * @dataProvider orMatrix * @template T * @param Result $left * @param Result $right * @param Result $expected */ + #[DataProvider('orMatrix')] public function testOr(Result $left, Result $right, Result $expected): void { Assert::assertEquals($expected, $result = $left->or($right)); diff --git a/tests/Unit/Result/ContainsTest.php b/tests/Unit/Result/ContainsTest.php index 49aa27d..7cbfa16 100644 --- a/tests/Unit/Result/ContainsTest.php +++ b/tests/Unit/Result/ContainsTest.php @@ -3,6 +3,7 @@ namespace TH\Maybe\Tests\Unit\Result; use PHPUnit\Framework\TestCase; +use PHPUnit\Framework\Attributes\DataProvider; use TH\Maybe\Result; use TH\Maybe\Tests\Assert; use TH\Maybe\Tests\Provider; @@ -12,9 +13,9 @@ final class ContainsTest extends TestCase use Provider\Values; /** - * @dataProvider containsMatrix * @param Result $result */ + #[DataProvider('containsMatrix')] public function testContains(Result $result, mixed $value, bool $expect, bool $strict = true): void { Assert::assertSame($expect, $result->contains($value, strict: $strict)); @@ -55,9 +56,9 @@ public function testContainsDefaultsToStrict(): void } /** - * @dataProvider containsErrMatrix * @param Result $result */ + #[DataProvider('containsErrMatrix')] public function testContainsErr(Result $result, mixed $value, bool $expect, bool $strict = true): void { Assert::assertSame($expect, $result->containsErr($value, strict: $strict)); diff --git a/tests/Unit/Result/ConvertToOptionTest.php b/tests/Unit/Result/ConvertToOptionTest.php index e063089..5b3f010 100644 --- a/tests/Unit/Result/ConvertToOptionTest.php +++ b/tests/Unit/Result/ConvertToOptionTest.php @@ -3,6 +3,7 @@ namespace TH\Maybe\Tests\Unit\Result; use PHPUnit\Framework\TestCase; +use PHPUnit\Framework\Attributes\DataProvider; use TH\Maybe\Option; use TH\Maybe\Result; use TH\Maybe\Tests\Assert; @@ -13,10 +14,10 @@ final class ConvertToOptionTest extends TestCase use Provider\Transpose; /** - * @dataProvider okMatrix * @param Result $result * @param Option $expected */ + #[DataProvider('okMatrix')] public function testOk(Result $result, Option $expected): void { Assert::assertEquals($expected, $result->ok()); @@ -39,10 +40,10 @@ public static function okMatrix(): iterable } /** - * @dataProvider errMatrix * @param Result $result * @param Option $expected */ + #[DataProvider('errMatrix')] public function testErr(Result $result, Option $expected): void { Assert::assertEquals($expected, $result->err()); @@ -67,10 +68,10 @@ public static function errMatrix(): iterable /** * @template T * @template E - * @dataProvider transposeMatrix * @param Result, E> $expected * @param Option> $option */ + #[DataProvider('transposeMatrix')] public function testTranspose(Option $option, Result $expected): void { Assert::assertEquals($option, $option2 = Result\transpose($expected)); diff --git a/tests/Unit/Result/ExtendsTest.php b/tests/Unit/Result/ExtendsTest.php index 350dfca..12a4a41 100644 --- a/tests/Unit/Result/ExtendsTest.php +++ b/tests/Unit/Result/ExtendsTest.php @@ -3,6 +3,7 @@ namespace TH\Maybe\Tests\Unit\Result; use PHPUnit\Framework\TestCase; +use PHPUnit\Framework\Attributes\DataProvider; use TH\Maybe\Result; use TH\Maybe\Tests\Assert; use TH\Maybe\Tests\Helpers; @@ -29,10 +30,10 @@ public function testErrIsExtendable(): void /** * Allowing overriding constructors would make the "Must be used" feature unsafe * - * @dataProvider resultClasses * @param class-string> $resultClass * @throws \ReflectionException */ + #[DataProvider('resultClasses')] public function testConstructorsCannotBeOverriden(string $resultClass): void { $rc = new \ReflectionClass($resultClass); @@ -42,9 +43,9 @@ public function testConstructorsCannotBeOverriden(string $resultClass): void } /** - * @dataProvider resultMethods * @throws \ReflectionException */ + #[DataProvider('resultMethods')] public function testOkResultMethodsCannotBeOverriden(string $method): void { $rc = new \ReflectionClass(Result\Ok::class); @@ -55,9 +56,9 @@ public function testOkResultMethodsCannotBeOverriden(string $method): void } /** - * @dataProvider resultMethods * @throws \ReflectionException */ + #[DataProvider('resultMethods')] public function testErrResultMethodsCannotBeOverriden(string $method): void { $rc = new \ReflectionClass(Result\Err::class); diff --git a/tests/Unit/Result/FlattenTest.php b/tests/Unit/Result/FlattenTest.php index 2d09dd4..8c74a0a 100644 --- a/tests/Unit/Result/FlattenTest.php +++ b/tests/Unit/Result/FlattenTest.php @@ -3,16 +3,17 @@ namespace TH\Maybe\Tests\Unit\Result; use PHPUnit\Framework\TestCase; +use PHPUnit\Framework\Attributes\DataProvider; use TH\Maybe\Result; use TH\Maybe\Tests\Assert; final class FlattenTest extends TestCase { /** - * @dataProvider flattenMatrix * @param Result $expected * @param Result, null> $result */ + #[DataProvider('flattenMatrix')] public function testFlatten(Result $expected, Result $result): void { Assert::assertResultNotUsed($result); diff --git a/tests/Unit/Result/InspectTest.php b/tests/Unit/Result/InspectTest.php index 7095896..b1138d3 100644 --- a/tests/Unit/Result/InspectTest.php +++ b/tests/Unit/Result/InspectTest.php @@ -3,6 +3,7 @@ namespace TH\Maybe\Tests\Unit\Result; use PHPUnit\Framework\TestCase; +use PHPUnit\Framework\Attributes\DataProvider; use TH\Maybe\Result; use TH\Maybe\Tests\Assert; use TH\Maybe\Tests\Provider; @@ -12,8 +13,8 @@ final class InspectTest extends TestCase use Provider\Values; /** - * @dataProvider values */ + #[DataProvider('values')] public function testInspectOk(mixed $value): void { $result = Result\ok($value); @@ -51,8 +52,8 @@ public function testInspectErrOk(): void } /** - * @dataProvider values */ + #[DataProvider('values')] public function testInspectErrNone(mixed $value): void { $result = Result\err($value); diff --git a/tests/Unit/Result/IsTest.php b/tests/Unit/Result/IsTest.php index b63e45f..c14a779 100644 --- a/tests/Unit/Result/IsTest.php +++ b/tests/Unit/Result/IsTest.php @@ -3,6 +3,7 @@ namespace TH\Maybe\Tests\Unit\Result; use PHPUnit\Framework\TestCase; +use PHPUnit\Framework\Attributes\DataProvider; use TH\Maybe\Result; use TH\Maybe\Tests\Assert; use TH\Maybe\Tests\Provider; @@ -12,8 +13,8 @@ final class IsTest extends TestCase use Provider\Values; /** - * @dataProvider values */ + #[DataProvider('values')] public function testIsOk(mixed $value): void { $result = Result\ok($value); @@ -28,8 +29,8 @@ public function testIsOk(mixed $value): void } /** - * @dataProvider values */ + #[DataProvider('values')] public function testIsErr(mixed $value): void { $result = Result\ok($value); @@ -44,8 +45,8 @@ public function testIsErr(mixed $value): void } /** - * @dataProvider values */ + #[DataProvider('values')] public function testIsOkAnd(mixed $value): void { $result = Result\ok($value); @@ -62,8 +63,8 @@ public function testIsOkAnd(mixed $value): void } /** - * @dataProvider values */ + #[DataProvider('values')] public function testIsErrAnd(mixed $value): void { $result = Result\ok($value); diff --git a/tests/Unit/Result/MapTest.php b/tests/Unit/Result/MapTest.php index 5af4eec..98a575b 100644 --- a/tests/Unit/Result/MapTest.php +++ b/tests/Unit/Result/MapTest.php @@ -3,13 +3,13 @@ namespace TH\Maybe\Tests\Unit\Result; use PHPUnit\Framework\TestCase; +use PHPUnit\Framework\Attributes\DataProvider; use TH\Maybe\Result; use TH\Maybe\Tests\Assert; final class MapTest extends TestCase { /** - * @dataProvider mapMatrix * @template T * @template U * @param Result $result @@ -17,6 +17,7 @@ final class MapTest extends TestCase * @param Result $expected * @param array $expectedCalls */ + #[DataProvider('mapMatrix')] public function testMap(Result $result, mixed $mapResult, Result $expected, array $expectedCalls): void { $calls = []; @@ -63,7 +64,6 @@ public static function mapMatrix(): iterable } /** - * @dataProvider mapErrMatrix * @template T * @template U * @param Result $result @@ -71,6 +71,7 @@ public static function mapMatrix(): iterable * @param Result $expected * @param array $expectedCalls */ + #[DataProvider('mapErrMatrix')] public function testMapErr(Result $result, mixed $mapResult, Result $expected, array $expectedCalls): void { $calls = []; @@ -117,7 +118,6 @@ public static function mapErrMatrix(): iterable } /** - * @dataProvider mapOrMatrix * @template T * @template U * @param Result $result @@ -126,6 +126,7 @@ public static function mapErrMatrix(): iterable * @param U $expected * @param array $expectedCalls */ + #[DataProvider('mapOrMatrix')] public function testMapOr( Result $result, mixed $mapResult, diff --git a/tests/Unit/Result/MustBeUsedTest.php b/tests/Unit/Result/MustBeUsedTest.php index d5741d4..856af46 100644 --- a/tests/Unit/Result/MustBeUsedTest.php +++ b/tests/Unit/Result/MustBeUsedTest.php @@ -4,15 +4,16 @@ use PHPUnit\Framework\Assert; use PHPUnit\Framework\TestCase; +use PHPUnit\Framework\Attributes\DataProvider; use TH\Maybe\Result; use TH\Maybe\Result\UnusedResultException; final class MustBeUsedTest extends TestCase { /** - * @dataProvider resultsFactory * @param callable(): Result $factory */ + #[DataProvider('resultsFactory')] public function testNotUsingAResultThrowAnExceptionWhenFreed(callable $factory): void { $this->expectException(UnusedResultException::class); @@ -25,9 +26,9 @@ public function testNotUsingAResultThrowAnExceptionWhenFreed(callable $factory): } /** - * @dataProvider resultsFactory * @param callable(): Result $factory */ + #[DataProvider('resultsFactory')] public function testUsingAResultAvoidTheExceptionWhenFreed(callable $factory): void { (static function (callable $factory): void { @@ -37,9 +38,9 @@ public function testUsingAResultAvoidTheExceptionWhenFreed(callable $factory): v } /** - * @dataProvider resultsFactory * @param callable(): Result $factory */ + #[DataProvider('resultsFactory')] public function testAClonedResultMustBeUsed(callable $factory): void { $this->expectException(UnusedResultException::class); @@ -56,9 +57,9 @@ public function testAClonedResultMustBeUsed(callable $factory): void } /** - * @dataProvider resultsFactory * @param callable(): Result $factory */ + #[DataProvider('resultsFactory')] public function testAnUnserializedResultDontHaveToBeUsed(callable $factory): void { (static function (callable $factory): void { diff --git a/tests/Unit/Result/TrapTest.php b/tests/Unit/Result/TrapTest.php index b6bfbc1..96b94fb 100644 --- a/tests/Unit/Result/TrapTest.php +++ b/tests/Unit/Result/TrapTest.php @@ -3,6 +3,7 @@ namespace TH\Maybe\Tests\Unit\Result; use PHPUnit\Framework\TestCase; +use PHPUnit\Framework\Attributes\DataProvider; use TH\Maybe\Result; use TH\Maybe\Tests\Assert; use TH\Maybe\Tests\Provider; @@ -12,8 +13,8 @@ final class TrapTest extends TestCase use Provider\Values; /** - * @dataProvider values */ + #[DataProvider('values')] public function testTrapOk(mixed $value): void { $callback = static fn () => $value; diff --git a/tests/Unit/Result/UnwrapTest.php b/tests/Unit/Result/UnwrapTest.php index a87ba07..d97aef8 100644 --- a/tests/Unit/Result/UnwrapTest.php +++ b/tests/Unit/Result/UnwrapTest.php @@ -4,6 +4,7 @@ use PHPUnit\Framework\Assert; use PHPUnit\Framework\TestCase; +use PHPUnit\Framework\Attributes\DataProvider; use TH\Maybe\Result; use TH\Maybe\Tests\Provider; @@ -19,8 +20,8 @@ public function testExpectErr(): void } /** - * @dataProvider values */ + #[DataProvider('values')] public function testExpectOk(mixed $value): void { Assert::assertSame($value, Result\ok($value)->expect("This should succeed")); @@ -43,40 +44,40 @@ public function testUnwrapErrException(): void } /** - * @dataProvider values */ + #[DataProvider('values')] public function testUnwrapOk(mixed $value): void { Assert::assertSame($value, Result\ok($value)->unwrap()); } /** - * @dataProvider values */ + #[DataProvider('values')] public function testUnwrapOrErr(mixed $value): void { Assert::assertSame($value, Result\err(null)->unwrapOr($value)); } /** - * @dataProvider values */ + #[DataProvider('values')] public function testUnwrapOrOk(mixed $value): void { Assert::assertSame($value, Result\ok($value)->unwrapOr(false)); } /** - * @dataProvider values */ + #[DataProvider('values')] public function testUnwrapOrElseErr(mixed $value): void { Assert::assertSame($value, Result\err(null)->unwrapOrElse(static fn () => $value)); } /** - * @dataProvider values */ + #[DataProvider('values')] public function testUnwrapOrElseOk(mixed $value): void { Assert::assertSame($value, Result\ok($value)->unwrapOrElse(static fn () => false));