Skip to content

Commit

Permalink
Use PHPUnit 10
Browse files Browse the repository at this point in the history
  • Loading branch information
ruudk committed Aug 25, 2023
1 parent b3ef24c commit e1ccf38
Show file tree
Hide file tree
Showing 6 changed files with 56 additions and 30 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,4 @@ composer.phar
phpunit.xml
.php_cs.cache
.phpunit.result.cache
.phpunit.cache
3 changes: 1 addition & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
"react/promise": "^2.8.0",
"webonyx/graphql-php": "^14.0"
},
Expand Down
28 changes: 14 additions & 14 deletions lib/promise-adapter/tests/AdapterTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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);
Expand All @@ -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);
Expand All @@ -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'];
Expand All @@ -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!';
Expand All @@ -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!');
Expand All @@ -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();
Expand All @@ -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';
Expand All @@ -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);
Expand All @@ -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);
Expand All @@ -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);
Expand All @@ -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);
Expand All @@ -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'],
Expand Down
25 changes: 13 additions & 12 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
@@ -1,17 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<!-- http://phpunit.de/manual/4.1/en/appendixes.configuration.html -->
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.3/phpunit.xsd" backupGlobals="false" colors="true" bootstrap="./vendor/autoload.php" convertDeprecationsToExceptions="false">
<coverage>
<include>
<directory>./src</directory>
<directory>./lib/promise-adapter/src</directory>
</include>
<exclude>
<directory>./vendor</directory>
<directory>./tests</directory>
<directory>./lib/promise-adapter/tests</directory>
</exclude>
</coverage>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/10.3/phpunit.xsd" backupGlobals="false" colors="true" bootstrap="./vendor/autoload.php" cacheDirectory=".phpunit.cache">
<coverage/>
<php>
<ini name="error_reporting" value="-1"/>
</php>
Expand All @@ -21,4 +11,15 @@
<directory>./lib/promise-adapter/tests</directory>
</testsuite>
</testsuites>
<source>
<include>
<directory>./src</directory>
<directory>./lib/promise-adapter/src</directory>
</include>
<exclude>
<directory>./vendor</directory>
<directory>./tests</directory>
<directory>./lib/promise-adapter/tests</directory>
</exclude>
</source>
</phpunit>
24 changes: 24 additions & 0 deletions phpunit.xml.dist.bak
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<?xml version="1.0" encoding="UTF-8"?>
<!-- http://phpunit.de/manual/4.1/en/appendixes.configuration.html -->
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.3/phpunit.xsd" backupGlobals="false" colors="true" bootstrap="./vendor/autoload.php" convertDeprecationsToExceptions="false">
<coverage>
<include>
<directory>./src</directory>
<directory>./lib/promise-adapter/src</directory>
</include>
<exclude>
<directory>./vendor</directory>
<directory>./tests</directory>
<directory>./lib/promise-adapter/tests</directory>
</exclude>
</coverage>
<php>
<ini name="error_reporting" value="-1"/>
</php>
<testsuites>
<testsuite name="DataLoad Php Test Suite">
<directory>./tests</directory>
<directory>./lib/promise-adapter/tests</directory>
</testsuite>
</testsuites>
</phpunit>
5 changes: 3 additions & 2 deletions tests/Functional/Webonyx/GraphQL/TestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand Down Expand Up @@ -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 = [
Expand Down

0 comments on commit e1ccf38

Please sign in to comment.