Skip to content

Commit

Permalink
feat: laravel 11 compatibility
Browse files Browse the repository at this point in the history
  • Loading branch information
patrickhoogkamer committed May 7, 2024
1 parent 863c108 commit 47d10f5
Show file tree
Hide file tree
Showing 10 changed files with 25 additions and 39 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/phpstan.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@ jobs:
runs-on: ubuntu-latest

steps:
- uses: shivammathur/setup-php@15c43e89cdef867065b0213be354c2841860869e
- uses: shivammathur/setup-php@v2
with:
php-version: '8.1'
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- name: Install Dependencies
run: composer install -q --no-ansi --no-interaction --no-scripts --no-progress --prefer-dist
- name: Test for PHPstan errors
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/pint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@ jobs:
runs-on: ubuntu-latest

steps:
- uses: shivammathur/setup-php@15c43e89cdef867065b0213be354c2841860869e
- uses: shivammathur/setup-php@v2
with:
php-version: '8.2'

- uses: actions/checkout@v3
- uses: actions/checkout@v4
with:
# Fetch the last 2 commits instead of just 1. (Fetching just 1 commit would overwrite the whole history)
fetch-depth: 2
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@ jobs:
runs-on: ubuntu-latest

steps:
- uses: shivammathur/setup-php@15c43e89cdef867065b0213be354c2841860869e
- uses: shivammathur/setup-php@v2
with:
php-version: '8.1'
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- name: Install Dependencies
run: composer install -q --no-ansi --no-interaction --no-scripts --no-progress --prefer-dist
- name: Execute tests (Unit and Feature tests) via PHPUnit
Expand Down
9 changes: 5 additions & 4 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,16 @@
"require": {
"php": ">=8.1",
"ext-json": "*",
"cebe/php-openapi": "^1.7",
"devizzent/cebe-php-openapi": "^1.0",
"fakerphp/faker": "^1.0",
"laravel/framework": "^7.0 || ^8.0 || ^9.0 || ^10.0",
"laravel/framework": "^7.0 || ^8.0 || ^9.0 || ^10.0 || ^11.0",
"phpdocumentor/reflection-docblock": "^5.2"
},
"require-dev": {
"laravel/pint": "^1.5",
"nunomaduro/larastan": "^2.4",
"orchestra/testbench": "^6.6 || ^7.0 || ^8.0"
"larastan/larastan": "^2.4",
"orchestra/testbench": "^9.0",
"phpunit/phpunit": "^11.0"
},
"autoload-dev": {
"psr-4": {
Expand Down
2 changes: 1 addition & 1 deletion phpstan.neon
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
includes:
- %currentWorkingDirectory%/vendor/nunomaduro/larastan/extension.neon
- %currentWorkingDirectory%/vendor/larastan/larastan/extension.neon
- phpstan-baseline.neon

parameters:
Expand Down
11 changes: 4 additions & 7 deletions tests/GeneratorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
use Intermax\LaravelOpenApi\Tests\Utilities\ResourceInput\PetController;
use Intermax\LaravelOpenApi\Tests\Utilities\ResourceInput\ThingController;
use Orchestra\Testbench\TestCase;
use PHPUnit\Framework\Attributes\Test;

class GeneratorTest extends TestCase
{
Expand All @@ -22,9 +23,7 @@ protected function setUp(): void
parent::setUp();
}

/**
* @test
*/
#[Test]
public function it_generates_open_api_spec_for_route()
{
/** @var Generator $generator */
Expand All @@ -36,9 +35,7 @@ public function it_generates_open_api_spec_for_route()
$this->assertEquals('postThings', $spec['paths']['/things']['post']['operationId'] ?? null);
}

/**
* @test
*/
#[Test]
public function it_generates_distinct_operation_ids_with_nested_routes()
{
/** @var Generator $generator */
Expand All @@ -49,7 +46,7 @@ public function it_generates_distinct_operation_ids_with_nested_routes()
$this->assertEquals('postPetOwner', Arr::get($spec, 'paths./pets/{pet}/owner.post.operationId'));
}

/** @test */
#[Test]
public function it_generates_distinct_get_operation_ids()
{
/** @var Generator $generator */
Expand Down
9 changes: 3 additions & 6 deletions tests/QueryParameters/QueryParameterCreatorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,11 @@
use Intermax\LaravelOpenApi\Generator\Parameters\QueryParametersCreator;
use Intermax\LaravelOpenApi\Tests\QueryParameters\Utilities\ThingCollectionRequest;
use Orchestra\Testbench\TestCase;
use PHPUnit\Framework\Attributes\Test;

class QueryParameterCreatorTest extends TestCase
{
/**
* @test
*/
#[Test]
public function it_creates_query_parameters_based_on_a_form_request_class()
{
/** @var QueryParametersCreator $creator */
Expand All @@ -25,9 +24,7 @@ public function it_creates_query_parameters_based_on_a_form_request_class()
$this->assertTrue(in_array('include', $names));
}

/**
* @test
*/
#[Test]
public function it_adds_an_enum_to_query_parameters_with_options()
{
/** @var QueryParametersCreator $creator */
Expand Down
5 changes: 2 additions & 3 deletions tests/RequestBody/RequestBodyCreatorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,11 @@
use Intermax\LaravelOpenApi\Generator\RequestBodyCreator;
use Intermax\LaravelOpenApi\Tests\QueryParameters\Utilities\ThingCollectionRequest;
use Orchestra\Testbench\TestCase;
use PHPUnit\Framework\Attributes\Test;

class RequestBodyCreatorTest extends TestCase
{
/**
* @test
*/
#[Test]
public function it_omits_query_parameters_from_request_body()
{
/** @var RequestBodyCreator $creator */
Expand Down
8 changes: 2 additions & 6 deletions tests/ResponseDiscoveryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@

namespace Intermax\LaravelOpenApi\Tests;

use cebe\openapi\exceptions\TypeErrorException;
use Illuminate\Routing\Router;
use Illuminate\Support\Arr;
use Intermax\LaravelOpenApi\Generator\Generator;
use Intermax\LaravelOpenApi\OpenApiServiceProvider;
use Intermax\LaravelOpenApi\Tests\Utilities\ResourceInput\ThingController;
use Orchestra\Testbench\TestCase;
use PHPUnit\Framework\Attributes\Test;

class ResponseDiscoveryTest extends TestCase
{
Expand All @@ -22,11 +22,7 @@ protected function setUp(): void
parent::setUp();
}

/**
* @test
*
* @throws TypeErrorException
*/
#[Test]
public function it_can_map_a_resource_with_openapi_types_through_response_discovery()
{
/** @var Generator $generator */
Expand Down
8 changes: 2 additions & 6 deletions tests/ResponseMappingTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@

namespace Intermax\LaravelOpenApi\Tests;

use cebe\openapi\exceptions\TypeErrorException;
use Illuminate\Routing\Router;
use Intermax\LaravelOpenApi\Generator\Generator;
use Intermax\LaravelOpenApi\OpenApiServiceProvider;
use Intermax\LaravelOpenApi\Tests\Utilities\Mapping\ThingController;
use Intermax\LaravelOpenApi\Tests\Utilities\Mapping\ThingMapper;
use Orchestra\Testbench\TestCase;
use PHPUnit\Framework\Attributes\Test;

class ResponseMappingTest extends TestCase
{
Expand All @@ -22,11 +22,7 @@ protected function setUp(): void
parent::setUp();
}

/**
* @test
*
* @throws TypeErrorException
*/
#[Test]
public function it_can_map_resource_with_a_mapper_class()
{
/** @var Generator $generator */
Expand Down

0 comments on commit 47d10f5

Please sign in to comment.