From 8a851a46873b0fdd82145e56c8e3b71576e60ecf Mon Sep 17 00:00:00 2001 From: Tim MacDonald Date: Mon, 20 Feb 2023 19:18:59 +1100 Subject: [PATCH] wip --- .github/workflows/main.yml | 77 +++++++++++++++----------------------- README.md | 2 +- composer.json | 16 ++++---- src/Concerns/Links.php | 2 + tests/Unit/LinkTest.php | 5 ++- 5 files changed, 45 insertions(+), 57 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 7b63927..dfe5ccd 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -14,12 +14,6 @@ jobs: - name: Checkout code uses: actions/checkout@v3 - - name: Setup PHP - uses: shivammathur/setup-php@v2 - with: - php-version: '8.1' - coverage: pcov - - name: Get composer cache directory id: composer-cache run: echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT @@ -31,15 +25,20 @@ jobs: key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.json') }} restore-keys: ${{ runner.os }}-composer- + - name: Setup PHP + uses: shivammathur/setup-php@v2 + with: + php-version: '8.1' + coverage: pcov + - name: Install dependencies - run: | - composer update --no-interaction --verbose + run: composer update - name: Check platform requirements - run: composer check-platform-reqs --verbose + run: composer check-platform-reqs - name: PHP-CS-Fixer - run: composer fix -- --dry-run --verbose + run: composer fix -- --dry-run # - name: composer normalize # run: composer normalize --dry-run --no-interaction --verbose @@ -67,33 +66,22 @@ jobs: tests: runs-on: ubuntu-latest - name: 'PHP: ${{ matrix.php }}; Lara: ${{ matrix.laravel }}; Deps: ${{ matrix.dependency-version }}' + name: 'PHP: ${{ matrix.php }}; Laravel: ${{ matrix.laravel }}; Prefer: ${{ matrix.prefer }}' strategy: matrix: - php: ['8.0', '8.1', '8.2'] - laravel: ['^8.73.2', '^9.0', '10.x-dev'] - dependency-version: ['prefer-lowest', 'prefer-stable'] + php: ['8.1', '8.2'] + laravel: ['^9.0', '^10.0'] + prefer: ['prefer-lowest', 'prefer-stable'] include: - - testbench: '^6.0' - laravel: '^8.73.2' - testbench: '^7.0' laravel: '^9.0' - - testbench: '8.x-dev' - laravel: '10.x-dev' - exclude: - - php: '8.0' - laravel: '10.x-dev' + - testbench: '^8.0' + laravel: '^10.0' steps: - name: checkout code uses: actions/checkout@v3 - - name: Setup PHP - uses: shivammathur/setup-php@v2 - with: - php-version: ${{ matrix.php }} - coverage: none - - name: Get composer cache directory id: composer-cache run: echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT @@ -101,40 +89,37 @@ jobs: - name: Cache dependencies uses: actions/cache@v3 with: - path: ${{ steps.composer-cache.outputs.dir }} - key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.json') }} - restore-keys: ${{ runner.os }}-composer- + path: ${{ steps.composer-cache.outputs.dir }} + key: ${{ runner.os }}-php-${{ matrix.php }}-laravel-${{ matrix.laravel }}-prefer-${{ matrix.prefer }}-composer-${{ hashFiles('**/composer.json') }} + restore-keys: ${{ runner.os }}-php-${{ matrix.php }}-laravel-{{ matrix.laravel }}-prefer-${{ matrix.prefer}}-composer- + + - name: Setup PHP + uses: shivammathur/setup-php@v2 + with: + php-version: ${{ matrix.php }} + coverage: none - name: Remove dev packages run: | - composer remove --dev --no-update --no-interaction --verbose \ + composer remove --dev --no-update \ friendsofphp/php-cs-fixer \ infection/infection \ nunomaduro/larastan \ phpstan/phpstan-strict-rules - name: Require Laravel and Testbench version - run: composer require laravel/framework:"${{ matrix.laravel }}" illuminate/collections:"${{ matrix.laravel }}" illuminate/database:"${{ matrix.laravel }}" illuminate/http:"${{ matrix.laravel }}" illuminate/support:"${{ matrix.laravel }}" orchestra/testbench:"${{ matrix.testbench }}" --no-update --no-interaction --verbose --with-all-dependencies - - - name: Support prefer-lowest in PHP 8.0 - if: ${{ matrix.php == 8.0 && matrix.dependency-version == 'prefer-lowest' }} - run: composer require --no-update \ - mockery/mockery:"^1.3.3" + run: composer require --no-update laravel/framework:"${{ matrix.laravel }}" illuminate/collections:"${{ matrix.laravel }}" illuminate/database:"${{ matrix.laravel }}" illuminate/http:"${{ matrix.laravel }}" illuminate/support:"${{ matrix.laravel }}" orchestra/testbench:"${{ matrix.testbench }}" - name: Support prefer-lowest in PHP 8.1 - if: ${{ matrix.php == 8.1 && matrix.dependency-version == 'prefer-lowest' }} - run: composer require --no-update \ - nesbot/carbon:"^2.62.1" \ - symfony/http-foundation:"^5.3.7 || ^6.0" + if: ${{ matrix.php == 8.1 && matrix.prefer == 'prefer-lowest' }} + run: composer require --no-update nesbot/carbon:"^2.62.1" - name: Support prefer-lowest in PHP 8.2 - if: ${{ matrix.php == 8.2 && matrix.dependency-version == 'prefer-lowest' }} - run: composer require --no-update \ - nesbot/carbon:"^2.62.1" \ - symfony/http-foundation:"^5.3.7 || ^6.0" + if: ${{ matrix.php == 8.2 && matrix.prefer == 'prefer-lowest' }} + run: composer require --no-update nesbot/carbon:"^2.62.1" - name: Install dependencies - run: composer update --${{ matrix.dependency-version }} --no-interaction --verbose + run: composer update --${{ matrix.prefer }} - name: Check platform requirements run: composer check-platform-reqs --verbose diff --git a/README.md b/README.md index c799290..90c2166 100644 --- a/README.md +++ b/README.md @@ -26,7 +26,7 @@ A lightweight API resource for Laravel that helps you adhere to the `JSON:API` s ## Version support -- **PHP**: `8.0`, `8.1`, `8.2` +- **PHP**: `8.1`, `8.2` - **Laravel**: `^8.73.2`, `^9.0`, `10.x-dev` ## Installation diff --git a/composer.json b/composer.json index 09e3a60..b45fc2d 100644 --- a/composer.json +++ b/composer.json @@ -17,18 +17,18 @@ } ], "require": { - "php": "^8.0 || ^8.1 || ^8.2", - "illuminate/collections": "^8.73.2 || ^9.0 || 10.x-dev", - "illuminate/database": "^8.73.2 || ^9.0 || 10.x-dev|^10.0", - "illuminate/http": "^8.73.2 || ^9.0 || 10.x-dev|^10.0", - "illuminate/support": "^8.73.2 || ^9.0 || 10.x-dev|^10.0", - "symfony/http-kernel": "^5.0 || ^6.0" + "php": "^8.1 || ^8.2", + "illuminate/collections": "^9.0 || ^10.0", + "illuminate/database": "^9.0 || ^10.0", + "illuminate/http": "^9.0 || ^10.0", + "illuminate/support": "^9.0 || ^10.0", + "symfony/http-kernel": "^6.0" }, "require-dev": { "friendsofphp/php-cs-fixer": "^3.13", - "laravel/framework": "^8.73.2 || ^9.0 || 10.x-dev|^10.0", + "laravel/framework": "^9.0 || ^10.0", "opis/json-schema": "^2.3", - "orchestra/testbench": "^6.0 || ^7.0 || 8.x-dev|^8.0", + "orchestra/testbench": "^7.0 || ^8.0", "phpunit/phpunit": "^9.0" }, "config": { diff --git a/src/Concerns/Links.php b/src/Concerns/Links.php index 647e8b6..5bb1cf2 100644 --- a/src/Concerns/Links.php +++ b/src/Concerns/Links.php @@ -7,6 +7,8 @@ use Illuminate\Support\Collection; use TiMacDonald\JsonApi\Link; +use function is_string; + trait Links { /** diff --git a/tests/Unit/LinkTest.php b/tests/Unit/LinkTest.php index 9e51116..4af0b66 100644 --- a/tests/Unit/LinkTest.php +++ b/tests/Unit/LinkTest.php @@ -4,11 +4,9 @@ namespace Tests\Unit; -use Illuminate\Container\Container; use Illuminate\Http\Request; use PHPUnit\Framework\TestCase; use Tests\Resources\BasicJsonApiResource; -use TiMacDonald\JsonApi\Concerns\Links; use TiMacDonald\JsonApi\JsonApiResource; use TiMacDonald\JsonApi\Link; @@ -73,5 +71,8 @@ public function testItCanUseHash() $links = json_encode($resource->toArray($request)['links']); $this->assertSame('{"foo":{"href":"http:\/\/foo.com","meta":{}}}', $links); + + JsonApiResource::resolveIdNormally(); + JsonApiResource::resolveTypeNormally(); } }