Skip to content

Commit

Permalink
Laravel 11.x Compatibility (#23)
Browse files Browse the repository at this point in the history
  • Loading branch information
enricodelazzari authored Mar 27, 2024
1 parent e0864f2 commit ad5f68e
Show file tree
Hide file tree
Showing 9 changed files with 47 additions and 95 deletions.
9 changes: 8 additions & 1 deletion .github/workflows/run-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,12 @@ jobs:
matrix:
os: [ubuntu-latest, windows-latest]
php: [8.3, 8.2, 8.1, 8.0]
laravel: [10.*, 9.*]
laravel: [11.*, 10.*, 9.*]
stability: [prefer-lowest, prefer-stable]
include:
- laravel: 11.*
testbench: 9.*
carbon: ^3.0
- laravel: 10.*
testbench: 8.*
carbon: ^2.63
Expand All @@ -26,6 +29,10 @@ jobs:
exclude:
- laravel: 10.*
php: 8.0
- laravel: 11.*
php: 8.1
- laravel: 11.*
php: 8.0

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

Expand Down
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,5 @@ testbench.yaml
vendor
node_modules
.php-cs-fixer.cache
.phpunit.cache
.phpunit.cache/test-results
2 changes: 1 addition & 1 deletion LICENSE.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
The MIT License (MIT)

Copyright (c) 2023 MAIZE SRL <[email protected]>
Copyright (c) 2024 MAIZE SRL <[email protected]>

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
14 changes: 7 additions & 7 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,17 +19,17 @@
"require": {
"php": "^8.0",
"ext-json": "*",
"illuminate/database": "^9.0|^10.0",
"illuminate/http": "^9.0|^10.0",
"illuminate/routing": "^9.0|^10.0",
"illuminate/support": "^9.0|^10.0",
"illuminate/database": "^9.0|^10.0|^11.0",
"illuminate/http": "^9.0|^10.0|^11.0",
"illuminate/routing": "^9.0|^10.0|^11.0",
"illuminate/support": "^9.0|^10.0|^11.0",
"spatie/laravel-package-tools": "^1.14.1"
},
"require-dev": {
"friendsofphp/php-cs-fixer": "^3.4",
"orchestra/testbench": "^7.0|^8.0",
"phpunit/phpunit": "^9.5",
"vimeo/psalm": "^4.20"
"orchestra/testbench": "^7.0|^8.0|^9.0",
"phpunit/phpunit": "^9.5|^10.5",
"vimeo/psalm": "^4.20|^5.22"
},
"autoload": {
"psr-4": {
Expand Down
16 changes: 0 additions & 16 deletions database/migrations/create_admins_table.php.stub

This file was deleted.

4 changes: 2 additions & 2 deletions database/migrations/create_legal_consent_tables.php.stub
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

class CreateLegalConsentTables extends Migration
return new class extends Migration
{
public function up()
{
Expand All @@ -29,4 +29,4 @@ class CreateLegalConsentTables extends Migration
Schema::dropIfExists('legal_consents');
Schema::dropIfExists('legal_documents');
}
}
};
16 changes: 0 additions & 16 deletions database/migrations/create_users_table.php.stub

This file was deleted.

51 changes: 14 additions & 37 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
@@ -1,39 +1,16 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="vendor/phpunit/phpunit/phpunit.xsd"
backupGlobals="false"
backupStaticAttributes="false"
bootstrap="vendor/autoload.php"
colors="true"
convertErrorsToExceptions="true"
convertNoticesToExceptions="true"
convertWarningsToExceptions="true"
processIsolation="false"
stopOnFailure="false"
executionOrder="random"
failOnWarning="true"
failOnRisky="true"
failOnEmptyTestSuite="true"
beStrictAboutOutputDuringTests="true"
verbose="true"
>
<testsuites>
<testsuite name="Maize Test Suite">
<directory>tests</directory>
</testsuite>
</testsuites>
<coverage>
<include>
<directory suffix=".php">./src</directory>
</include>
<report>
<html outputDirectory="build/coverage"/>
<text outputFile="build/coverage.txt"/>
<clover outputFile="build/logs/clover.xml"/>
</report>
</coverage>
<logging>
<junit outputFile="build/report.junit.xml"/>
</logging>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/10.5/phpunit.xsd" backupGlobals="false" bootstrap="vendor/autoload.php" colors="true" processIsolation="false" stopOnFailure="false" executionOrder="random" failOnWarning="true" failOnRisky="true" failOnEmptyTestSuite="true" beStrictAboutOutputDuringTests="true" cacheDirectory=".phpunit.cache" backupStaticProperties="false">
<testsuites>
<testsuite name="Maize Test Suite">
<directory>tests</directory>
</testsuite>
</testsuites>
<logging>
<junit outputFile="build/report.junit.xml"/>
</logging>
<source>
<include>
<directory suffix=".php">./src</directory>
</include>
</source>
</phpunit>
28 changes: 13 additions & 15 deletions tests/TestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,13 @@
namespace Maize\LegalConsent\Tests;

use Illuminate\Database\Eloquent\Factories\Factory;
use Illuminate\Foundation\Testing\RefreshDatabase;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
use Maize\LegalConsent\LegalConsentServiceProvider;
use Orchestra\Testbench\TestCase as Orchestra;

class TestCase extends Orchestra
{
use RefreshDatabase;

public function setUp(): void
{
parent::setUp();
Expand All @@ -29,12 +28,7 @@ protected function getPackageProviders($app)

public function getEnvironmentSetUp($app)
{
config()->set('database.default', 'sqlite');
config()->set('database.connections.sqlite', [
'driver' => 'sqlite',
'database' => ':memory:',
'prefix' => '',
]);
config()->set('database.default', 'testing');

config()->set('auth.guards', [
'web' => [
Expand All @@ -53,14 +47,18 @@ public function getEnvironmentSetUp($app)
'type2',
]);

include_once __DIR__.'/../database/migrations/create_users_table.php.stub';
(new \CreateUsersTable())->up();
Schema::create('users', function (Blueprint $table) {
$table->bigIncrements('id');
$table->timestamps();
});

include_once __DIR__.'/../database/migrations/create_admins_table.php.stub';
(new \CreateAdminsTable())->up();
Schema::create('admins', function (Blueprint $table) {
$table->bigIncrements('id');
$table->timestamps();
});

include_once __DIR__.'/../database/migrations/create_legal_consent_tables.php.stub';
(new \CreateLegalConsentTables())->up();
$migration = include __DIR__.'/../database/migrations/create_legal_consent_tables.php.stub';
$migration->up();
}

public function getRouteByPartialName(string $name, ...$args)
Expand Down

0 comments on commit ad5f68e

Please sign in to comment.