Skip to content

Commit

Permalink
Add Laravel 11 support on tests (#1261)
Browse files Browse the repository at this point in the history
* Add Laravel 11 Support on tests

Include **Laravel 11** and **PHP 8.3** on the test matrix

* Update run-tests.yml

Test with old testbench version

* Update run-tests.yml

Restore to testbench 9.* for Laravel 11

* Update run-tests.yml

Test with old ocular.phar

* Update composer.json

Remove ocular form dev dependencies

* Update FormComponentsTest.php

Test fix on setLaravelSession()

* Update run-tests.yml

Migrate phpunit config before running test

* Update run-tests.yml

* Update run-tests.yml

Test again

* Improve commentaries on run-tests workflow

* Update run-tests.yml
  • Loading branch information
dfsmania authored Mar 18, 2024
1 parent 21b94f6 commit 17d9f1a
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 9 deletions.
34 changes: 28 additions & 6 deletions .github/workflows/run-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ jobs:
strategy:
fail-fast: true
matrix:
php: [7.3, 7.4, 8.0, 8.1, 8.2]
laravel: [7.*, 8.*, 9.*, 10.*]
php: [7.3, 7.4, 8.0, 8.1, 8.2, 8.3]
laravel: [7.*, 8.*, 9.*, 10.*, 11.*]
stability: [prefer-lowest, prefer-stable]
include:
- laravel: 7.*
Expand All @@ -21,13 +21,19 @@ jobs:
testbench: 7.*
- laravel: 10.*
testbench: 8.*
- laravel: 11.*
testbench: 9.*
exclude:
- laravel: 7.*
php: 8.1
- laravel: 7.*
php: 8.2
- laravel: 7.*
php: 8.3
- laravel: 8.*
php: 8.2
- laravel: 8.*
php: 8.3
- laravel: 9.*
php: 7.3
- laravel: 9.*
Expand All @@ -38,41 +44,57 @@ jobs:
php: 7.4
- laravel: 10.*
php: 8.0
- laravel: 11.*
php: 7.3
- laravel: 11.*
php: 7.4
- laravel: 11.*
php: 8.0
- laravel: 11.*
php: 8.1

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

steps:

# Checkout the package code.
- name: Checkout code
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
ref: ${{ github.event.pull_request.head.sha }}
fetch-depth: 0

# Cache dependencies and build outputs to improve workflow execution time.
- name: Cache dependencies
uses: actions/cache@v3
uses: actions/cache@v4
with:
path: ~/.composer/cache/files
key: dependencies-laravel-${{ matrix.laravel }}-php-${{ matrix.php }}-composer-${{ hashFiles('composer.json') }}

# Setup PHP and extensions.
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php }}
extensions: curl, mbstring, zip, pcntl, pdo, sqlite, pdo_sqlite, iconv
coverage: xdebug

# Install the package dependencies.
- name: Install dependencies
run: |
composer require "laravel/framework:${{ matrix.laravel }}" "orchestra/testbench:${{ matrix.testbench }}" "nesbot/carbon:>=2.62.1" --no-interaction --no-update
composer update --${{ matrix.stability }} --prefer-dist --no-interaction
# Test suite for Laravel.
# Execute the test suite for Laravel.
- name: Execute Laravel tests
run: vendor/bin/phpunit --testsuite Laravel

# Upload coverage only for latest versions.
# Upload code coverage to Scrutinizer CI, only for specific version.
- name: Upload coverage to scrutinizer-ci
if: matrix.php == '8.2' && matrix.laravel == '10.*' && matrix.stability == 'prefer-stable'
run: |
composer require scrutinizer/ocular
cp phpunit.xml.dist phpunit.xml
vendor/bin/phpunit --migrate-configuration
vendor/bin/phpunit --testsuite Laravel --coverage-clover=coverage.clover
vendor/bin/ocular code-coverage:upload --format=php-clover coverage.clover
3 changes: 1 addition & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@
},
"require-dev": {
"phpunit/phpunit": ">=9.1",
"orchestra/testbench": ">=4.0",
"scrutinizer/ocular": "^1.9"
"orchestra/testbench": ">=4.0"
}
}
2 changes: 1 addition & 1 deletion tests/Components/FormComponentsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ protected function addErrorOnSessionFor($key)
protected function addInputOnCurrentRequest($key, $val)
{
session()->flashInput([$key => $val]);
request()->setLaravelsession(session());
request()->setLaravelsession(session()->driver());
}

/*
Expand Down

0 comments on commit 17d9f1a

Please sign in to comment.