Skip to content

Commit

Permalink
Laravel 11 Support
Browse files Browse the repository at this point in the history
  • Loading branch information
SupianIDz committed Apr 1, 2024
1 parent 6a3e376 commit c6c4477
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 19 deletions.
20 changes: 8 additions & 12 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,34 +13,30 @@ jobs:

strategy:
matrix:
php: [ 8.1, 8.2 ]
laravel: [ '^10.0' ]
php: [ 8.1, 8.2, 8.3 ]
laravel: [ '10.*', '11.*' ]
exclude:
- php: 8.1
laravel: '11.*'

name: PHP ${{ matrix.php }} - LARAVEL ${{ matrix.laravel }}

steps:
- name: Checkout Code
uses: actions/checkout@v2

- name: Cache Dependencies
uses: actions/cache@v1
with:
path: ~/.composer/cache/files
key: dependencies-php-${{ matrix.php }}-composer-${{ hashFiles('composer.json') }}
uses: actions/checkout@v4

- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php }}
extensions: dom, libxml, mbstring, zip, pdo, sqlite, pdo_sqlite
tools: composer:v2
extensions: dom, curl, mbstring, zip, pdo, sqlite, pdo_sqlite, iconv
coverage: none

- name: Install Dependencies

run: |
composer require "laravel/framework:${{ matrix.laravel }}" --no-interaction --no-update
composer update --prefer-dist
composer update --prefer-dist --no-interaction
- name: Execute Tests
run: vendor/bin/phpunit --colors=always
Binary file removed bun.lockb
Binary file not shown.
11 changes: 6 additions & 5 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,16 @@
"authors": [
{
"name": "Supian M",
"email": "supianidz@gmail.com"
"email": "supianidz@octopy.dev"
}
],
"require": {
"php": "^8.1"
"php": "^8.1",
"illuminate/contracts": "^10.0|^11.0"
},
"require-dev": {
"nunomaduro/collision": "^7.8",
"orchestra/testbench": "^8.11"
"nunomaduro/collision": "^7.8|^8.0",
"orchestra/testbench": "^8.11|^9.0"
},
"autoload": {
"psr-4": {
Expand All @@ -40,7 +41,7 @@
}
},
"scripts": {
"test": "vendor/bin/testbench package:test"
"test": "vendor/bin/phpunit"
},
"config": {
"sort-packages": true
Expand Down
25 changes: 23 additions & 2 deletions tests/TestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,26 @@ class TestCase extends \Orchestra\Testbench\TestCase
{
use RefreshDatabase;

/**
* @var string
*/
protected string $database;

/**
* @var Impersonate
*/
protected Impersonate $impersonate;

/**
* @param string $name
*/
public function __construct(string $name)
{
parent::__construct($name);

$this->database = __DIR__ . '/../database/database.sqlite';
}

/**
* @return void
*/
Expand All @@ -36,11 +51,18 @@ protected function setUp() : void
*/
protected function defineDatabaseMigrations() : void
{
if (! file_exists($this->database)) {
touch($this->database);
}

$this->artisan('migrate', ['--database' => 'testbench'])->run();

$this->loadMigrationsFrom(__DIR__ . '/../database/migrations');
$this->beforeApplicationDestroyed(function () {
$this->artisan('migrate:rollback', ['--database' => 'testbench'])->run();
if (file_exists($this->database)) {
unlink($this->database);
}
});
}

Expand All @@ -53,8 +75,7 @@ protected function defineEnvironment($app) : void
$app['config']->set('database.default', 'testbench');
$app['config']->set('database.connections.testbench', [
'driver' => 'sqlite',
'database' => ':memory:',
'prefix' => '',
'database' => __DIR__ . '/../database/database.sqlite',
]);
}

Expand Down

0 comments on commit c6c4477

Please sign in to comment.