Skip to content

Commit

Permalink
Laravel 11 (#18)
Browse files Browse the repository at this point in the history
* Bump dependencies for Laravel 11

* Update GitHub Actions for Laravel 11

* Removed deprecated call

* Fixed createTestResponse method

* Removed older Laravel versions

* Using static data providers

* Migrated phpunit config

---------

Co-authored-by: Shift <[email protected]>
  • Loading branch information
luisdalmolin and laravel-shift authored Apr 4, 2024
1 parent 221745a commit 89b0009
Show file tree
Hide file tree
Showing 7 changed files with 35 additions and 58 deletions.
31 changes: 10 additions & 21 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
name: run-tests

on: [push]
on:
- push

jobs:
tests:
Expand All @@ -9,34 +10,22 @@ jobs:
strategy:
fail-fast: true
matrix:
php: [7.4, 8.0, 8.1, 8.2]
laravel: [6.*, 7.*, 8.*, 9.*, 10.*]
php: [8.0, 8.1, 8.2]
laravel: ['9.*', '10.*', '11.*']
include:
- laravel: 11.*
testbench: 9.*
- laravel: 10.*
testbench: 8.*
- laravel: 9.*
testbench: 7.*
- laravel: 8.*
testbench: 6.*
- laravel: 7.*
testbench: 5.*
- laravel: 6.*
testbench: 4.*
exclude:
- php: 7.4
laravel: 9.*
- php: 7.4
laravel: 10.*
- php: 8.0
laravel: 10.*
- php: 8.1
laravel: 7.*
- php: 8.1
laravel: 6.*
- php: 8.2
laravel: 7.*
- php: 8.2
laravel: 6.*
- laravel: 11.*
php: 8.0
- laravel: 11.*
php: 8.1

name: PHP ${{ matrix.php }} - Laravel ${{ matrix.laravel }}

Expand Down
10 changes: 5 additions & 5 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,16 +18,16 @@
}
],
"require": {
"php": "^7.4|^8.0",
"illuminate/support": "^6.0|^7.0|^8.0|^9.0|^10.0",
"php": "^8.0",
"illuminate/support": "^9.0|^10.0|^11.0",
"league/openapi-psr7-validator": "^0.14|^0.15|^0.16|^0.17|^0.18|^0.19|^0.20|^0.21|^0.22",
"nyholm/psr7": "^1.3",
"symfony/psr-http-message-bridge": "^2.0"
"symfony/psr-http-message-bridge": "^2.0|^7.0"
},
"require-dev": {
"orchestra/testbench": "4.*|5.*|6.*|7.*",
"orchestra/testbench": "7.*|^8.0|^9.0",
"mockery/mockery": "^1.3.1",
"phpunit/phpunit": "^9.0",
"phpunit/phpunit": "^9.0|^10.5",
"fakerphp/faker": "^1.9.1"
},
"autoload": {
Expand Down
39 changes: 14 additions & 25 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
@@ -1,27 +1,16 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
bootstrap="vendor/autoload.php"
backupGlobals="false"
backupStaticAttributes="false"
colors="true"
verbose="true"
convertErrorsToExceptions="true"
convertNoticesToExceptions="true"
convertWarningsToExceptions="true"
processIsolation="false"
stopOnFailure="false"
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.3/phpunit.xsd">
<coverage>
<include>
<directory suffix=".php">src/</directory>
</include>
</coverage>
<testsuites>
<testsuite name="Test Suite">
<directory>tests</directory>
</testsuite>
</testsuites>
<logging>
<junit outputFile="build/report.junit.xml" />
</logging>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" bootstrap="vendor/autoload.php" backupGlobals="false" colors="true" processIsolation="false" stopOnFailure="false" xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/10.5/phpunit.xsd" cacheDirectory=".phpunit.cache" backupStaticProperties="false">
<testsuites>
<testsuite name="Test Suite">
<directory>tests</directory>
</testsuite>
</testsuites>
<logging>
<junit outputFile="build/report.junit.xml"/>
</logging>
<source>
<include>
<directory suffix=".php">src/</directory>
</include>
</source>
</phpunit>
2 changes: 1 addition & 1 deletion src/ValidatesOpenApiSpec.php
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ public function call($method, $uri, $parameters = [], $cookies = [], $files = []

$kernel->terminate($request, $response);

$testResponse = $this->createTestResponse($response);
$testResponse = $this->createTestResponse($response, $request);

if ($address) {
$this->validateResponse($address, $testResponse->baseResponse);
Expand Down
2 changes: 1 addition & 1 deletion tests/ValidatesRequestsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ public function testValidatesRequests(array $requestData, bool $expectSuccess, ?
* Provides a handful of scenarios to test the validator is hooked up correctly.
* We'll defer the actual testing to the league's validator itself.
*/
public function provideValidationScenarios()
public static function provideValidationScenarios()
{
yield 'Gets test OK' => [
[
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ public function testValidatesResponses(OperationAddress $address, array $respons
* Provides a handful of scenarios to test the validator is hooked up correctly.
* We'll defer the actual testing to the league's validator itself.
*/
public function provideValidationScenarios()
public static function provideValidationScenarios()
{
yield 'Empty 200 on /test is OK' => [
new OperationAddress('/test', 'get'),
Expand Down
7 changes: 3 additions & 4 deletions tests/ValidatorBuildAndSetupTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public function testGetsOpenApiValidatorBuilder(string $extension)
$this->assertInstanceOf(ValidatorBuilder::class, $builder);
}

public function provideSpecFormats()
public static function provideSpecFormats()
{
return [
['json'],
Expand All @@ -47,14 +47,13 @@ public function testThrowsExceptionForUnknownFormat(string $extension)
$this->app['config']->set('openapi_validator.spec_path', __DIR__ . "/fixtures/OpenAPI.{$extension}");

$this->expectException(UnknownSpecFileTypeException::class);
$this->expectErrorMessage("Expected json or yaml type OpenAPI spec, got {$extension}");
$this->getSpecFileType();
}

/**
* @return array
*/
public function provideSpecUnknownFormats(): array
public static function provideSpecUnknownFormats(): array
{
return [
['banana'],
Expand Down Expand Up @@ -116,7 +115,7 @@ public function testSkipsResponseCodes($responseCode, $codesToSkip, bool $expect
$this->assertEquals($expected, $this->shouldSkipResponseValidation($response));
}

public function provideResponseCodes()
public static function provideResponseCodes()
{
for ($i = 0; $i <= 8; $i++) {
yield "Skips 50{$i} by default" => [500 + $i, [], true];
Expand Down

0 comments on commit 89b0009

Please sign in to comment.