Skip to content

Adding PHP 8.3 and PHPUnit 11 #21

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

Merged
merged 11 commits into from
Oct 30, 2024
28 changes: 27 additions & 1 deletion .github/workflows/php.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,11 @@ jobs:
- "7.4"
- "8.0"
- "8.1"
- "8.3"
dependencies:
- "lowest"
- "highest"
symfony-yaml: ['^3.4', '^4', '^5', '^6']
symfony-yaml: ['^3.4', '^4', '^5', '^6', '^7']
include:
- os: "windows-latest"
php: "8.0"
Expand All @@ -46,11 +47,27 @@ jobs:
symfony-yaml: '^6'
- php: '7.4'
symfony-yaml: '^6'
# symfony/yaml v7 does not run on PHP 7.*
- php: '7.1'
symfony-yaml: '^7'
- php: '7.2'
symfony-yaml: '^7'
- php: '7.3'
symfony-yaml: '^7'
- php: '7.4'
symfony-yaml: '^7'
# symfony/yaml v7 does not run on PHP 8.0 & 8.1
- php: '8.0'
symfony-yaml: '^7'
- php: '8.1'
symfony-yaml: '^7'
# symfony/yaml v3.4 is not compatible with PHP 8.0 but has no upper-bound, so it installs on it
- php: '8.0'
symfony-yaml: '^3.4'
- php: '8.1'
symfony-yaml: '^3.4'
- php: '8.3'
symfony-yaml: '^3.4'

runs-on: ${{ matrix.os }}

Expand All @@ -71,6 +88,10 @@ jobs:
run: "composer require phpunit/phpunit '^9.5' --dev --no-interaction --ansi --no-install"
if: matrix.php == '8.1'

- name: Require newer phpunit/phpunit version
run: "composer require phpunit/phpunit '^11.4' --dev --no-interaction --ansi --no-install"
if: matrix.php == '8.3'

- name: "Install dependencies with Composer"
uses: "ramsey/composer-install@v2"
with:
Expand All @@ -81,6 +102,11 @@ jobs:

- name: PHPUnit tests
run: make test
if: matrix.php < '8.3'

- name: PHPUnit tests
run: make test-debug
if: matrix.php == '8.3'

- name: Code coverage
run: make coverage
5 changes: 5 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,11 @@ test: unit test-recursion.json test-recursion2.yaml test-recursion3_index.yaml t
unit:
$(DOCKER_PHP) php $(PHPARGS) $(XPHPARGS) vendor/bin/phpunit --verbose --colors=always $(TESTCASE)

test-debug: unit-debug test-recursion.json test-recursion2.yaml test-recursion3_index.yaml test-empty-maps.json

unit-debug:
$(DOCKER_PHP) php $(PHPARGS) $(XPHPARGS) vendor/bin/phpunit --debug --testdox --colors=always -c phpunit11.xml.dist $(TESTCASE)

# test specific JSON files in tests/spec/data/
# e.g. test-recursion will run validation on tests/spec/data/recursion.json
test-%: tests/spec/data/%
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
},
"require-dev": {
"cebe/indent": "*",
"phpunit/phpunit": "^6.5 || ^7.5 || ^8.5 || ^9.4",
"phpunit/phpunit": "^6.5 || ^7.5 || ^8.5 || ^9.4 || ^11.4",

"oai/openapi-specification-3.0": "3.0.3",
"oai/openapi-specification-3.1": "3.1.0",
Expand Down
22 changes: 22 additions & 0 deletions phpunit11.xml.dist
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<?xml version="1.0" encoding="utf-8"?>
<phpunit
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/11.4/phpunit.xsd"
bootstrap="./tests/bootstrap.php"
colors="true"
stopOnFailure="false">
<testsuites>
<testsuite name="Test Suite">
<directory suffix="Test.php">./tests</directory>
</testsuite>
</testsuites>
<coverage>
<include>
<directory>./src</directory>
</include>
<exclude>
<directory>./vendor</directory>
<directory>./tests</directory>
</exclude>
</coverage>
</phpunit>
4 changes: 2 additions & 2 deletions tests/ReferenceContextTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

class ReferenceContextTest extends \PHPUnit\Framework\TestCase
{
public function resolveUriProvider()
public static function resolveUriProvider()
{
$data = [
[
Expand Down Expand Up @@ -124,7 +124,7 @@ public function testResolveUri($baseUri, $referencedUri, $expected)
$this->assertEquals($expected, $context->resolveRelativeUri($referencedUri));
}

public function normalizeUriProvider()
public static function normalizeUriProvider()
{
$data = [
[
Expand Down
18 changes: 9 additions & 9 deletions tests/json/JsonPointerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

class JsonPointerTest extends \PHPUnit\Framework\TestCase
{
public function encodeDecodeData()
public static function encodeDecodeData()
{
return [
['~0', '~'],
Expand Down Expand Up @@ -41,7 +41,7 @@ public function testDecode($encoded, $decoded)
/**
* @link https://tools.ietf.org/html/rfc6901#section-5
*/
public function rfcJsonDocument()
public static function rfcJsonDocument()
{
return <<<JSON
{
Expand All @@ -63,10 +63,10 @@ public function rfcJsonDocument()
/**
* @link https://tools.ietf.org/html/rfc6901#section-5
*/
public function rfcExamples()
public static function rfcExamples()
{
$return = [
["" , "#" , json_decode($this->rfcJsonDocument())],
["" , "#" , json_decode(self::rfcJsonDocument())],
["/foo" , "#/foo" , ["bar", "baz"]],
["/foo/0", "#/foo/0", "bar"],
["/" , "#/" , 0],
Expand All @@ -80,14 +80,14 @@ public function rfcExamples()
["/m~0n" , "#/m~0n" , 8],
];
foreach ($return as $example) {
$example[3] = $this->rfcJsonDocument();
$example[3] = self::rfcJsonDocument();
yield $example;
}
}

public function allExamples()
public static function allExamples()
{
yield from $this->rfcExamples();
yield from self::rfcExamples();

yield ["/a#b" , "#/a%23b" , 16, '{"a#b": 16}'];
}
Expand Down Expand Up @@ -117,11 +117,11 @@ public function testUriEncoding($jsonPointer, $uriJsonPointer, $expectedEvaluati
*/
public function testEvaluation($jsonPointer, $uriJsonPointer, $expectedEvaluation)
{
$document = json_decode($this->rfcJsonDocument());
$document = json_decode(self::rfcJsonDocument());
$pointer = new JsonPointer($jsonPointer);
$this->assertEquals($expectedEvaluation, $pointer->evaluate($document));

$document = json_decode($this->rfcJsonDocument());
$document = json_decode(self::rfcJsonDocument());
$reference = JsonReference::createFromReference($uriJsonPointer);
$this->assertEquals($expectedEvaluation, $reference->getJsonPointer()->evaluate($document));
}
Expand Down
2 changes: 1 addition & 1 deletion tests/spec/MediaTypeTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ public function testCreateionFromObjects()
$this->assertInstanceOf(\cebe\openapi\spec\Encoding::class, $mediaType->encoding['profileImage']);
}

public function badEncodingProvider()
public static function badEncodingProvider()
{
yield [['encoding' => ['id' => 'foo']], 'Encoding MUST be either array or Encoding object, "string" given'];
yield [['encoding' => ['id' => 42]], 'Encoding MUST be either array or Encoding object, "integer" given'];
Expand Down
2 changes: 1 addition & 1 deletion tests/spec/OpenApiTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ public function assertAllInstanceOf($className, $array)
}
}

public function specProvider()
public static function specProvider()
{
// examples from https://github.com/OAI/OpenAPI-Specification/tree/master/examples/v3.0
$oaiExamples = [
Expand Down
2 changes: 1 addition & 1 deletion tests/spec/PathTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ public function testCreationFromObjects()
$this->assertSame('The pets list is gone 🙀', $paths->getPath('/pets')->get->responses->getResponse(404)->description);
}

public function badPathsConfigProvider()
public static function badPathsConfigProvider()
{
yield [['/pets' => 'foo'], 'Path MUST be either array or PathItem object, "string" given'];
yield [['/pets' => 42], 'Path MUST be either array or PathItem object, "integer" given'];
Expand Down
2 changes: 1 addition & 1 deletion tests/spec/ResponseTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ public function testCreateionFromObjects()
$this->assertSame('The pets list is gone 🙀', $responses->getResponse(404)->description);
}

public function badResponseProvider()
public static function badResponseProvider()
{
yield [['200' => 'foo'], 'Response MUST be either an array, a Response or a Reference object, "string" given'];
yield [['200' => 42], 'Response MUST be either an array, a Response or a Reference object, "integer" given'];
Expand Down
2 changes: 1 addition & 1 deletion tests/spec/SchemaTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,7 @@ public function testCreateionFromObjects()
}


public function badSchemaProvider()
public static function badSchemaProvider()
{
yield [['properties' => ['a' => 'foo']], 'Unable to instantiate cebe\openapi\spec\Schema Object with data \'foo\''];
yield [['properties' => ['a' => 42]], 'Unable to instantiate cebe\openapi\spec\Schema Object with data \'42\''];
Expand Down
Loading