Skip to content

Commit 1cc5359

Browse files
authored
Merge pull request #8 from swisnl/feature/laravel-11
Add support for Laravel 11
2 parents d98df6b + f6f7218 commit 1cc5359

7 files changed

+81
-31
lines changed

.github/workflows/tests.yml

+30-10
Original file line numberDiff line numberDiff line change
@@ -9,18 +9,37 @@ jobs:
99
strategy:
1010
fail-fast: false
1111
matrix:
12-
php: [ '7.4', '8.0', '8.1', '8.2' ]
13-
laravel: [ '8.*', '9.*', '10.*' ]
12+
php: [ 7.4, '8.0', 8.1, 8.2, 8.3 ]
13+
laravel: [ 8.*, 9.*, 10.*, 11.* ]
1414
stability: [ prefer-stable ]
1515
exclude:
16-
- laravel: '8.*'
17-
php: '8.2'
18-
- laravel: '9.*'
19-
php: '7.4'
20-
- laravel: '10.*'
21-
php: '7.4'
22-
- laravel: '10.*'
16+
- laravel: 8.*
17+
php: 8.2
18+
- laravel: 8.*
19+
php: 8.3
20+
- laravel: 9.*
21+
php: 7.4
22+
- laravel: 9.*
23+
php: 8.3
24+
- laravel: 10.*
25+
php: 7.4
26+
- laravel: 10.*
2327
php: '8.0'
28+
- laravel: 11.*
29+
php: 7.4
30+
- laravel: 11.*
31+
php: '8.0'
32+
- laravel: 11.*
33+
php: 8.1
34+
include:
35+
- laravel: 8.*
36+
phpunit: ^9.5
37+
- laravel: 9.*
38+
phpunit: ^9.5
39+
- laravel: 10.*
40+
phpunit: ^10.5
41+
- laravel: 11.*
42+
phpunit: ^10.5
2443

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

@@ -52,10 +71,11 @@ jobs:
5271
- name: Install dependencies
5372
run: |
5473
composer require "illuminate/contracts:${{ matrix.laravel }}" --no-interaction --no-update
74+
composer require "phpunit/phpunit:${{ matrix.phpunit }}" --dev --no-interaction --no-update
5575
composer update --${{ matrix.stability }} --prefer-dist --no-interaction
5676
5777
- name: Execute tests
58-
run: XDEBUG_MODE=coverage vendor/bin/phpunit --coverage-text --coverage-clover=coverage.clover
78+
run: XDEBUG_MODE=coverage vendor/bin/phpunit --configuration=${{ matrix.phpunit == '^9.5' && 'phpunit-9.xml' || 'phpunit.xml' }} --coverage-text --coverage-clover=coverage.clover
5979

6080
- name: Upload Scrutinizer coverage
6181
uses: sudo-bot/action-scrutinizer@latest

composer.json

+3-3
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,15 @@
44
"description": "A PHP package for mapping remote JSON:API resources to Eloquent like models and collections.",
55
"require": {
66
"php": "^7.4|^8.0",
7-
"illuminate/support": "^8.0|^9.0|^10.0",
7+
"illuminate/support": "^8.0|^9.0|^10.0|^11.0",
88
"swisnl/json-api-client": "^2.0"
99
},
1010
"require-dev": {
1111
"friendsofphp/php-cs-fixer": "^3.0",
1212
"guzzlehttp/guzzle": "^7.3",
1313
"guzzlehttp/psr7": "^2.1",
14-
"orchestra/testbench": "^6.15|^7.0|^8.0",
15-
"phpunit/phpunit": "^9.5"
14+
"orchestra/testbench": "^6.15|^7.0|^8.0|^9.0",
15+
"phpunit/phpunit": "^9.5|^10.5"
1616
},
1717
"autoload": {
1818
"psr-4": {

phpunit-9.xml

+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
3+
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/6.2/phpunit.xsd"
4+
backupGlobals="false"
5+
backupStaticAttributes="false"
6+
colors="true"
7+
bootstrap="vendor/autoload.php"
8+
convertErrorsToExceptions="true"
9+
convertNoticesToExceptions="true"
10+
convertWarningsToExceptions="true"
11+
processIsolation="false"
12+
stopOnFailure="false">
13+
<testsuites>
14+
<testsuite name="tests">
15+
<directory suffix="Test.php">./tests</directory>
16+
</testsuite>
17+
</testsuites>
18+
<filter>
19+
<whitelist processUncoveredFilesFromWhitelist="true">
20+
<directory suffix=".php">./src</directory>
21+
</whitelist>
22+
</filter>
23+
</phpunit>

phpunit.xml

+7-9
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,21 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
3-
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/6.2/phpunit.xsd"
3+
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/10.5/phpunit.xsd"
44
backupGlobals="false"
5-
backupStaticAttributes="false"
5+
backupStaticProperties="false"
66
colors="true"
77
bootstrap="vendor/autoload.php"
8-
convertErrorsToExceptions="true"
9-
convertNoticesToExceptions="true"
10-
convertWarningsToExceptions="true"
8+
cacheDirectory=".phpunit.cache"
119
processIsolation="false"
1210
stopOnFailure="false">
1311
<testsuites>
1412
<testsuite name="tests">
1513
<directory suffix="Test.php">./tests</directory>
1614
</testsuite>
1715
</testsuites>
18-
<filter>
19-
<whitelist processUncoveredFilesFromWhitelist="true">
16+
<source>
17+
<include>
2018
<directory suffix=".php">./src</directory>
21-
</whitelist>
22-
</filter>
19+
</include>
20+
</source>
2321
</phpunit>

tests/AbstractTest.php tests/AbstractTestCase.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
use Orchestra\Testbench\TestCase;
88
use Swis\JsonApi\Client\Providers\ServiceProvider;
99

10-
abstract class AbstractTest extends TestCase
10+
abstract class AbstractTestCase extends TestCase
1111
{
1212
/**
1313
* Define environment setup.

tests/Providers/ServiceProviderTest.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,9 @@
77
use Illuminate\Http\Client\Request;
88
use Illuminate\Support\Facades\Http;
99
use Swis\JsonApi\Client\Document;
10-
use Swis\JsonApi\Client\Tests\AbstractTest;
10+
use Swis\JsonApi\Client\Tests\AbstractTestCase;
1111

12-
class ServiceProviderTest extends AbstractTest
12+
class ServiceProviderTest extends AbstractTestCase
1313
{
1414
protected function setUp(): void
1515
{

tests/Providers/TypeMapperServiceProviderTest.php

+15-6
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,13 @@
44

55
namespace Swis\JsonApi\Client\Tests\Providers;
66

7-
use Swis\JsonApi\Client\Tests\AbstractTest;
7+
use Swis\JsonApi\Client\Tests\AbstractTestCase;
88
use Swis\JsonApi\Client\Tests\Mocks\Items\ChildItem;
99
use Swis\JsonApi\Client\Tests\Mocks\Items\ParentItem;
1010
use Swis\JsonApi\Client\Tests\Mocks\MockTypeMapperServiceProvider;
1111
use Swis\JsonApi\Client\TypeMapper;
1212

13-
class TypeMapperServiceProviderTest extends AbstractTest
13+
class TypeMapperServiceProviderTest extends AbstractTestCase
1414
{
1515
/**
1616
* @test
@@ -21,10 +21,19 @@ public function itRegistersTypesWithTheTypeMapper()
2121
$typeMapper = $this->createMock(TypeMapper::class);
2222
$typeMapper->expects($this->exactly(2))
2323
->method('setMapping')
24-
->withConsecutive(
25-
['child', ChildItem::class],
26-
['parent', ParentItem::class]
27-
);
24+
->willReturnCallback(function (string $type, string $class) {
25+
static $i = 0;
26+
switch (++$i) {
27+
case 1:
28+
$this->assertEquals('child', $type);
29+
$this->assertEquals(ChildItem::class, $class);
30+
break;
31+
case 2:
32+
$this->assertEquals('parent', $type);
33+
$this->assertEquals(ParentItem::class, $class);
34+
break;
35+
}
36+
});
2837

2938
$provider->boot($typeMapper);
3039
}

0 commit comments

Comments
 (0)