diff --git a/.gitignore b/.gitignore index d1966d1..b74c281 100644 --- a/.gitignore +++ b/.gitignore @@ -5,3 +5,4 @@ composer.phar phpunit.xml .php_cs.cache .phpunit.result.cache +.phpunit.cache diff --git a/composer.json b/composer.json index f37f969..e6f3c30 100644 --- a/composer.json +++ b/composer.json @@ -27,8 +27,7 @@ }, "require-dev": { "guzzlehttp/promises": "^1.5.0 || ^2.0.0", - "phpunit/php-code-coverage": "^9.2.27", - "phpunit/phpunit": "^9.6.11", + "phpunit/phpunit": "^10.3", "react/promise": "^2.8.0", "webonyx/graphql-php": "^14.0" }, diff --git a/lib/promise-adapter/tests/AdapterTest.php b/lib/promise-adapter/tests/AdapterTest.php index fa56f9b..7c341ea 100644 --- a/lib/promise-adapter/tests/AdapterTest.php +++ b/lib/promise-adapter/tests/AdapterTest.php @@ -15,15 +15,16 @@ use Overblog\PromiseAdapter\Adapter\ReactPromiseAdapter; use Overblog\PromiseAdapter\Adapter\WebonyxGraphQLSyncPromiseAdapter; use Overblog\PromiseAdapter\PromiseAdapterInterface; +use PHPUnit\Framework\Attributes\DataProvider; class AdapterTest extends \PHPUnit\Framework\TestCase { /** - * @dataProvider AdapterDataProvider * @param string $promiseClass * @param PromiseAdapterInterface $Adapter * @param string $context */ + #[DataProvider('AdapterDataProvider')] public function testCreate(PromiseAdapterInterface $Adapter, $context, $promiseClass) { $promise = $Adapter->create($resolve, $reject); @@ -34,10 +35,10 @@ public function testCreate(PromiseAdapterInterface $Adapter, $context, $promiseC } /** - * @dataProvider AdapterDataProvider * @param PromiseAdapterInterface $Adapter * @param $message */ + #[DataProvider('AdapterDataProvider')] public function testResolveCreatedPromise(PromiseAdapterInterface $Adapter, $message) { $promise = $Adapter->create($resolve, $reject); @@ -49,10 +50,10 @@ public function testResolveCreatedPromise(PromiseAdapterInterface $Adapter, $mes } /** - * @dataProvider AdapterDataProvider * @param PromiseAdapterInterface $Adapter * @param string $context */ + #[DataProvider('AdapterDataProvider')] public function testRejectCreatedPromise(PromiseAdapterInterface $Adapter, $context) { $promise = $Adapter->create($resolve, $reject); @@ -65,11 +66,11 @@ public function testRejectCreatedPromise(PromiseAdapterInterface $Adapter, $cont } /** - * @dataProvider AdapterDataProvider * @param PromiseAdapterInterface $Adapter * @param string $context * @param string $promiseClass */ + #[DataProvider('AdapterDataProvider')] public function testCreateAll(PromiseAdapterInterface $Adapter, $context, $promiseClass) { $values = ['A', 'B', 'C']; @@ -82,11 +83,11 @@ public function testCreateAll(PromiseAdapterInterface $Adapter, $context, $promi } /** - * @dataProvider AdapterDataProvider * @param PromiseAdapterInterface $Adapter * @param string $context * @param string $promiseClass */ + #[DataProvider('AdapterDataProvider')] public function testCreateFulfilled(PromiseAdapterInterface $Adapter, $context, $promiseClass) { $value = 'resolved!'; @@ -98,11 +99,11 @@ public function testCreateFulfilled(PromiseAdapterInterface $Adapter, $context, } /** - * @dataProvider AdapterDataProvider * @param PromiseAdapterInterface $Adapter * @param string $context * @param string $promiseClass */ + #[DataProvider('AdapterDataProvider')] public function testCreatedRejected(PromiseAdapterInterface $Adapter, $context, $promiseClass) { $expectRejectionReason = new \Exception('Error!'); @@ -114,10 +115,10 @@ public function testCreatedRejected(PromiseAdapterInterface $Adapter, $context, } /** - * @dataProvider AdapterDataProvider * @param PromiseAdapterInterface $Adapter * @param string $context */ + #[DataProvider('AdapterDataProvider')] public function testIsPromise(PromiseAdapterInterface $Adapter, $context) { $promise = $Adapter->create(); @@ -128,10 +129,10 @@ public function testIsPromise(PromiseAdapterInterface $Adapter, $context) } /** - * @dataProvider AdapterDataProvider * @param PromiseAdapterInterface $Adapter * @param string $context */ + #[DataProvider('AdapterDataProvider')] public function testAwaitWithoutPromise(PromiseAdapterInterface $Adapter, $context) { $expected = 'expected value'; @@ -148,10 +149,9 @@ public function testAwaitWithoutPromise(PromiseAdapterInterface $Adapter, $conte } /** - * @dataProvider AdapterDataProvider * @param PromiseAdapterInterface $Adapter - * */ + #[DataProvider('AdapterDataProvider')] public function testAwaitWithUnwrap(PromiseAdapterInterface $Adapter) { $this->expectException(\Exception::class); @@ -164,9 +164,9 @@ public function testAwaitWithUnwrap(PromiseAdapterInterface $Adapter) } /** - * @dataProvider AdapterDataProvider * @param PromiseAdapterInterface $Adapter */ + #[DataProvider('AdapterDataProvider')] public function testAwaitWithInvalidPromise(PromiseAdapterInterface $Adapter) { $this->expectException(\InvalidArgumentException::class); @@ -176,9 +176,9 @@ public function testAwaitWithInvalidPromise(PromiseAdapterInterface $Adapter) } /** - * @dataProvider AdapterDataProvider * @param PromiseAdapterInterface $Adapter */ + #[DataProvider('AdapterDataProvider')] public function testCancel(PromiseAdapterInterface $Adapter) { $this->expectException(\Exception::class); @@ -193,9 +193,9 @@ public function testCancel(PromiseAdapterInterface $Adapter) } /** - * @dataProvider AdapterDataProvider * @param PromiseAdapterInterface $Adapter */ + #[DataProvider('AdapterDataProvider')] public function testCancelInvalidPromise(PromiseAdapterInterface $Adapter) { $this->expectException(\Exception::class); @@ -208,7 +208,7 @@ public function testCancelInvalidPromise(PromiseAdapterInterface $Adapter) $Adapter->cancel(new \stdClass()); } - public function AdapterDataProvider() + public static function AdapterDataProvider() { return [ [new GuzzleHttpPromiseAdapter(), 'guzzle', 'GuzzleHttp\\Promise\\PromiseInterface'], diff --git a/phpunit.xml.dist b/phpunit.xml.dist index 338b144..bfe83d5 100644 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -1,17 +1,7 @@ - - - - ./src - ./lib/promise-adapter/src - - - ./vendor - ./tests - ./lib/promise-adapter/tests - - + + @@ -21,4 +11,15 @@ ./lib/promise-adapter/tests + + + ./src + ./lib/promise-adapter/src + + + ./vendor + ./tests + ./lib/promise-adapter/tests + + diff --git a/phpunit.xml.dist.bak b/phpunit.xml.dist.bak new file mode 100644 index 0000000..338b144 --- /dev/null +++ b/phpunit.xml.dist.bak @@ -0,0 +1,24 @@ + + + + + + ./src + ./lib/promise-adapter/src + + + ./vendor + ./tests + ./lib/promise-adapter/tests + + + + + + + + ./tests + ./lib/promise-adapter/tests + + + diff --git a/tests/Functional/Webonyx/GraphQL/TestCase.php b/tests/Functional/Webonyx/GraphQL/TestCase.php index dfd034f..2ad5840 100644 --- a/tests/Functional/Webonyx/GraphQL/TestCase.php +++ b/tests/Functional/Webonyx/GraphQL/TestCase.php @@ -18,12 +18,13 @@ use GraphQL\GraphQL; use Overblog\DataLoader\DataLoader; use Overblog\PromiseAdapter\PromiseAdapterInterface; +use PHPUnit\Framework\Attributes\DataProvider; abstract class TestCase extends \PHPUnit\Framework\TestCase { private static $fixtures = null; - public function getFixtures() + public static function getFixtures() { if (null === self::$fixtures) { $fixturesFiles = self::listFiles(__DIR__.'/fixtures'); @@ -64,11 +65,11 @@ private static function listFiles($dir, &$results = []) } /** - * @dataProvider getFixtures * @param array $expectedMetrics * @param string $query * @param array $expectedResponse */ + #[DataProvider('getFixtures')] public function testExecute(array $expectedMetrics, $query, array $expectedResponse) { $metrics = [