Skip to content

Commit

Permalink
PHPUnit 10 attributes
Browse files Browse the repository at this point in the history
  • Loading branch information
BenMorel committed Mar 27, 2024
1 parent 872db31 commit 6dc9f27
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 22 deletions.
5 changes: 2 additions & 3 deletions tests/NameMapperTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,12 @@

use Brick\JsonMapper\NameMapper;
use Generator;
use PHPUnit\Framework\Attributes\DataProvider;
use PHPUnit\Framework\TestCase;

final class NameMapperTest extends TestCase
{
/**
* @dataProvider providerNameMapper
*/
#[DataProvider('providerNameMapper')]
public function testNameMapper(NameMapper $nameMapper, string $propertyName, string $expected): void
{
self::assertSame($expected, $nameMapper->mapName($propertyName));
Expand Down
11 changes: 4 additions & 7 deletions tests/Reflection/ReflectorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
use Brick\JsonMapper\Tests\Attributes\ExpectParameterType;
use Brick\JsonMapper\Tests\Classes\KitchenSink;
use Generator;
use PHPUnit\Framework\Attributes\DataProvider;
use PHPUnit\Framework\TestCase;
use ReflectionAttribute;
use ReflectionClass;
Expand All @@ -25,10 +26,9 @@
final class ReflectorTest extends TestCase
{
/**
* @dataProvider providerGetParameterType
*
* @param Config $config
*/
#[DataProvider('providerGetParameterType')]
public function testGetParameterType(ReflectionParameter $parameter, string $expectedType, array $config): void
{
$reflector = new Reflector(...$config);
Expand All @@ -55,10 +55,9 @@ public static function providerGetParameterType(): Generator
}

/**
* @dataProvider providerGetParameterTypeThrowsException
*
* @param Config $config
*/
#[DataProvider('providerGetParameterTypeThrowsException')]
public function testGetParameterTypeThrowsException(ReflectionParameter $parameter, string $exceptionMessage, array $config): void
{
$reflector = new Reflector(...$config);
Expand All @@ -83,9 +82,7 @@ public static function providerGetParameterTypeThrowsException(): Generator
}
}

/**
* @dataProvider providerKitchenSinkMethodsHaveExpectations
*/
#[DataProvider('providerKitchenSinkMethodsHaveExpectations')]
public function testKitchenSinkMethodsHaveExpectations(ReflectionParameter $parameter): void
{
$attributes = array_merge(
Expand Down
9 changes: 3 additions & 6 deletions tests/Reflection/TypeParserTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,12 @@

use Brick\JsonMapper\JsonMapperException;
use Brick\JsonMapper\Reflection\TypeParser;
use PHPUnit\Framework\Attributes\DataProvider;
use PHPUnit\Framework\TestCase;

final class TypeParserTest extends TestCase
{
/**
* @dataProvider providerParse
*/
#[DataProvider('providerParse')]
public function testParse(string $type, array $expected): void
{
$typeParser = new TypeParser($type);
Expand Down Expand Up @@ -50,9 +49,7 @@ public static function providerParse(): array
];
}

/**
* @dataProvider providerParseInvalidType
*/
#[DataProvider('providerParseInvalidType')]
public function testParseInvalidType(string $type, string $exceptionMessage): void
{
$typeParser = new TypeParser($type);
Expand Down
9 changes: 3 additions & 6 deletions tests/Reflection/TypeTokenizerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,12 @@
use Brick\JsonMapper\JsonMapperException;
use Brick\JsonMapper\Reflection\TypeToken;
use Brick\JsonMapper\Reflection\TypeTokenizer;
use PHPUnit\Framework\Attributes\DataProvider;
use PHPUnit\Framework\TestCase;

final class TypeTokenizerTest extends TestCase
{
/**
* @dataProvider providerTokenize
*/
#[DataProvider('providerTokenize')]
public function testTokenize(string $type, array $expected): void
{
$tokens = array_map(
Expand Down Expand Up @@ -76,9 +75,7 @@ public static function providerTokenize(): array
];
}

/**
* @dataProvider providerTokenizeInvalidType
*/
#[DataProvider('providerTokenizeInvalidType')]
public function testTokenizeInvalidType(string $type, string $exceptionMessage): void
{
self::expectException(JsonMapperException::class);
Expand Down

0 comments on commit 6dc9f27

Please sign in to comment.