Skip to content

Commit 81f4d0b

Browse files
authored
Fix tests for Laravel 10 (#135)
2 parents d17ccbe + e1ef42d commit 81f4d0b

File tree

10 files changed

+142
-27
lines changed

10 files changed

+142
-27
lines changed

.github/workflows/tests.yml

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,9 +40,17 @@ jobs:
4040
experimental: false
4141
composer: v2
4242

43-
- deps: 'dev'
43+
- deps: 'stable'
4444
php: 8.2
45+
symfony: '6.x'
4546
laravel: '10.x'
47+
experimental: false
48+
composer: v2
49+
50+
- deps: 'dev'
51+
php: 8.3
52+
symfony: '6.x'
53+
laravel: '11.x'
4654
experimental: true
4755
composer: preview
4856

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,12 @@
11
Changelog
22
=========
33

4+
2.4.0
5+
-----
6+
7+
* Added Laravel 10 support
8+
* Dropped Symfony <5.4 support
9+
410
2.0.0
511
-----
612

composer.json

Lines changed: 19 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -7,32 +7,31 @@
77

88
"require": {
99
"php": "^7.3 || ^8.0",
10-
"illuminate/database": "^8.40 || ^9.0",
11-
"illuminate/events": "^8.12 || ^9.0",
12-
"illuminate/console": "^8.12 || ^9.0",
13-
"symfony/framework-bundle": "^4.4 || ^5.0 || ^6.0",
14-
"symfony/dependency-injection": "^4.4 || ^5.0 || ^6.0",
10+
"illuminate/database": "^8.40 || ^9.0 || ^10.0",
11+
"illuminate/events": "^8.12 || ^9.0 || ^10.0",
12+
"illuminate/console": "^8.12 || ^9.0 || ^10.0",
13+
"symfony/framework-bundle": "^5.4 || ^6.0",
14+
"symfony/dependency-injection": "^5.4 || ^6.0",
1515
"jdorn/sql-formatter": "^1.2.17"
1616
},
1717
"require-dev": {
1818
"doctrine/annotations": "1.*",
1919
"symfony/maker-bundle": "^1.20",
2020
"mockery/mockery": "^1.3",
21-
"symfony/console": "^4.4 || ^5.0 || ^6.0",
22-
"symfony/event-dispatcher": "^4.4 || ^5.0 || ^6.0",
23-
"symfony/http-kernel": "^4.4 || ^5.0 || ^6.0",
24-
"symfony/finder": "^4.4 || ^5.0 || ^6.0",
25-
"symfony/debug": "^4.4 || ^5.0 || ^6.0",
26-
"symfony/yaml": "^4.4 || ^5.0 || ^6.0",
27-
"symfony/form": "^4.4 || ^5.0 || ^6.0",
28-
"symfony/phpunit-bridge": "^4.4 || ^5.0 || ^6.0",
29-
"symfony/browser-kit": "^4.4 || ^5.0 || ^6.0",
30-
"symfony/dom-crawler": "^4.4 || ^5.0 || ^6.0",
31-
"symfony/validator": "^4.4 || ^5.0 || ^6.0",
32-
"symfony/security-bundle": "^4.4 || ^5.0 || ^6.0",
33-
"symfony/twig-bundle": "^4.4 || ^5.0 || ^6.0",
34-
"symfony/twig-bridge": "^4.4 || ^5.0 || ^6.0",
35-
"symfony/var-dumper": "^4.4 || ^5.0 || ^6.0",
21+
"symfony/console": "^5.4 || ^6.0",
22+
"symfony/event-dispatcher": "^5.4 || ^6.0",
23+
"symfony/http-kernel": "^5.4 || ^6.0",
24+
"symfony/finder": "^5.4 || ^6.0",
25+
"symfony/yaml": "^5.4 || ^6.0",
26+
"symfony/form": "^5.4 || ^6.0",
27+
"symfony/phpunit-bridge": "^5.4 || ^6.0",
28+
"symfony/browser-kit": "^5.4 || ^6.0",
29+
"symfony/dom-crawler": "^5.4 || ^6.0",
30+
"symfony/validator": "^5.4 || ^6.0",
31+
"symfony/security-bundle": "^5.4 || ^6.0",
32+
"symfony/twig-bundle": "^5.4 || ^6.0",
33+
"symfony/twig-bridge": "^5.4 || ^6.0",
34+
"symfony/var-dumper": "^5.4 || ^6.0",
3635
"twig/twig": "^1.26 || ^2.0 || ^3.0",
3736
"vimeo/psalm": "^3.18.2 || ^4.0",
3837
"psalm/plugin-symfony": "^1.5.0 || ^2.0 || ^3.0"
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
<?php
2+
3+
use Illuminate\Database\Migrations\Migration;
4+
use Illuminate\Database\Schema\Blueprint;
5+
use WouterJ\EloquentBundle\Facade\Schema;
6+
7+
return new class extends Migration
8+
{
9+
/**
10+
* Run the migrations.
11+
*/
12+
public function up(): void
13+
{
14+
//
15+
}
16+
17+
/**
18+
* Reverse the migrations.
19+
*/
20+
public function down(): void
21+
{
22+
//
23+
}
24+
};
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
<?php
2+
3+
use Illuminate\Database\Migrations\Migration;
4+
use Illuminate\Database\Schema\Blueprint;
5+
use WouterJ\EloquentBundle\Facade\Schema;
6+
7+
return new class extends Migration
8+
{
9+
/**
10+
* Run the migrations.
11+
*/
12+
public function up(): void
13+
{
14+
Schema::create('SomeTable', function (Blueprint $table) {
15+
$table->id();
16+
$table->timestamps();
17+
});
18+
}
19+
20+
/**
21+
* Reverse the migrations.
22+
*/
23+
public function down(): void
24+
{
25+
Schema::dropIfExists('SomeTable');
26+
}
27+
};
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
<?php
2+
3+
use Illuminate\Database\Migrations\Migration;
4+
use Illuminate\Database\Schema\Blueprint;
5+
use WouterJ\EloquentBundle\Facade\Schema;
6+
7+
return new class extends Migration
8+
{
9+
/**
10+
* Run the migrations.
11+
*/
12+
public function up(): void
13+
{
14+
Schema::table('SomeTable', function (Blueprint $table) {
15+
//
16+
});
17+
}
18+
19+
/**
20+
* Reverse the migrations.
21+
*/
22+
public function down(): void
23+
{
24+
Schema::table('SomeTable', function (Blueprint $table) {
25+
//
26+
});
27+
}
28+
};
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
<?php
2+
3+
namespace App\Seed;
4+
5+
use Illuminate\Database\Console\Seeds\WithoutModelEvents;
6+
use WouterJ\EloquentBundle\Seeder;
7+
8+
class PostSeeder extends Seeder
9+
{
10+
/**
11+
* Run the database seeds.
12+
*/
13+
public function run(): void
14+
{
15+
//
16+
}
17+
}

tests/Functional/app/src/AppBundle/AppBundle.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
*/
2222
class AppBundle extends Bundle
2323
{
24-
public function boot()
24+
public function boot(): void
2525
{
2626
User::observe(UserObserver::class);
2727
SoftDeleteUser::observe(UserObserver::class);

tests/Maker/SeederMakeCommandTest.php

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
namespace WouterJ\EloquentBundle\Maker;
44

55
use Illuminate\Database\Console\Seeds\WithoutModelEvents;
6+
use Illuminate\Database\Eloquent\Casts\Json;
67
use PHPUnit\Framework\TestCase;
78
use Symfony\Bundle\MakerBundle\DependencyBuilder;
89
use Symfony\Bundle\MakerBundle\FileManager;
@@ -52,11 +53,13 @@ public function provideSeederNames()
5253

5354
private function expectSeeder(string $name)
5455
{
55-
$fixturePath = file_get_contents(__DIR__.'/../Fixtures/seeds/'.$name.'.php');
56-
if (trait_exists(WithoutModelEvents::class)) {
57-
$fixturePath = file_get_contents(__DIR__.'/../Fixtures/seeds/'.$name.'.laravel9.php');
56+
$fixturePath = __DIR__.'/../Fixtures/seeds/'.$name.'.php';
57+
if (class_exists(Json::class)) {
58+
$fixturePath = __DIR__.'/../Fixtures/seeds/'.$name.'.laravel10.php';
59+
} elseif (trait_exists(WithoutModelEvents::class)) {
60+
$fixturePath = __DIR__.'/../Fixtures/seeds/'.$name.'.laravel9.php';
5861
}
59-
$normalizedExpected = preg_replace('/\R/', "\n", $fixturePath);
62+
$normalizedExpected = preg_replace('/\R/', "\n", file_get_contents($fixturePath));
6063

6164
$path = '/app/src/Seed/'.$name.'.php';
6265
$this->fileManager->allows()->getRelativePathForFutureClass()->with('App\\Seed\\'.$name)->andReturn($path);

tests/Migrations/CreatorTest.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
namespace WouterJ\EloquentBundle\Migrations;
1313

1414
use Illuminate\Database\Console\Seeds\WithoutModelEvents;
15+
use Illuminate\Database\Eloquent\Casts\Json;
1516
use Illuminate\Database\Schema\Blueprint;
1617
use PHPUnit\Framework\TestCase;
1718
use Symfony\Bundle\MakerBundle\FileManager;
@@ -56,7 +57,9 @@ private function expectMigration(string $type, string $name)
5657
{
5758
$normalize = function ($str) { return preg_replace('/\R/', "\n", $str); };
5859

59-
if (trait_exists(WithoutModelEvents::class)) {
60+
if (class_exists(Json::class)) {
61+
$type .= '-10';
62+
} elseif (trait_exists(WithoutModelEvents::class)) {
6063
$type .= '-9';
6164
}
6265
$expected = $normalize(file_get_contents(__DIR__.'/../Fixtures/migrations/'.$type.'.php'));

0 commit comments

Comments
 (0)