Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Drop PHP 8.0, require PHP 8.1 minimum, use PHPUnit 10 #67

Merged
merged 2 commits into from
Aug 25, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ jobs:
fail-fast: false
matrix:
php-version:
- "8.0"
- "8.1"
- "8.2"
dependencies:
Expand Down
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
5 changes: 2 additions & 3 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,11 @@
"overblog/promise-adapter": "self.version"
},
"require": {
"php": "^8.0"
"php": "^8.1"
},
"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"
},
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>
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
Loading