Skip to content

Commit

Permalink
Merge pull request #8 from swisnl/feature/laravel-11
Browse files Browse the repository at this point in the history
Add support for Laravel 11
  • Loading branch information
JaZo authored Mar 5, 2024
2 parents d98df6b + f6f7218 commit 1cc5359
Show file tree
Hide file tree
Showing 7 changed files with 81 additions and 31 deletions.
40 changes: 30 additions & 10 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,18 +9,37 @@ jobs:
strategy:
fail-fast: false
matrix:
php: [ '7.4', '8.0', '8.1', '8.2' ]
laravel: [ '8.*', '9.*', '10.*' ]
php: [ 7.4, '8.0', 8.1, 8.2, 8.3 ]
laravel: [ 8.*, 9.*, 10.*, 11.* ]
stability: [ prefer-stable ]
exclude:
- laravel: '8.*'
php: '8.2'
- laravel: '9.*'
php: '7.4'
- laravel: '10.*'
php: '7.4'
- laravel: '10.*'
- laravel: 8.*
php: 8.2
- laravel: 8.*
php: 8.3
- laravel: 9.*
php: 7.4
- laravel: 9.*
php: 8.3
- laravel: 10.*
php: 7.4
- laravel: 10.*
php: '8.0'
- laravel: 11.*
php: 7.4
- laravel: 11.*
php: '8.0'
- laravel: 11.*
php: 8.1
include:
- laravel: 8.*
phpunit: ^9.5
- laravel: 9.*
phpunit: ^9.5
- laravel: 10.*
phpunit: ^10.5
- laravel: 11.*
phpunit: ^10.5

name: P${{ matrix.php }} - L${{ matrix.laravel }} - ${{ matrix.stability }}

Expand Down Expand Up @@ -52,10 +71,11 @@ jobs:
- name: Install dependencies
run: |
composer require "illuminate/contracts:${{ matrix.laravel }}" --no-interaction --no-update
composer require "phpunit/phpunit:${{ matrix.phpunit }}" --dev --no-interaction --no-update
composer update --${{ matrix.stability }} --prefer-dist --no-interaction
- name: Execute tests
run: XDEBUG_MODE=coverage vendor/bin/phpunit --coverage-text --coverage-clover=coverage.clover
run: XDEBUG_MODE=coverage vendor/bin/phpunit --configuration=${{ matrix.phpunit == '^9.5' && 'phpunit-9.xml' || 'phpunit.xml' }} --coverage-text --coverage-clover=coverage.clover

- name: Upload Scrutinizer coverage
uses: sudo-bot/action-scrutinizer@latest
Expand Down
6 changes: 3 additions & 3 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,15 @@
"description": "A PHP package for mapping remote JSON:API resources to Eloquent like models and collections.",
"require": {
"php": "^7.4|^8.0",
"illuminate/support": "^8.0|^9.0|^10.0",
"illuminate/support": "^8.0|^9.0|^10.0|^11.0",
"swisnl/json-api-client": "^2.0"
},
"require-dev": {
"friendsofphp/php-cs-fixer": "^3.0",
"guzzlehttp/guzzle": "^7.3",
"guzzlehttp/psr7": "^2.1",
"orchestra/testbench": "^6.15|^7.0|^8.0",
"phpunit/phpunit": "^9.5"
"orchestra/testbench": "^6.15|^7.0|^8.0|^9.0",
"phpunit/phpunit": "^9.5|^10.5"
},
"autoload": {
"psr-4": {
Expand Down
23 changes: 23 additions & 0 deletions phpunit-9.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/6.2/phpunit.xsd"
backupGlobals="false"
backupStaticAttributes="false"
colors="true"
bootstrap="vendor/autoload.php"
convertErrorsToExceptions="true"
convertNoticesToExceptions="true"
convertWarningsToExceptions="true"
processIsolation="false"
stopOnFailure="false">
<testsuites>
<testsuite name="tests">
<directory suffix="Test.php">./tests</directory>
</testsuite>
</testsuites>
<filter>
<whitelist processUncoveredFilesFromWhitelist="true">
<directory suffix=".php">./src</directory>
</whitelist>
</filter>
</phpunit>
16 changes: 7 additions & 9 deletions phpunit.xml
Original file line number Diff line number Diff line change
@@ -1,23 +1,21 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/6.2/phpunit.xsd"
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/10.5/phpunit.xsd"
backupGlobals="false"
backupStaticAttributes="false"
backupStaticProperties="false"
colors="true"
bootstrap="vendor/autoload.php"
convertErrorsToExceptions="true"
convertNoticesToExceptions="true"
convertWarningsToExceptions="true"
cacheDirectory=".phpunit.cache"
processIsolation="false"
stopOnFailure="false">
<testsuites>
<testsuite name="tests">
<directory suffix="Test.php">./tests</directory>
</testsuite>
</testsuites>
<filter>
<whitelist processUncoveredFilesFromWhitelist="true">
<source>
<include>
<directory suffix=".php">./src</directory>
</whitelist>
</filter>
</include>
</source>
</phpunit>
2 changes: 1 addition & 1 deletion tests/AbstractTest.php → tests/AbstractTestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
use Orchestra\Testbench\TestCase;
use Swis\JsonApi\Client\Providers\ServiceProvider;

abstract class AbstractTest extends TestCase
abstract class AbstractTestCase extends TestCase
{
/**
* Define environment setup.
Expand Down
4 changes: 2 additions & 2 deletions tests/Providers/ServiceProviderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@
use Illuminate\Http\Client\Request;
use Illuminate\Support\Facades\Http;
use Swis\JsonApi\Client\Document;
use Swis\JsonApi\Client\Tests\AbstractTest;
use Swis\JsonApi\Client\Tests\AbstractTestCase;

class ServiceProviderTest extends AbstractTest
class ServiceProviderTest extends AbstractTestCase
{
protected function setUp(): void
{
Expand Down
21 changes: 15 additions & 6 deletions tests/Providers/TypeMapperServiceProviderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@

namespace Swis\JsonApi\Client\Tests\Providers;

use Swis\JsonApi\Client\Tests\AbstractTest;
use Swis\JsonApi\Client\Tests\AbstractTestCase;
use Swis\JsonApi\Client\Tests\Mocks\Items\ChildItem;
use Swis\JsonApi\Client\Tests\Mocks\Items\ParentItem;
use Swis\JsonApi\Client\Tests\Mocks\MockTypeMapperServiceProvider;
use Swis\JsonApi\Client\TypeMapper;

class TypeMapperServiceProviderTest extends AbstractTest
class TypeMapperServiceProviderTest extends AbstractTestCase
{
/**
* @test
Expand All @@ -21,10 +21,19 @@ public function itRegistersTypesWithTheTypeMapper()
$typeMapper = $this->createMock(TypeMapper::class);
$typeMapper->expects($this->exactly(2))
->method('setMapping')
->withConsecutive(
['child', ChildItem::class],
['parent', ParentItem::class]
);
->willReturnCallback(function (string $type, string $class) {
static $i = 0;
switch (++$i) {
case 1:
$this->assertEquals('child', $type);
$this->assertEquals(ChildItem::class, $class);
break;
case 2:
$this->assertEquals('parent', $type);
$this->assertEquals(ParentItem::class, $class);
break;
}
});

$provider->boot($typeMapper);
}
Expand Down

0 comments on commit 1cc5359

Please sign in to comment.