From d7ae72049a5b636bf0d1eab2bcfb5d805dbabe47 Mon Sep 17 00:00:00 2001 From: Raj Siva-Rajah <5361908+binaryfire@users.noreply.github.com> Date: Sun, 27 Sep 2026 23:46:54 +0000 Subject: [PATCH] Consolidate shared test fixtures and cover nested deferred callbacks Move common database models, routing controllers, enums and route files into their shared fixture locations, and extract mail, notification, queue and model-inspector helpers. Update consumers without changing runtime behavior or dropping Hypervel-specific assertions and isolation adaptations. Reuse the shared models for ignoring-touch assertions while keeping the richer relationship fixtures local. Preserve native typing, immutable dates and the existing timestamp-mutator correction. Add the upstream HTTP regression for callbacks deferred within another callback; the recursive runtime drain is already present. Port Laravel framework https://github.com/laravel/framework/pull/61422 and the regression from https://github.com/laravel/framework/pull/61431 against master 7068848dfe48fc3a433598e09ce798799d442a52. Validated affected test files individually, MySQL and MariaDB timestamp casts, MySQL after-commit transaction coverage, the full parallel suite, formatting and both PHPStan configurations. --- .../DatabaseEloquentIntegrationTest.php | 15 +---- .../Database/Fixtures/Models/Attachment.php | 2 +- .../Database/Fixtures/Models/Comment.php | 2 +- .../Database/Fixtures/Models/Guarded/Post.php | 2 +- .../UnixTimeStampToCarbon.php | 2 +- .../UserWithIntTimestampsViaAttribute.php | 2 +- .../UserWithIntTimestampsViaCasts.php | 2 +- .../UserWithIntTimestampsViaMutator.php | 2 +- .../UserWithUpdatedAtViaMutator.php | 2 +- .../Fixtures/Models/Integration}/Post.php | 2 +- .../Fixtures/Models/Integration}/User.php | 2 +- .../Models/LoadAggregate/BaseModel.php | 2 +- .../Models/LoadAggregate/Related1.php | 2 +- .../Models/LoadAggregate/Related2.php | 2 +- .../Models/MorphEagerLoading/User.php | 2 +- .../Models/MorphEagerLoading/Video.php | 2 +- .../Fixtures/Models/MorphToTarget/Post.php | 2 +- .../Fixtures/Models/PostLikes/Like.php | 2 +- .../Fixtures/Models/PostLikes/Post.php | 2 +- .../Database/EloquentCollectionFreshTest.php | 13 ++-- .../Database/EloquentDeleteTest.php | 2 +- .../EloquentEagerLoadingLimitTest.php | 2 +- .../Database/EloquentHasOneIsTest.php | 2 +- .../Database/EloquentModelLoadMaxTest.php | 6 +- .../Database/EloquentModelLoadMinTest.php | 6 +- .../Database/EloquentModelLoadSumTest.php | 6 +- .../Database/EloquentMorphConstrainTest.php | 2 +- .../EloquentMorphCountEagerLoadingTest.php | 6 +- ...EloquentMorphCountLazyEagerLoadingTest.php | 6 +- .../EloquentMorphEagerLoadingTest.php | 4 +- .../EloquentMorphLazyEagerLoadingTest.php | 4 +- .../Database/EloquentMorphOneIsTest.php | 2 +- .../Database/EloquentMorphToEagerLoadTest.php | 2 +- .../EloquentMorphToGlobalScopesTest.php | 2 +- .../Database/EloquentMorphToIsTest.php | 4 +- .../EloquentMorphToLazyEagerLoadingTest.php | 6 +- .../Database/EloquentMorphToSelectTest.php | 4 +- .../Database/EloquentMorphToTouchesTest.php | 2 +- .../Database/EloquentPaginateTest.php | 2 +- ...loquentTransactionWithAfterCommitTests.php | 26 +------- .../Database/EloquentWhereHasTest.php | 2 +- .../Database/Fixtures/NamedScopeUser.php | 27 ++++++--- .../Database/MariaDb/EloquentCastTest.php | 8 +-- .../Database/ModelInspectorTest.php | 6 +- .../Database/MySql/EloquentCastTest.php | 8 +-- .../ModelInspectorTestModelResource.php | 11 ++++ .../Integration/Mail/SentMessageMailTest.php | 21 +------ .../SendingNotificationsWithLocaleTest.php | 13 +--- ...DeleteNotificationWhenMissingModelTest.php | 34 +---------- .../Fixtures/ApiResourceTaskController.php | 35 ----------- .../Fixtures/ApiResourceTestController.php | 35 ----------- .../CreatableSingletonTestController.php | 40 ------------- .../NestedSingletonTestController.php | 30 ---------- .../Fixtures/SingletonTestController.php | 30 ---------- .../ImplicitBackedEnumRouteBindingTest.php | 23 +++---- .../Routing/RouteApiResourceTest.php | 10 ++-- .../Integration/Routing/RouteCachingTest.php | 8 +-- .../Routing/RouteCanBackedEnumTest.php | 14 ++--- .../Integration/Routing/RouteRedirectTest.php | 32 +++++----- .../Routing/RouteSingletonTest.php | 60 +++++++++---------- tests/Integration/Routing/RouteViewTest.php | 25 ++++---- .../Support/DeferredCallbackTest.php | 32 +++++----- tests/Mail/Fixtures/GreetingMailable.php | 18 ++++++ .../DeleteWhenMissingNotification.php | 47 +++++++++++++++ .../Fixtures/SentMessageMailNotification.php | 32 ++++++++++ ...uentTransactionWithAfterCommitTestsJob.php | 39 ++++++++++++ tests/Queue/Fixtures/TestSyncJob.php | 22 +++++++ .../Routing/Fixtures/AbilityBackedEnum.php | 2 +- .../Fixtures/ApiResourceTaskController.php | 50 ++++++++++++++++ .../Fixtures/ApiResourceTestController.php | 50 ++++++++++++++++ .../CreatableSingletonTestController.php | 58 ++++++++++++++++++ .../Integration}/CategoryBackedEnum.php | 5 +- .../NestedSingletonTestController.php | 42 +++++++++++++ .../Fixtures/SingletonTestController.php | 42 +++++++++++++ .../Routing/Fixtures/redirect_routes.php | 4 +- .../Routing/Fixtures/view.blade.php | 0 .../Fixtures/wildcard_catch_all_routes.php | 4 +- 77 files changed, 626 insertions(+), 453 deletions(-) rename tests/{Integration => }/Database/Fixtures/Models/Attachment.php (69%) rename tests/{Integration => }/Database/Fixtures/Models/Comment.php (84%) rename tests/{Integration => }/Database/Fixtures/Models/Guarded/Post.php (65%) rename tests/{Integration => }/Database/Fixtures/Models/IntTimestampCasts/UnixTimeStampToCarbon.php (89%) rename tests/{Integration => }/Database/Fixtures/Models/IntTimestampCasts/UserWithIntTimestampsViaAttribute.php (92%) rename tests/{Integration => }/Database/Fixtures/Models/IntTimestampCasts/UserWithIntTimestampsViaCasts.php (81%) rename tests/{Integration => }/Database/Fixtures/Models/IntTimestampCasts/UserWithIntTimestampsViaMutator.php (93%) rename tests/{Integration => }/Database/Fixtures/Models/IntTimestampCasts/UserWithUpdatedAtViaMutator.php (86%) rename tests/{Integration/Database/Fixtures => Database/Fixtures/Models/Integration}/Post.php (69%) rename tests/{Integration/Database/Fixtures => Database/Fixtures/Models/Integration}/User.php (68%) rename tests/{Integration => }/Database/Fixtures/Models/LoadAggregate/BaseModel.php (87%) rename tests/{Integration => }/Database/Fixtures/Models/LoadAggregate/Related1.php (84%) rename tests/{Integration => }/Database/Fixtures/Models/LoadAggregate/Related2.php (84%) rename tests/{Integration => }/Database/Fixtures/Models/MorphEagerLoading/User.php (63%) rename tests/{Integration => }/Database/Fixtures/Models/MorphEagerLoading/Video.php (69%) rename tests/{Integration => }/Database/Fixtures/Models/MorphToTarget/Post.php (56%) rename tests/{Integration => }/Database/Fixtures/Models/PostLikes/Like.php (81%) rename tests/{Integration => }/Database/Fixtures/Models/PostLikes/Post.php (81%) create mode 100644 tests/Integration/Http/Fixtures/ModelInspectorTestModelResource.php delete mode 100644 tests/Integration/Routing/Fixtures/ApiResourceTaskController.php delete mode 100644 tests/Integration/Routing/Fixtures/ApiResourceTestController.php delete mode 100644 tests/Integration/Routing/Fixtures/CreatableSingletonTestController.php delete mode 100644 tests/Integration/Routing/Fixtures/NestedSingletonTestController.php delete mode 100644 tests/Integration/Routing/Fixtures/SingletonTestController.php create mode 100644 tests/Mail/Fixtures/GreetingMailable.php create mode 100644 tests/Notifications/Fixtures/DeleteWhenMissingNotification.php create mode 100644 tests/Notifications/Fixtures/SentMessageMailNotification.php create mode 100644 tests/Queue/Fixtures/EloquentTransactionWithAfterCommitTestsJob.php create mode 100644 tests/Queue/Fixtures/TestSyncJob.php rename tests/{Integration => }/Routing/Fixtures/AbilityBackedEnum.php (73%) create mode 100644 tests/Routing/Fixtures/ApiResourceTaskController.php create mode 100644 tests/Routing/Fixtures/ApiResourceTestController.php create mode 100644 tests/Routing/Fixtures/CreatableSingletonTestController.php rename tests/{Integration/Routing/Fixtures => Routing/Fixtures/Integration}/CategoryBackedEnum.php (75%) create mode 100644 tests/Routing/Fixtures/NestedSingletonTestController.php create mode 100644 tests/Routing/Fixtures/SingletonTestController.php rename tests/{Integration => }/Routing/Fixtures/redirect_routes.php (66%) rename tests/{Integration => }/Routing/Fixtures/view.blade.php (100%) rename tests/{Integration => }/Routing/Fixtures/wildcard_catch_all_routes.php (61%) diff --git a/tests/Database/DatabaseEloquentIntegrationTest.php b/tests/Database/DatabaseEloquentIntegrationTest.php index 337b4f7a6e..c49293c17e 100644 --- a/tests/Database/DatabaseEloquentIntegrationTest.php +++ b/tests/Database/DatabaseEloquentIntegrationTest.php @@ -30,6 +30,8 @@ use Hypervel\Support\CarbonImmutable; use Hypervel\Support\Str; use Hypervel\Testbench\TestCase; +use Hypervel\Tests\Database\Fixtures\Models\Integration\Post as IgnoringTouchPost; +use Hypervel\Tests\Database\Fixtures\Models\Integration\User as IgnoringTouchUser; use UnitEnum; class DatabaseEloquentIntegrationTest extends TestCase @@ -3267,16 +3269,3 @@ enum StringBackedRole: string case User = 'user'; case Admin = 'admin'; } - -/** - * Used for isIgnoringTouch() / withoutTouching() tests. - */ -class IgnoringTouchUser extends Eloquent -{ - protected array $guarded = []; -} - -class IgnoringTouchPost extends Eloquent -{ - protected array $guarded = []; -} diff --git a/tests/Integration/Database/Fixtures/Models/Attachment.php b/tests/Database/Fixtures/Models/Attachment.php similarity index 69% rename from tests/Integration/Database/Fixtures/Models/Attachment.php rename to tests/Database/Fixtures/Models/Attachment.php index 04aa0a45cf..1cb7ef369d 100644 --- a/tests/Integration/Database/Fixtures/Models/Attachment.php +++ b/tests/Database/Fixtures/Models/Attachment.php @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace Hypervel\Tests\Integration\Database\Fixtures\Models; +namespace Hypervel\Tests\Database\Fixtures\Models; use Hypervel\Database\Eloquent\Model; diff --git a/tests/Integration/Database/Fixtures/Models/Comment.php b/tests/Database/Fixtures/Models/Comment.php similarity index 84% rename from tests/Integration/Database/Fixtures/Models/Comment.php rename to tests/Database/Fixtures/Models/Comment.php index 15b8f64801..ce2749feac 100644 --- a/tests/Integration/Database/Fixtures/Models/Comment.php +++ b/tests/Database/Fixtures/Models/Comment.php @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace Hypervel\Tests\Integration\Database\Fixtures\Models; +namespace Hypervel\Tests\Database\Fixtures\Models; use Hypervel\Database\Eloquent\Model; use Hypervel\Database\Eloquent\Relations\MorphTo; diff --git a/tests/Integration/Database/Fixtures/Models/Guarded/Post.php b/tests/Database/Fixtures/Models/Guarded/Post.php similarity index 65% rename from tests/Integration/Database/Fixtures/Models/Guarded/Post.php rename to tests/Database/Fixtures/Models/Guarded/Post.php index 44b4f1a149..2b68c8c478 100644 --- a/tests/Integration/Database/Fixtures/Models/Guarded/Post.php +++ b/tests/Database/Fixtures/Models/Guarded/Post.php @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace Hypervel\Tests\Integration\Database\Fixtures\Models\Guarded; +namespace Hypervel\Tests\Database\Fixtures\Models\Guarded; use Hypervel\Database\Eloquent\Model; diff --git a/tests/Integration/Database/Fixtures/Models/IntTimestampCasts/UnixTimeStampToCarbon.php b/tests/Database/Fixtures/Models/IntTimestampCasts/UnixTimeStampToCarbon.php similarity index 89% rename from tests/Integration/Database/Fixtures/Models/IntTimestampCasts/UnixTimeStampToCarbon.php rename to tests/Database/Fixtures/Models/IntTimestampCasts/UnixTimeStampToCarbon.php index 75f6bd8248..0fa2fb76b7 100644 --- a/tests/Integration/Database/Fixtures/Models/IntTimestampCasts/UnixTimeStampToCarbon.php +++ b/tests/Database/Fixtures/Models/IntTimestampCasts/UnixTimeStampToCarbon.php @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace Hypervel\Tests\Integration\Database\Fixtures\Models\IntTimestampCasts; +namespace Hypervel\Tests\Database\Fixtures\Models\IntTimestampCasts; use Hypervel\Contracts\Database\Eloquent\CastsAttributes; use Hypervel\Database\Eloquent\Model; diff --git a/tests/Integration/Database/Fixtures/Models/IntTimestampCasts/UserWithIntTimestampsViaAttribute.php b/tests/Database/Fixtures/Models/IntTimestampCasts/UserWithIntTimestampsViaAttribute.php similarity index 92% rename from tests/Integration/Database/Fixtures/Models/IntTimestampCasts/UserWithIntTimestampsViaAttribute.php rename to tests/Database/Fixtures/Models/IntTimestampCasts/UserWithIntTimestampsViaAttribute.php index 4859ee92ed..f0e9bc446c 100644 --- a/tests/Integration/Database/Fixtures/Models/IntTimestampCasts/UserWithIntTimestampsViaAttribute.php +++ b/tests/Database/Fixtures/Models/IntTimestampCasts/UserWithIntTimestampsViaAttribute.php @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace Hypervel\Tests\Integration\Database\Fixtures\Models\IntTimestampCasts; +namespace Hypervel\Tests\Database\Fixtures\Models\IntTimestampCasts; use Hypervel\Database\Eloquent\Casts\Attribute; use Hypervel\Database\Eloquent\Model; diff --git a/tests/Integration/Database/Fixtures/Models/IntTimestampCasts/UserWithIntTimestampsViaCasts.php b/tests/Database/Fixtures/Models/IntTimestampCasts/UserWithIntTimestampsViaCasts.php similarity index 81% rename from tests/Integration/Database/Fixtures/Models/IntTimestampCasts/UserWithIntTimestampsViaCasts.php rename to tests/Database/Fixtures/Models/IntTimestampCasts/UserWithIntTimestampsViaCasts.php index 1e701c3dee..9e52116970 100644 --- a/tests/Integration/Database/Fixtures/Models/IntTimestampCasts/UserWithIntTimestampsViaCasts.php +++ b/tests/Database/Fixtures/Models/IntTimestampCasts/UserWithIntTimestampsViaCasts.php @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace Hypervel\Tests\Integration\Database\Fixtures\Models\IntTimestampCasts; +namespace Hypervel\Tests\Database\Fixtures\Models\IntTimestampCasts; use Hypervel\Database\Eloquent\Model; diff --git a/tests/Integration/Database/Fixtures/Models/IntTimestampCasts/UserWithIntTimestampsViaMutator.php b/tests/Database/Fixtures/Models/IntTimestampCasts/UserWithIntTimestampsViaMutator.php similarity index 93% rename from tests/Integration/Database/Fixtures/Models/IntTimestampCasts/UserWithIntTimestampsViaMutator.php rename to tests/Database/Fixtures/Models/IntTimestampCasts/UserWithIntTimestampsViaMutator.php index fbe8a9d020..a65332ac1c 100644 --- a/tests/Integration/Database/Fixtures/Models/IntTimestampCasts/UserWithIntTimestampsViaMutator.php +++ b/tests/Database/Fixtures/Models/IntTimestampCasts/UserWithIntTimestampsViaMutator.php @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace Hypervel\Tests\Integration\Database\Fixtures\Models\IntTimestampCasts; +namespace Hypervel\Tests\Database\Fixtures\Models\IntTimestampCasts; use Hypervel\Database\Eloquent\Model; use Hypervel\Support\CarbonImmutable; diff --git a/tests/Integration/Database/Fixtures/Models/IntTimestampCasts/UserWithUpdatedAtViaMutator.php b/tests/Database/Fixtures/Models/IntTimestampCasts/UserWithUpdatedAtViaMutator.php similarity index 86% rename from tests/Integration/Database/Fixtures/Models/IntTimestampCasts/UserWithUpdatedAtViaMutator.php rename to tests/Database/Fixtures/Models/IntTimestampCasts/UserWithUpdatedAtViaMutator.php index bda59c5086..c52a7a1e7f 100644 --- a/tests/Integration/Database/Fixtures/Models/IntTimestampCasts/UserWithUpdatedAtViaMutator.php +++ b/tests/Database/Fixtures/Models/IntTimestampCasts/UserWithUpdatedAtViaMutator.php @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace Hypervel\Tests\Integration\Database\Fixtures\Models\IntTimestampCasts; +namespace Hypervel\Tests\Database\Fixtures\Models\IntTimestampCasts; use Hypervel\Database\Eloquent\Model; diff --git a/tests/Integration/Database/Fixtures/Post.php b/tests/Database/Fixtures/Models/Integration/Post.php similarity index 69% rename from tests/Integration/Database/Fixtures/Post.php rename to tests/Database/Fixtures/Models/Integration/Post.php index 0fa18034c9..1d5e70fab6 100644 --- a/tests/Integration/Database/Fixtures/Post.php +++ b/tests/Database/Fixtures/Models/Integration/Post.php @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace Hypervel\Tests\Integration\Database\Fixtures; +namespace Hypervel\Tests\Database\Fixtures\Models\Integration; use Hypervel\Database\Eloquent\Model; diff --git a/tests/Integration/Database/Fixtures/User.php b/tests/Database/Fixtures/Models/Integration/User.php similarity index 68% rename from tests/Integration/Database/Fixtures/User.php rename to tests/Database/Fixtures/Models/Integration/User.php index ed3d5e9c66..08912d3640 100644 --- a/tests/Integration/Database/Fixtures/User.php +++ b/tests/Database/Fixtures/Models/Integration/User.php @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace Hypervel\Tests\Integration\Database\Fixtures; +namespace Hypervel\Tests\Database\Fixtures\Models\Integration; use Hypervel\Database\Eloquent\Model; diff --git a/tests/Integration/Database/Fixtures/Models/LoadAggregate/BaseModel.php b/tests/Database/Fixtures/Models/LoadAggregate/BaseModel.php similarity index 87% rename from tests/Integration/Database/Fixtures/Models/LoadAggregate/BaseModel.php rename to tests/Database/Fixtures/Models/LoadAggregate/BaseModel.php index c3654b7b9d..a43de5ab3f 100644 --- a/tests/Integration/Database/Fixtures/Models/LoadAggregate/BaseModel.php +++ b/tests/Database/Fixtures/Models/LoadAggregate/BaseModel.php @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace Hypervel\Tests\Integration\Database\Fixtures\Models\LoadAggregate; +namespace Hypervel\Tests\Database\Fixtures\Models\LoadAggregate; use Hypervel\Database\Eloquent\Model; use Hypervel\Database\Eloquent\Relations\HasMany; diff --git a/tests/Integration/Database/Fixtures/Models/LoadAggregate/Related1.php b/tests/Database/Fixtures/Models/LoadAggregate/Related1.php similarity index 84% rename from tests/Integration/Database/Fixtures/Models/LoadAggregate/Related1.php rename to tests/Database/Fixtures/Models/LoadAggregate/Related1.php index 541bced95e..4736d379c4 100644 --- a/tests/Integration/Database/Fixtures/Models/LoadAggregate/Related1.php +++ b/tests/Database/Fixtures/Models/LoadAggregate/Related1.php @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace Hypervel\Tests\Integration\Database\Fixtures\Models\LoadAggregate; +namespace Hypervel\Tests\Database\Fixtures\Models\LoadAggregate; use Hypervel\Database\Eloquent\Model; use Hypervel\Database\Eloquent\Relations\BelongsTo; diff --git a/tests/Integration/Database/Fixtures/Models/LoadAggregate/Related2.php b/tests/Database/Fixtures/Models/LoadAggregate/Related2.php similarity index 84% rename from tests/Integration/Database/Fixtures/Models/LoadAggregate/Related2.php rename to tests/Database/Fixtures/Models/LoadAggregate/Related2.php index 205af63d45..be552e2e46 100644 --- a/tests/Integration/Database/Fixtures/Models/LoadAggregate/Related2.php +++ b/tests/Database/Fixtures/Models/LoadAggregate/Related2.php @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace Hypervel\Tests\Integration\Database\Fixtures\Models\LoadAggregate; +namespace Hypervel\Tests\Database\Fixtures\Models\LoadAggregate; use Hypervel\Database\Eloquent\Model; use Hypervel\Database\Eloquent\Relations\BelongsTo; diff --git a/tests/Integration/Database/Fixtures/Models/MorphEagerLoading/User.php b/tests/Database/Fixtures/Models/MorphEagerLoading/User.php similarity index 63% rename from tests/Integration/Database/Fixtures/Models/MorphEagerLoading/User.php rename to tests/Database/Fixtures/Models/MorphEagerLoading/User.php index 32722da125..ab4f175417 100644 --- a/tests/Integration/Database/Fixtures/Models/MorphEagerLoading/User.php +++ b/tests/Database/Fixtures/Models/MorphEagerLoading/User.php @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace Hypervel\Tests\Integration\Database\Fixtures\Models\MorphEagerLoading; +namespace Hypervel\Tests\Database\Fixtures\Models\MorphEagerLoading; use Hypervel\Database\Eloquent\Model; diff --git a/tests/Integration/Database/Fixtures/Models/MorphEagerLoading/Video.php b/tests/Database/Fixtures/Models/MorphEagerLoading/Video.php similarity index 69% rename from tests/Integration/Database/Fixtures/Models/MorphEagerLoading/Video.php rename to tests/Database/Fixtures/Models/MorphEagerLoading/Video.php index f4dad65f21..59e631c83e 100644 --- a/tests/Integration/Database/Fixtures/Models/MorphEagerLoading/Video.php +++ b/tests/Database/Fixtures/Models/MorphEagerLoading/Video.php @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace Hypervel\Tests\Integration\Database\Fixtures\Models\MorphEagerLoading; +namespace Hypervel\Tests\Database\Fixtures\Models\MorphEagerLoading; use Hypervel\Database\Eloquent\Model; diff --git a/tests/Integration/Database/Fixtures/Models/MorphToTarget/Post.php b/tests/Database/Fixtures/Models/MorphToTarget/Post.php similarity index 56% rename from tests/Integration/Database/Fixtures/Models/MorphToTarget/Post.php rename to tests/Database/Fixtures/Models/MorphToTarget/Post.php index 4cc2ebd017..09041d021a 100644 --- a/tests/Integration/Database/Fixtures/Models/MorphToTarget/Post.php +++ b/tests/Database/Fixtures/Models/MorphToTarget/Post.php @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace Hypervel\Tests\Integration\Database\Fixtures\Models\MorphToTarget; +namespace Hypervel\Tests\Database\Fixtures\Models\MorphToTarget; use Hypervel\Database\Eloquent\Model; diff --git a/tests/Integration/Database/Fixtures/Models/PostLikes/Like.php b/tests/Database/Fixtures/Models/PostLikes/Like.php similarity index 81% rename from tests/Integration/Database/Fixtures/Models/PostLikes/Like.php rename to tests/Database/Fixtures/Models/PostLikes/Like.php index 7be42cac63..d48ce7ec09 100644 --- a/tests/Integration/Database/Fixtures/Models/PostLikes/Like.php +++ b/tests/Database/Fixtures/Models/PostLikes/Like.php @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace Hypervel\Tests\Integration\Database\Fixtures\Models\PostLikes; +namespace Hypervel\Tests\Database\Fixtures\Models\PostLikes; use Hypervel\Database\Eloquent\Model; use Hypervel\Database\Eloquent\Relations\BelongsTo; diff --git a/tests/Integration/Database/Fixtures/Models/PostLikes/Post.php b/tests/Database/Fixtures/Models/PostLikes/Post.php similarity index 81% rename from tests/Integration/Database/Fixtures/Models/PostLikes/Post.php rename to tests/Database/Fixtures/Models/PostLikes/Post.php index 76f1e8c2c8..0f8e49f23d 100644 --- a/tests/Integration/Database/Fixtures/Models/PostLikes/Post.php +++ b/tests/Database/Fixtures/Models/PostLikes/Post.php @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace Hypervel\Tests\Integration\Database\Fixtures\Models\PostLikes; +namespace Hypervel\Tests\Database\Fixtures\Models\PostLikes; use Hypervel\Database\Eloquent\Model; use Hypervel\Database\Eloquent\Relations\HasMany; diff --git a/tests/Integration/Database/EloquentCollectionFreshTest.php b/tests/Integration/Database/EloquentCollectionFreshTest.php index 3c6b6a4337..2ae30d696a 100644 --- a/tests/Integration/Database/EloquentCollectionFreshTest.php +++ b/tests/Integration/Database/EloquentCollectionFreshTest.php @@ -10,24 +10,27 @@ use Hypervel\Database\Schema\Blueprint; use Hypervel\Support\Facades\DB; use Hypervel\Support\Facades\Schema; -use Hypervel\Tests\Integration\Database\Fixtures\User; +use Hypervel\Tests\Database\Fixtures\Models\Integration\User; class EloquentCollectionFreshTest extends DatabaseTestCase { + /** + * Create the test schema. + */ protected function afterRefreshingDatabase(): void { - Schema::create('users', function (Blueprint $table) { + Schema::create('users', function (Blueprint $table): void { $table->increments('id'); $table->string('email'); $table->timestamps(); }); } - public function testEloquentCollectionFresh() + public function testEloquentCollectionFresh(): void { User::insert([ - ['email' => 'laravel@framework.com'], - ['email' => 'laravel@laravel.com'], + ['email' => 'hypervel@framework.com'], + ['email' => 'hypervel@hypervel.com'], ]); $collection = User::all(); diff --git a/tests/Integration/Database/EloquentDeleteTest.php b/tests/Integration/Database/EloquentDeleteTest.php index 8bdb62628b..66b6412be8 100644 --- a/tests/Integration/Database/EloquentDeleteTest.php +++ b/tests/Integration/Database/EloquentDeleteTest.php @@ -9,8 +9,8 @@ use Hypervel\Database\QueryException; use Hypervel\Database\Schema\Blueprint; use Hypervel\Support\Facades\Schema; +use Hypervel\Tests\Database\Fixtures\Models\Integration\Post; use Hypervel\Tests\Integration\Database\DatabaseTestCase; -use Hypervel\Tests\Integration\Database\Fixtures\Post; use Hypervel\Tests\Integration\Database\Fixtures\PostStringyKey; class EloquentDeleteTest extends DatabaseTestCase diff --git a/tests/Integration/Database/EloquentEagerLoadingLimitTest.php b/tests/Integration/Database/EloquentEagerLoadingLimitTest.php index 812ca7a362..747229bef9 100644 --- a/tests/Integration/Database/EloquentEagerLoadingLimitTest.php +++ b/tests/Integration/Database/EloquentEagerLoadingLimitTest.php @@ -12,8 +12,8 @@ use Hypervel\Support\CarbonImmutable; use Hypervel\Support\Facades\DB; use Hypervel\Support\Facades\Schema; +use Hypervel\Tests\Database\Fixtures\Models\Guarded\Post; use Hypervel\Tests\Integration\Database\DatabaseTestCase; -use Hypervel\Tests\Integration\Database\Fixtures\Models\Guarded\Post; class EloquentEagerLoadingLimitTest extends DatabaseTestCase { diff --git a/tests/Integration/Database/EloquentHasOneIsTest.php b/tests/Integration/Database/EloquentHasOneIsTest.php index 96d1021091..e689da4294 100644 --- a/tests/Integration/Database/EloquentHasOneIsTest.php +++ b/tests/Integration/Database/EloquentHasOneIsTest.php @@ -8,8 +8,8 @@ use Hypervel\Database\Eloquent\Relations\HasOne; use Hypervel\Database\Schema\Blueprint; use Hypervel\Support\Facades\Schema; +use Hypervel\Tests\Database\Fixtures\Models\Attachment; use Hypervel\Tests\Integration\Database\DatabaseTestCase; -use Hypervel\Tests\Integration\Database\Fixtures\Models\Attachment; class EloquentHasOneIsTest extends DatabaseTestCase { diff --git a/tests/Integration/Database/EloquentModelLoadMaxTest.php b/tests/Integration/Database/EloquentModelLoadMaxTest.php index 4456ca451e..e41c8fb8cc 100644 --- a/tests/Integration/Database/EloquentModelLoadMaxTest.php +++ b/tests/Integration/Database/EloquentModelLoadMaxTest.php @@ -7,10 +7,10 @@ use Hypervel\Database\Schema\Blueprint; use Hypervel\Support\Facades\DB; use Hypervel\Support\Facades\Schema; +use Hypervel\Tests\Database\Fixtures\Models\LoadAggregate\BaseModel; +use Hypervel\Tests\Database\Fixtures\Models\LoadAggregate\Related1; +use Hypervel\Tests\Database\Fixtures\Models\LoadAggregate\Related2; use Hypervel\Tests\Integration\Database\DatabaseTestCase; -use Hypervel\Tests\Integration\Database\Fixtures\Models\LoadAggregate\BaseModel; -use Hypervel\Tests\Integration\Database\Fixtures\Models\LoadAggregate\Related1; -use Hypervel\Tests\Integration\Database\Fixtures\Models\LoadAggregate\Related2; class EloquentModelLoadMaxTest extends DatabaseTestCase { diff --git a/tests/Integration/Database/EloquentModelLoadMinTest.php b/tests/Integration/Database/EloquentModelLoadMinTest.php index 484a755dce..c6c08b2507 100644 --- a/tests/Integration/Database/EloquentModelLoadMinTest.php +++ b/tests/Integration/Database/EloquentModelLoadMinTest.php @@ -7,10 +7,10 @@ use Hypervel\Database\Schema\Blueprint; use Hypervel\Support\Facades\DB; use Hypervel\Support\Facades\Schema; +use Hypervel\Tests\Database\Fixtures\Models\LoadAggregate\BaseModel; +use Hypervel\Tests\Database\Fixtures\Models\LoadAggregate\Related1; +use Hypervel\Tests\Database\Fixtures\Models\LoadAggregate\Related2; use Hypervel\Tests\Integration\Database\DatabaseTestCase; -use Hypervel\Tests\Integration\Database\Fixtures\Models\LoadAggregate\BaseModel; -use Hypervel\Tests\Integration\Database\Fixtures\Models\LoadAggregate\Related1; -use Hypervel\Tests\Integration\Database\Fixtures\Models\LoadAggregate\Related2; class EloquentModelLoadMinTest extends DatabaseTestCase { diff --git a/tests/Integration/Database/EloquentModelLoadSumTest.php b/tests/Integration/Database/EloquentModelLoadSumTest.php index 48aa495106..17c4bf1e46 100644 --- a/tests/Integration/Database/EloquentModelLoadSumTest.php +++ b/tests/Integration/Database/EloquentModelLoadSumTest.php @@ -8,10 +8,10 @@ use Hypervel\Database\Schema\Blueprint; use Hypervel\Support\Facades\DB; use Hypervel\Support\Facades\Schema; +use Hypervel\Tests\Database\Fixtures\Models\LoadAggregate\BaseModel; +use Hypervel\Tests\Database\Fixtures\Models\LoadAggregate\Related1; +use Hypervel\Tests\Database\Fixtures\Models\LoadAggregate\Related2; use Hypervel\Tests\Integration\Database\DatabaseTestCase; -use Hypervel\Tests\Integration\Database\Fixtures\Models\LoadAggregate\BaseModel; -use Hypervel\Tests\Integration\Database\Fixtures\Models\LoadAggregate\Related1; -use Hypervel\Tests\Integration\Database\Fixtures\Models\LoadAggregate\Related2; use Mockery as m; class EloquentModelLoadSumTest extends DatabaseTestCase diff --git a/tests/Integration/Database/EloquentMorphConstrainTest.php b/tests/Integration/Database/EloquentMorphConstrainTest.php index b9d0c5ef10..1cf01fd1ad 100644 --- a/tests/Integration/Database/EloquentMorphConstrainTest.php +++ b/tests/Integration/Database/EloquentMorphConstrainTest.php @@ -8,8 +8,8 @@ use Hypervel\Database\Eloquent\Relations\MorphTo; use Hypervel\Database\Schema\Blueprint; use Hypervel\Support\Facades\Schema; +use Hypervel\Tests\Database\Fixtures\Models\Comment; use Hypervel\Tests\Integration\Database\DatabaseTestCase; -use Hypervel\Tests\Integration\Database\Fixtures\Models\Comment; class EloquentMorphConstrainTest extends DatabaseTestCase { diff --git a/tests/Integration/Database/EloquentMorphCountEagerLoadingTest.php b/tests/Integration/Database/EloquentMorphCountEagerLoadingTest.php index b106f6f8c4..d5ce103ca8 100644 --- a/tests/Integration/Database/EloquentMorphCountEagerLoadingTest.php +++ b/tests/Integration/Database/EloquentMorphCountEagerLoadingTest.php @@ -10,10 +10,10 @@ use Hypervel\Database\Eloquent\Relations\MorphTo; use Hypervel\Database\Schema\Blueprint; use Hypervel\Support\Facades\Schema; +use Hypervel\Tests\Database\Fixtures\Models\Comment; +use Hypervel\Tests\Database\Fixtures\Models\PostLikes\Like; +use Hypervel\Tests\Database\Fixtures\Models\PostLikes\Post; use Hypervel\Tests\Integration\Database\DatabaseTestCase; -use Hypervel\Tests\Integration\Database\Fixtures\Models\Comment; -use Hypervel\Tests\Integration\Database\Fixtures\Models\PostLikes\Like; -use Hypervel\Tests\Integration\Database\Fixtures\Models\PostLikes\Post; class EloquentMorphCountEagerLoadingTest extends DatabaseTestCase { diff --git a/tests/Integration/Database/EloquentMorphCountLazyEagerLoadingTest.php b/tests/Integration/Database/EloquentMorphCountLazyEagerLoadingTest.php index 7aaa09d710..d70fb51b3b 100644 --- a/tests/Integration/Database/EloquentMorphCountLazyEagerLoadingTest.php +++ b/tests/Integration/Database/EloquentMorphCountLazyEagerLoadingTest.php @@ -6,10 +6,10 @@ use Hypervel\Database\Schema\Blueprint; use Hypervel\Support\Facades\Schema; +use Hypervel\Tests\Database\Fixtures\Models\Comment; +use Hypervel\Tests\Database\Fixtures\Models\PostLikes\Like; +use Hypervel\Tests\Database\Fixtures\Models\PostLikes\Post; use Hypervel\Tests\Integration\Database\DatabaseTestCase; -use Hypervel\Tests\Integration\Database\Fixtures\Models\Comment; -use Hypervel\Tests\Integration\Database\Fixtures\Models\PostLikes\Like; -use Hypervel\Tests\Integration\Database\Fixtures\Models\PostLikes\Post; class EloquentMorphCountLazyEagerLoadingTest extends DatabaseTestCase { diff --git a/tests/Integration/Database/EloquentMorphEagerLoadingTest.php b/tests/Integration/Database/EloquentMorphEagerLoadingTest.php index 08bf2b8736..f7ebeeed4e 100644 --- a/tests/Integration/Database/EloquentMorphEagerLoadingTest.php +++ b/tests/Integration/Database/EloquentMorphEagerLoadingTest.php @@ -10,9 +10,9 @@ use Hypervel\Database\Eloquent\SoftDeletes; use Hypervel\Database\Schema\Blueprint; use Hypervel\Support\Facades\Schema; +use Hypervel\Tests\Database\Fixtures\Models\Comment; +use Hypervel\Tests\Database\Fixtures\Models\MorphEagerLoading\Video; use Hypervel\Tests\Integration\Database\DatabaseTestCase; -use Hypervel\Tests\Integration\Database\Fixtures\Models\Comment; -use Hypervel\Tests\Integration\Database\Fixtures\Models\MorphEagerLoading\Video; class EloquentMorphEagerLoadingTest extends DatabaseTestCase { diff --git a/tests/Integration/Database/EloquentMorphLazyEagerLoadingTest.php b/tests/Integration/Database/EloquentMorphLazyEagerLoadingTest.php index 80ce20eb8a..6897f476b7 100644 --- a/tests/Integration/Database/EloquentMorphLazyEagerLoadingTest.php +++ b/tests/Integration/Database/EloquentMorphLazyEagerLoadingTest.php @@ -8,9 +8,9 @@ use Hypervel\Database\Eloquent\Relations\BelongsTo; use Hypervel\Database\Schema\Blueprint; use Hypervel\Support\Facades\Schema; +use Hypervel\Tests\Database\Fixtures\Models\Comment; +use Hypervel\Tests\Database\Fixtures\Models\MorphEagerLoading\User; use Hypervel\Tests\Integration\Database\DatabaseTestCase; -use Hypervel\Tests\Integration\Database\Fixtures\Models\Comment; -use Hypervel\Tests\Integration\Database\Fixtures\Models\MorphEagerLoading\User; class EloquentMorphLazyEagerLoadingTest extends DatabaseTestCase { diff --git a/tests/Integration/Database/EloquentMorphOneIsTest.php b/tests/Integration/Database/EloquentMorphOneIsTest.php index e9084b9464..37997b51af 100644 --- a/tests/Integration/Database/EloquentMorphOneIsTest.php +++ b/tests/Integration/Database/EloquentMorphOneIsTest.php @@ -8,8 +8,8 @@ use Hypervel\Database\Eloquent\Relations\MorphOne; use Hypervel\Database\Schema\Blueprint; use Hypervel\Support\Facades\Schema; +use Hypervel\Tests\Database\Fixtures\Models\Attachment; use Hypervel\Tests\Integration\Database\DatabaseTestCase; -use Hypervel\Tests\Integration\Database\Fixtures\Models\Attachment; class EloquentMorphOneIsTest extends DatabaseTestCase { diff --git a/tests/Integration/Database/EloquentMorphToEagerLoadTest.php b/tests/Integration/Database/EloquentMorphToEagerLoadTest.php index 148b18ebfc..4926d949e4 100644 --- a/tests/Integration/Database/EloquentMorphToEagerLoadTest.php +++ b/tests/Integration/Database/EloquentMorphToEagerLoadTest.php @@ -9,8 +9,8 @@ use Hypervel\Database\Eloquent\Relations\Relation; use Hypervel\Database\Schema\Blueprint; use Hypervel\Support\Facades\Schema; +use Hypervel\Tests\Database\Fixtures\Models\Comment; use Hypervel\Tests\Integration\Database\DatabaseTestCase; -use Hypervel\Tests\Integration\Database\Fixtures\Models\Comment; class EloquentMorphToEagerLoadTest extends DatabaseTestCase { diff --git a/tests/Integration/Database/EloquentMorphToGlobalScopesTest.php b/tests/Integration/Database/EloquentMorphToGlobalScopesTest.php index 4b36c5d44f..702eb3d0f9 100644 --- a/tests/Integration/Database/EloquentMorphToGlobalScopesTest.php +++ b/tests/Integration/Database/EloquentMorphToGlobalScopesTest.php @@ -9,8 +9,8 @@ use Hypervel\Database\Eloquent\SoftDeletingScope; use Hypervel\Database\Schema\Blueprint; use Hypervel\Support\Facades\Schema; +use Hypervel\Tests\Database\Fixtures\Models\Comment; use Hypervel\Tests\Integration\Database\DatabaseTestCase; -use Hypervel\Tests\Integration\Database\Fixtures\Models\Comment; class EloquentMorphToGlobalScopesTest extends DatabaseTestCase { diff --git a/tests/Integration/Database/EloquentMorphToIsTest.php b/tests/Integration/Database/EloquentMorphToIsTest.php index 6ad7ca8e36..cf2e2ca376 100644 --- a/tests/Integration/Database/EloquentMorphToIsTest.php +++ b/tests/Integration/Database/EloquentMorphToIsTest.php @@ -6,9 +6,9 @@ use Hypervel\Database\Schema\Blueprint; use Hypervel\Support\Facades\Schema; +use Hypervel\Tests\Database\Fixtures\Models\Comment; +use Hypervel\Tests\Database\Fixtures\Models\MorphToTarget\Post; use Hypervel\Tests\Integration\Database\DatabaseTestCase; -use Hypervel\Tests\Integration\Database\Fixtures\Models\Comment; -use Hypervel\Tests\Integration\Database\Fixtures\Models\MorphToTarget\Post; class EloquentMorphToIsTest extends DatabaseTestCase { diff --git a/tests/Integration/Database/EloquentMorphToLazyEagerLoadingTest.php b/tests/Integration/Database/EloquentMorphToLazyEagerLoadingTest.php index 16e3df316d..f0fdf982cf 100644 --- a/tests/Integration/Database/EloquentMorphToLazyEagerLoadingTest.php +++ b/tests/Integration/Database/EloquentMorphToLazyEagerLoadingTest.php @@ -9,10 +9,10 @@ use Hypervel\Database\Schema\Blueprint; use Hypervel\Support\Facades\DB; use Hypervel\Support\Facades\Schema; +use Hypervel\Tests\Database\Fixtures\Models\Comment; +use Hypervel\Tests\Database\Fixtures\Models\MorphEagerLoading\User; +use Hypervel\Tests\Database\Fixtures\Models\MorphEagerLoading\Video; use Hypervel\Tests\Integration\Database\DatabaseTestCase; -use Hypervel\Tests\Integration\Database\Fixtures\Models\Comment; -use Hypervel\Tests\Integration\Database\Fixtures\Models\MorphEagerLoading\User; -use Hypervel\Tests\Integration\Database\Fixtures\Models\MorphEagerLoading\Video; class EloquentMorphToLazyEagerLoadingTest extends DatabaseTestCase { diff --git a/tests/Integration/Database/EloquentMorphToSelectTest.php b/tests/Integration/Database/EloquentMorphToSelectTest.php index 6331050d25..0ed30a6583 100644 --- a/tests/Integration/Database/EloquentMorphToSelectTest.php +++ b/tests/Integration/Database/EloquentMorphToSelectTest.php @@ -6,9 +6,9 @@ use Hypervel\Database\Schema\Blueprint; use Hypervel\Support\Facades\Schema; +use Hypervel\Tests\Database\Fixtures\Models\Comment; +use Hypervel\Tests\Database\Fixtures\Models\MorphToTarget\Post; use Hypervel\Tests\Integration\Database\DatabaseTestCase; -use Hypervel\Tests\Integration\Database\Fixtures\Models\Comment; -use Hypervel\Tests\Integration\Database\Fixtures\Models\MorphToTarget\Post; class EloquentMorphToSelectTest extends DatabaseTestCase { diff --git a/tests/Integration/Database/EloquentMorphToTouchesTest.php b/tests/Integration/Database/EloquentMorphToTouchesTest.php index 8b6c317355..c86de87ad1 100644 --- a/tests/Integration/Database/EloquentMorphToTouchesTest.php +++ b/tests/Integration/Database/EloquentMorphToTouchesTest.php @@ -9,8 +9,8 @@ use Hypervel\Database\Schema\Blueprint; use Hypervel\Support\Facades\DB; use Hypervel\Support\Facades\Schema; +use Hypervel\Tests\Database\Fixtures\Models\MorphToTarget\Post; use Hypervel\Tests\Integration\Database\DatabaseTestCase; -use Hypervel\Tests\Integration\Database\Fixtures\Models\MorphToTarget\Post; class EloquentMorphToTouchesTest extends DatabaseTestCase { diff --git a/tests/Integration/Database/EloquentPaginateTest.php b/tests/Integration/Database/EloquentPaginateTest.php index f1515cc24b..3fead57fa0 100644 --- a/tests/Integration/Database/EloquentPaginateTest.php +++ b/tests/Integration/Database/EloquentPaginateTest.php @@ -7,8 +7,8 @@ use Hypervel\Database\Eloquent\Model; use Hypervel\Database\Schema\Blueprint; use Hypervel\Support\Facades\Schema; +use Hypervel\Tests\Database\Fixtures\Models\Guarded\Post; use Hypervel\Tests\Integration\Database\DatabaseTestCase; -use Hypervel\Tests\Integration\Database\Fixtures\Models\Guarded\Post; class EloquentPaginateTest extends DatabaseTestCase { diff --git a/tests/Integration/Database/EloquentTransactionWithAfterCommitTests.php b/tests/Integration/Database/EloquentTransactionWithAfterCommitTests.php index 929a38540e..e1e8ec6443 100644 --- a/tests/Integration/Database/EloquentTransactionWithAfterCommitTests.php +++ b/tests/Integration/Database/EloquentTransactionWithAfterCommitTests.php @@ -4,15 +4,12 @@ namespace Hypervel\Tests\Integration\Database; -use Hypervel\Bus\Queueable; -use Hypervel\Contracts\Queue\ShouldQueue; use Hypervel\Database\Schema\Blueprint; use Hypervel\Foundation\Auth\User; -use Hypervel\Foundation\Bus\Dispatchable; -use Hypervel\Queue\InteractsWithQueue; use Hypervel\Support\Facades\DB; use Hypervel\Support\Facades\Schema; use Hypervel\Testbench\Factories\UserFactory; +use Hypervel\Tests\Queue\Fixtures\EloquentTransactionWithAfterCommitTestsJob; use RuntimeException; /** @@ -252,27 +249,6 @@ public function created(User $user): void } } -class EloquentTransactionWithAfterCommitTestsJob implements ShouldQueue -{ - use Dispatchable; - use InteractsWithQueue; - use Queueable; - - public function __construct( - public string $email - ) { - } - - public function handle(): void - { - DB::transaction(function () { - DB::table('password_reset_tokens')->insert([ - ['email' => $this->email, 'token' => sha1($this->email), 'created_at' => now()], - ]); - }); - } -} - class EloquentTransactionWithAfterCommitTestsTestObjectForTransactions { public bool $ran = false; diff --git a/tests/Integration/Database/EloquentWhereHasTest.php b/tests/Integration/Database/EloquentWhereHasTest.php index 188bc14c98..81b74ecaef 100644 --- a/tests/Integration/Database/EloquentWhereHasTest.php +++ b/tests/Integration/Database/EloquentWhereHasTest.php @@ -14,8 +14,8 @@ use Hypervel\Database\Schema\Blueprint; use Hypervel\Support\Facades\DB; use Hypervel\Support\Facades\Schema; +use Hypervel\Tests\Database\Fixtures\Models\Comment; use Hypervel\Tests\Integration\Database\DatabaseTestCase; -use Hypervel\Tests\Integration\Database\Fixtures\Models\Comment; use PHPUnit\Framework\Attributes\DataProvider; class EloquentWhereHasTest extends DatabaseTestCase diff --git a/tests/Integration/Database/Fixtures/NamedScopeUser.php b/tests/Integration/Database/Fixtures/NamedScopeUser.php index ac3b78ef6b..d096b1c914 100644 --- a/tests/Integration/Database/Fixtures/NamedScopeUser.php +++ b/tests/Integration/Database/Fixtures/NamedScopeUser.php @@ -6,10 +6,14 @@ use Hypervel\Database\Eloquent\Attributes\Scope; use Hypervel\Database\Eloquent\Builder; +use Hypervel\Tests\Database\Fixtures\Models\Integration\User; use Override; class NamedScopeUser extends User { + /** + * Get the attributes that should be cast. + */ #[Override] protected function casts(): array { @@ -19,28 +23,37 @@ protected function casts(): array ]; } + /** + * Filter users by email verification. + */ #[Scope] - protected function verified(Builder $builder, bool $email = true) + protected function verified(Builder $builder, bool $email = true): Builder { return $builder->when( $email === true, - fn ($query) => $query->whereNotNull('email_verified_at'), - fn ($query) => $query->whereNull('email_verified_at'), + fn (Builder $query): Builder => $query->whereNotNull('email_verified_at'), + fn (Builder $query): Builder => $query->whereNull('email_verified_at'), ); } + /** + * Filter users without returning the query builder. + */ #[Scope] - protected function verifiedWithoutReturn(Builder $builder, bool $email = true) + protected function verifiedWithoutReturn(Builder $builder, bool $email = true): void { $this->verified($builder, $email); } - public function scopeVerifiedUser(Builder $builder, bool $email = true) + /** + * Filter users through a convention-based scope. + */ + public function scopeVerifiedUser(Builder $builder, bool $email = true): Builder { return $builder->when( $email === true, - fn ($query) => $query->whereNotNull('email_verified_at'), - fn ($query) => $query->whereNull('email_verified_at'), + fn (Builder $query): Builder => $query->whereNotNull('email_verified_at'), + fn (Builder $query): Builder => $query->whereNull('email_verified_at'), ); } } diff --git a/tests/Integration/Database/MariaDb/EloquentCastTest.php b/tests/Integration/Database/MariaDb/EloquentCastTest.php index ef3534a92e..202dbdc484 100644 --- a/tests/Integration/Database/MariaDb/EloquentCastTest.php +++ b/tests/Integration/Database/MariaDb/EloquentCastTest.php @@ -7,10 +7,10 @@ use Hypervel\Database\Schema\Blueprint; use Hypervel\Support\CarbonImmutable; use Hypervel\Support\Facades\Schema; -use Hypervel\Tests\Integration\Database\Fixtures\Models\IntTimestampCasts\UserWithIntTimestampsViaAttribute; -use Hypervel\Tests\Integration\Database\Fixtures\Models\IntTimestampCasts\UserWithIntTimestampsViaCasts; -use Hypervel\Tests\Integration\Database\Fixtures\Models\IntTimestampCasts\UserWithIntTimestampsViaMutator; -use Hypervel\Tests\Integration\Database\Fixtures\Models\IntTimestampCasts\UserWithUpdatedAtViaMutator; +use Hypervel\Tests\Database\Fixtures\Models\IntTimestampCasts\UserWithIntTimestampsViaAttribute; +use Hypervel\Tests\Database\Fixtures\Models\IntTimestampCasts\UserWithIntTimestampsViaCasts; +use Hypervel\Tests\Database\Fixtures\Models\IntTimestampCasts\UserWithIntTimestampsViaMutator; +use Hypervel\Tests\Database\Fixtures\Models\IntTimestampCasts\UserWithUpdatedAtViaMutator; class EloquentCastTest extends MariaDbTestCase { diff --git a/tests/Integration/Database/ModelInspectorTest.php b/tests/Integration/Database/ModelInspectorTest.php index b88028f1e3..28891a9a28 100644 --- a/tests/Integration/Database/ModelInspectorTest.php +++ b/tests/Integration/Database/ModelInspectorTest.php @@ -15,9 +15,9 @@ use Hypervel\Database\Eloquent\ModelInspector; use Hypervel\Database\Eloquent\Relations\BelongsTo; use Hypervel\Database\Schema\Blueprint; -use Hypervel\Http\Resources\Json\JsonResource; use Hypervel\Support\Facades\Artisan; use Hypervel\Support\Facades\Schema; +use Hypervel\Tests\Integration\Http\Fixtures\ModelInspectorTestModelResource; class ModelInspectorTest extends DatabaseTestCase { @@ -250,7 +250,3 @@ class ModelInspectorTestModelEloquentCollection extends Collection class ModelInspectorTestModelBuilder extends Builder { } - -class ModelInspectorTestModelResource extends JsonResource -{ -} diff --git a/tests/Integration/Database/MySql/EloquentCastTest.php b/tests/Integration/Database/MySql/EloquentCastTest.php index f72de3086a..7d642f93bc 100644 --- a/tests/Integration/Database/MySql/EloquentCastTest.php +++ b/tests/Integration/Database/MySql/EloquentCastTest.php @@ -7,10 +7,10 @@ use Hypervel\Database\Schema\Blueprint; use Hypervel\Support\CarbonImmutable; use Hypervel\Support\Facades\Schema; -use Hypervel\Tests\Integration\Database\Fixtures\Models\IntTimestampCasts\UserWithIntTimestampsViaAttribute; -use Hypervel\Tests\Integration\Database\Fixtures\Models\IntTimestampCasts\UserWithIntTimestampsViaCasts; -use Hypervel\Tests\Integration\Database\Fixtures\Models\IntTimestampCasts\UserWithIntTimestampsViaMutator; -use Hypervel\Tests\Integration\Database\Fixtures\Models\IntTimestampCasts\UserWithUpdatedAtViaMutator; +use Hypervel\Tests\Database\Fixtures\Models\IntTimestampCasts\UserWithIntTimestampsViaAttribute; +use Hypervel\Tests\Database\Fixtures\Models\IntTimestampCasts\UserWithIntTimestampsViaCasts; +use Hypervel\Tests\Database\Fixtures\Models\IntTimestampCasts\UserWithIntTimestampsViaMutator; +use Hypervel\Tests\Database\Fixtures\Models\IntTimestampCasts\UserWithUpdatedAtViaMutator; class EloquentCastTest extends MySqlTestCase { diff --git a/tests/Integration/Http/Fixtures/ModelInspectorTestModelResource.php b/tests/Integration/Http/Fixtures/ModelInspectorTestModelResource.php new file mode 100644 index 0000000000..273b7bf53f --- /dev/null +++ b/tests/Integration/Http/Fixtures/ModelInspectorTestModelResource.php @@ -0,0 +1,11 @@ +line('Example notification with attachment.') - ->attach(__DIR__ . '/Fixtures/blank_document.pdf', [ - 'as' => 'blank_document.pdf', - 'mime' => 'application/pdf', - ]); - } -} diff --git a/tests/Integration/Notifications/SendingNotificationsWithLocaleTest.php b/tests/Integration/Notifications/SendingNotificationsWithLocaleTest.php index 0b211451db..bbc62d5e67 100644 --- a/tests/Integration/Notifications/SendingNotificationsWithLocaleTest.php +++ b/tests/Integration/Notifications/SendingNotificationsWithLocaleTest.php @@ -9,7 +9,6 @@ use Hypervel\Database\Eloquent\Model; use Hypervel\Database\Schema\Blueprint; use Hypervel\Foundation\Events\LocaleUpdated; -use Hypervel\Mail\Mailable; use Hypervel\Notifications\Channels\MailChannel; use Hypervel\Notifications\Messages\MailMessage; use Hypervel\Notifications\Notifiable; @@ -21,6 +20,7 @@ use Hypervel\Testbench\Attributes\WithConfig; use Hypervel\Testbench\TestCase; use Hypervel\Testing\Assert; +use Hypervel\Tests\Mail\Fixtures\GreetingMailable; #[WithConfig('database.default', 'testing')] class SendingNotificationsWithLocaleTest extends TestCase @@ -317,14 +317,3 @@ public function toMail(mixed $notifiable): GreetingMailable ->to($notifiable->email); } } - -class GreetingMailable extends Mailable -{ - /** - * Build the message. - */ - public function build(): static - { - return $this->view('greeting'); - } -} diff --git a/tests/Integration/Queue/DeleteNotificationWhenMissingModelTest.php b/tests/Integration/Queue/DeleteNotificationWhenMissingModelTest.php index bbf8cc7f7b..38cd78e462 100644 --- a/tests/Integration/Queue/DeleteNotificationWhenMissingModelTest.php +++ b/tests/Integration/Queue/DeleteNotificationWhenMissingModelTest.php @@ -4,21 +4,16 @@ namespace Hypervel\Tests\Integration\Queue\DeleteNotificationWhenMissingModelTest; -use DB; -use Hypervel\Bus\Queueable; use Hypervel\Contracts\Foundation\Application as ApplicationContract; -use Hypervel\Contracts\Queue\ShouldQueue; use Hypervel\Database\Eloquent\Model; use Hypervel\Database\Schema\Blueprint; -use Hypervel\Notifications\Messages\MailMessage; use Hypervel\Notifications\Notifiable; -use Hypervel\Notifications\Notification; -use Hypervel\Queue\Attributes\DeleteWhenMissingModels; -use Hypervel\Queue\SerializesModels; +use Hypervel\Support\Facades\DB; use Hypervel\Support\Facades\Notification as NotificationFacade; use Hypervel\Support\Facades\Schema; use Hypervel\Testbench\Attributes\WithMigration; use Hypervel\Tests\Integration\Queue\QueueTestCase; +use Hypervel\Tests\Notifications\Fixtures\DeleteWhenMissingNotification; use Override; #[WithMigration] @@ -77,28 +72,3 @@ class DeleteNotificationTestModel extends Model protected array $guarded = []; } - -#[DeleteWhenMissingModels] -class DeleteWhenMissingNotification extends Notification implements ShouldQueue -{ - use Queueable; - use SerializesModels; - - public static bool $sent = false; - - public function __construct(public DeleteNotificationTestModel $model) - { - } - - public function via(mixed $notifiable): array - { - return ['mail']; - } - - public function toMail(mixed $notifiable): MailMessage - { - static::$sent = true; - - return new MailMessage; - } -} diff --git a/tests/Integration/Routing/Fixtures/ApiResourceTaskController.php b/tests/Integration/Routing/Fixtures/ApiResourceTaskController.php deleted file mode 100644 index c0fe4b75ff..0000000000 --- a/tests/Integration/Routing/Fixtures/ApiResourceTaskController.php +++ /dev/null @@ -1,35 +0,0 @@ -make('config')->set(['app.key' => 'AckfSECXIvnK5r28GVIWUAxmbBSjTsmF']); } - public function testWithRouteCachingEnabled() + public function testWithRouteCachingEnabled(): void { $this->defineCacheRoutes(<<<'PHP' value; })->middleware('web'); -Route::get('/categories-default/{category?}', function (CategoryBackedEnum $category = CategoryBackedEnum::Fruits) { +Route::get('/categories-default/{category?}', function (CategoryBackedEnum $category = CategoryBackedEnum::Fruits): string { return $category->value; })->middleware('web'); PHP); @@ -50,21 +53,21 @@ public function testWithRouteCachingEnabled() $response->assertSee('fruits'); } - public function testWithoutRouteCachingEnabled() + public function testWithoutRouteCachingEnabled(): void { config(['app.key' => str_repeat('a', 32)]); - Route::post('/categories/{category}', function (CategoryBackedEnum $category) { + Route::post('/categories/{category}', function (CategoryBackedEnum $category): string { return $category->value; })->middleware(['web']); - Route::post('/categories-default/{category?}', function (CategoryBackedEnum $category = CategoryBackedEnum::Fruits) { + Route::post('/categories-default/{category?}', function (CategoryBackedEnum $category = CategoryBackedEnum::Fruits): string { return $category->value; })->middleware('web'); - Route::bind('categoryCode', fn (string $categoryCode) => CategoryBackedEnum::fromCode($categoryCode) ?? abort(404)); + Route::bind('categoryCode', fn (string $categoryCode): CategoryBackedEnum => CategoryBackedEnum::fromCode($categoryCode) ?? abort(404)); - Route::post('/categories-code/{categoryCode}', function (CategoryBackedEnum $categoryCode) { + Route::post('/categories-code/{categoryCode}', function (CategoryBackedEnum $categoryCode): string { return $categoryCode->value; })->middleware(['web']); diff --git a/tests/Integration/Routing/RouteApiResourceTest.php b/tests/Integration/Routing/RouteApiResourceTest.php index 5ec4f46c23..0ddada80a4 100644 --- a/tests/Integration/Routing/RouteApiResourceTest.php +++ b/tests/Integration/Routing/RouteApiResourceTest.php @@ -5,12 +5,12 @@ namespace Hypervel\Tests\Integration\Routing; use Hypervel\Support\Facades\Route; -use Hypervel\Tests\Integration\Routing\Fixtures\ApiResourceTaskController; -use Hypervel\Tests\Integration\Routing\Fixtures\ApiResourceTestController; +use Hypervel\Tests\Routing\Fixtures\ApiResourceTaskController; +use Hypervel\Tests\Routing\Fixtures\ApiResourceTestController; class RouteApiResourceTest extends RoutingTestCase { - public function testApiResource() + public function testApiResource(): void { Route::apiResource('tests', ApiResourceTestController::class); @@ -38,7 +38,7 @@ public function testApiResource() $this->assertSame('I`m destroy', $response->getContent()); } - public function testApiResourceWithOnly() + public function testApiResourceWithOnly(): void { Route::apiResource('tests', ApiResourceTestController::class)->only(['index', 'store']); @@ -56,7 +56,7 @@ public function testApiResourceWithOnly() $this->assertEquals(404, $this->delete('/tests/1')->getStatusCode()); } - public function testApiResources() + public function testApiResources(): void { Route::apiResources([ 'tests' => ApiResourceTestController::class, diff --git a/tests/Integration/Routing/RouteCachingTest.php b/tests/Integration/Routing/RouteCachingTest.php index d6a21df19f..1e565cff2b 100644 --- a/tests/Integration/Routing/RouteCachingTest.php +++ b/tests/Integration/Routing/RouteCachingTest.php @@ -15,17 +15,17 @@ class RouteCachingTest extends RoutingTestCase { - public function testWildcardCatchAllRoutes() + public function testWildcardCatchAllRoutes(): void { - $this->defineCacheRoutes(file_get_contents(__DIR__ . '/Fixtures/wildcard_catch_all_routes.php')); + $this->defineCacheRoutes(file_get_contents(dirname(__DIR__, 2) . '/Routing/Fixtures/wildcard_catch_all_routes.php')); $this->get('/foo')->assertSee('Regular route'); $this->get('/bar')->assertSee('Wildcard route'); } - public function testRedirectRoutes() + public function testRedirectRoutes(): void { - $this->defineCacheRoutes(file_get_contents(__DIR__ . '/Fixtures/redirect_routes.php')); + $this->defineCacheRoutes(file_get_contents(dirname(__DIR__, 2) . '/Routing/Fixtures/redirect_routes.php')); $this->post('/foo/1')->assertRedirect('/foo/1/bar'); $this->get('/foo/1/bar')->assertSee('Redirect response'); diff --git a/tests/Integration/Routing/RouteCanBackedEnumTest.php b/tests/Integration/Routing/RouteCanBackedEnumTest.php index d609517dba..8d3be6484a 100644 --- a/tests/Integration/Routing/RouteCanBackedEnumTest.php +++ b/tests/Integration/Routing/RouteCanBackedEnumTest.php @@ -7,17 +7,17 @@ use Hypervel\Auth\GenericUser; use Hypervel\Support\Facades\Gate; use Hypervel\Support\Facades\Route; -use Hypervel\Tests\Integration\Routing\Fixtures\AbilityBackedEnum; use Hypervel\Tests\Integration\Routing\RoutingTestCase; +use Hypervel\Tests\Routing\Fixtures\AbilityBackedEnum; class RouteCanBackedEnumTest extends RoutingTestCase { - public function testSimpleRouteWithStringBackedEnumCanAbilityGuestForbiddenThroughTheFramework() + public function testSimpleRouteWithStringBackedEnumCanAbilityGuestForbiddenThroughTheFramework(): void { - $gate = Gate::define(AbilityBackedEnum::NotAccessRoute, fn (?GenericUser $user) => false); + $gate = Gate::define(AbilityBackedEnum::NotAccessRoute, fn (?GenericUser $user): bool => false); $this->assertArrayHasKey('not-access-route', $gate->abilities()); - $route = Route::get('/', function () { + $route = Route::get('/', function (): string { return 'Hello World'; })->can(AbilityBackedEnum::NotAccessRoute); $this->assertEquals(['can:not-access-route'], $route->middleware()); @@ -26,12 +26,12 @@ public function testSimpleRouteWithStringBackedEnumCanAbilityGuestForbiddenThrou $response->assertForbidden(); } - public function testSimpleRouteWithStringBackedEnumCanAbilityGuestAllowedThroughTheFramework() + public function testSimpleRouteWithStringBackedEnumCanAbilityGuestAllowedThroughTheFramework(): void { - $gate = Gate::define(AbilityBackedEnum::AccessRoute, fn (?GenericUser $user) => true); + $gate = Gate::define(AbilityBackedEnum::AccessRoute, fn (?GenericUser $user): bool => true); $this->assertArrayHasKey('access-route', $gate->abilities()); - $route = Route::get('/', function () { + $route = Route::get('/', function (): string { return 'Hello World'; })->can(AbilityBackedEnum::AccessRoute); $this->assertEquals(['can:access-route'], $route->middleware()); diff --git a/tests/Integration/Routing/RouteRedirectTest.php b/tests/Integration/Routing/RouteRedirectTest.php index fa1d9ace88..33ce00423e 100644 --- a/tests/Integration/Routing/RouteRedirectTest.php +++ b/tests/Integration/Routing/RouteRedirectTest.php @@ -5,15 +5,16 @@ namespace Hypervel\Tests\Integration\Routing; use Hypervel\Foundation\Auth\User; +use Hypervel\Http\RedirectResponse; use Hypervel\Routing\Middleware\SubstituteBindings; use Hypervel\Support\Facades\Route; -use Hypervel\Tests\Integration\Routing\Fixtures\ApiResourceTestController; +use Hypervel\Tests\Routing\Fixtures\ApiResourceTestController; use PHPUnit\Framework\Attributes\DataProvider; class RouteRedirectTest extends RoutingTestCase { #[DataProvider('routeRedirectDataSets')] - public function testRouteRedirect($redirectFrom, $redirectTo, $requestUri, $redirectUri) + public function testRouteRedirect(string $redirectFrom, string $redirectTo, string $requestUri, string $redirectUri): void { $this->withoutExceptionHandling(); Route::redirect($redirectFrom, $redirectTo, 301); @@ -23,14 +24,17 @@ public function testRouteRedirect($redirectFrom, $redirectTo, $requestUri, $redi $response->assertStatus(301); } - public static function routeRedirectDataSets() + /** + * Provide redirect route parameters and expected URLs. + */ + public static function routeRedirectDataSets(): array { return [ 'route redirect with no parameters' => ['from', 'to', '/from', '/to'], 'route redirect with one parameter' => ['from/{param}/{param2?}', 'to', '/from/value1', '/to'], 'route redirect with two parameters' => ['from/{param}/{param2?}', 'to', '/from/value1/value2', '/to'], 'route redirect with one parameter replacement' => ['users/{user}/repos', 'members/{user}/repos', '/users/22/repos', '/members/22/repos'], - 'route redirect with two parameter replacements' => ['users/{user}/repos/{repo}', 'members/{user}/projects/{repo}', '/users/22/repos/laravel-framework', '/members/22/projects/laravel-framework'], + 'route redirect with two parameter replacements' => ['users/{user}/repos/{repo}', 'members/{user}/projects/{repo}', '/users/22/repos/hypervel-framework', '/members/22/projects/hypervel-framework'], 'route redirect with non existent optional parameter replacements' => ['users/{user?}', 'members/{user?}', '/users', '/members'], 'route redirect with existing parameter replacements' => ['users/{user?}', 'members/{user?}', '/users/22', '/members/22'], 'route redirect with two optional replacements' => ['users/{user?}/{repo?}', 'members/{user?}', '/users/22', '/members/22'], @@ -38,28 +42,28 @@ public static function routeRedirectDataSets() ]; } - public function testRouteRedirectWithExplicitRouteModelBinding() + public function testRouteRedirectWithExplicitRouteModelBinding(): void { $this->withoutExceptionHandling(); - Route::middleware([SubstituteBindings::class])->group(function () { + Route::middleware([SubstituteBindings::class])->group(function (): void { Route::redirect('users/{user}', 'users/{user}/overview'); }); - Route::bind('user', fn ($id) => (new User)->setAttribute('id', '999')); + Route::bind('user', fn (string $id): User => (new User)->setAttribute('id', '999')); $response = $this->get('users/1'); $response->assertRedirect('users/999/overview'); } - public function testToActionHelper() + public function testToActionHelper(): void { Route::get('to', [ApiResourceTestController::class, 'index']); - Route::get('from-301', function () { + Route::get('from-301', function (): RedirectResponse { return to_action([ApiResourceTestController::class, 'index'], [], 301); }); - Route::get('from-302', function () { + Route::get('from-302', function (): RedirectResponse { return to_action([ApiResourceTestController::class, 'index']); }); @@ -74,17 +78,17 @@ public function testToActionHelper() ->assertSee('Redirecting to'); } - public function testToRouteHelper() + public function testToRouteHelper(): void { - Route::get('to', function () { + Route::get('to', function (): void { // .. })->name('to'); - Route::get('from-301', function () { + Route::get('from-301', function (): RedirectResponse { return to_route('to', [], 301); }); - Route::get('from-302', function () { + Route::get('from-302', function (): RedirectResponse { return to_route('to'); }); diff --git a/tests/Integration/Routing/RouteSingletonTest.php b/tests/Integration/Routing/RouteSingletonTest.php index a5bc2b971b..fd6ea06386 100644 --- a/tests/Integration/Routing/RouteSingletonTest.php +++ b/tests/Integration/Routing/RouteSingletonTest.php @@ -5,13 +5,13 @@ namespace Hypervel\Tests\Integration\Routing; use Hypervel\Support\Facades\Route; -use Hypervel\Tests\Integration\Routing\Fixtures\CreatableSingletonTestController; -use Hypervel\Tests\Integration\Routing\Fixtures\NestedSingletonTestController; -use Hypervel\Tests\Integration\Routing\Fixtures\SingletonTestController; +use Hypervel\Tests\Routing\Fixtures\CreatableSingletonTestController; +use Hypervel\Tests\Routing\Fixtures\NestedSingletonTestController; +use Hypervel\Tests\Routing\Fixtures\SingletonTestController; class RouteSingletonTest extends RoutingTestCase { - public function testSingletonDefaults() + public function testSingletonDefaults(): void { Route::singleton('avatar', SingletonTestController::class); @@ -43,7 +43,7 @@ public function testSingletonDefaults() // $this->assertSame('singleton destroy', $response->getContent()); } - public function testCreatableSingleton() + public function testCreatableSingleton(): void { Route::singleton('avatar', CreatableSingletonTestController::class)->creatable(); @@ -63,7 +63,7 @@ public function testCreatableSingleton() $this->assertSame('singleton destroy', $response->getContent()); } - public function testCreatableSingletonOnly() + public function testCreatableSingletonOnly(): void { Route::singleton('avatar', CreatableSingletonTestController::class)->creatable()->only('show'); @@ -89,7 +89,7 @@ public function testCreatableSingletonOnly() $this->assertEquals(405, $response->getStatusCode()); } - public function testCreatableSingletonExcept() + public function testCreatableSingletonExcept(): void { Route::singleton('avatar', CreatableSingletonTestController::class)->creatable()->except('show'); @@ -115,7 +115,7 @@ public function testCreatableSingletonExcept() $this->assertEquals(200, $response->getStatusCode()); } - public function testDestroyableSingleton() + public function testDestroyableSingleton(): void { Route::singleton('avatar', CreatableSingletonTestController::class)->destroyable(); @@ -140,7 +140,7 @@ public function testDestroyableSingleton() $this->assertSame('singleton destroy', $response->getContent()); } - public function testDestroyableSingletonOnly() + public function testDestroyableSingletonOnly(): void { Route::singleton('avatar', SingletonTestController::class)->destroyable()->only('destroy'); @@ -166,7 +166,7 @@ public function testDestroyableSingletonOnly() $this->assertEquals(200, $response->getStatusCode()); } - public function testDestroyableSingletonExcept() + public function testDestroyableSingletonExcept(): void { Route::singleton('avatar', SingletonTestController::class)->destroyable()->except('destroy'); @@ -192,7 +192,7 @@ public function testDestroyableSingletonExcept() $this->assertEquals(405, $response->getStatusCode()); } - public function testCreatableDestroyableSingletonOnlyExceptTest() + public function testCreatableDestroyableSingletonOnlyExceptTest(): void { Route::singleton('avatar', SingletonTestController::class)->creatable()->destroyable()->only(['show'])->except(['destroy']); @@ -218,7 +218,7 @@ public function testCreatableDestroyableSingletonOnlyExceptTest() $this->assertEquals(405, $response->getStatusCode()); } - public function testApiSingleton() + public function testApiSingleton(): void { Route::apiSingleton('avatar', SingletonTestController::class); @@ -234,7 +234,7 @@ public function testApiSingleton() $this->assertSame('singleton update', $response->getContent()); } - public function testCreatableApiSingleton() + public function testCreatableApiSingleton(): void { Route::apiSingleton('avatar', CreatableSingletonTestController::class)->creatable(); @@ -252,7 +252,7 @@ public function testCreatableApiSingleton() $this->assertSame('singleton update', $response->getContent()); } - public function testCreatableApiSingletonOnly() + public function testCreatableApiSingletonOnly(): void { Route::apiSingleton('avatar', CreatableSingletonTestController::class)->creatable()->only(['create', 'store']); @@ -278,7 +278,7 @@ public function testCreatableApiSingletonOnly() $this->assertEquals(405, $response->getStatusCode()); } - public function testCreatableApiSingletonExcept() + public function testCreatableApiSingletonExcept(): void { Route::apiSingleton('avatar', CreatableSingletonTestController::class)->creatable()->except(['create', 'store']); @@ -304,7 +304,7 @@ public function testCreatableApiSingletonExcept() $this->assertEquals(200, $response->getStatusCode()); } - public function testDestroyableApiSingleton() + public function testDestroyableApiSingleton(): void { Route::apiSingleton('avatar', CreatableSingletonTestController::class)->destroyable(); @@ -324,7 +324,7 @@ public function testDestroyableApiSingleton() $this->assertSame('singleton destroy', $response->getContent()); } - public function testDestroyableApiSingletonOnly() + public function testDestroyableApiSingletonOnly(): void { Route::apiSingleton('avatar', CreatableSingletonTestController::class)->destroyable()->only(['destroy']); @@ -350,7 +350,7 @@ public function testDestroyableApiSingletonOnly() $this->assertEquals(200, $response->getStatusCode()); } - public function testDestroyableApiSingletonExcept() + public function testDestroyableApiSingletonExcept(): void { Route::apiSingleton('avatar', CreatableSingletonTestController::class)->destroyable()->except(['destroy', 'show']); @@ -376,7 +376,7 @@ public function testDestroyableApiSingletonExcept() $this->assertEquals(405, $response->getStatusCode()); } - public function testCreatableDestroyableApiSingletonOnlyExceptTest() + public function testCreatableDestroyableApiSingletonOnlyExceptTest(): void { Route::apiSingleton('avatar', CreatableSingletonTestController::class)->creatable()->destroyable()->only(['show'])->except(['destroy']); @@ -402,7 +402,7 @@ public function testCreatableDestroyableApiSingletonOnlyExceptTest() $this->assertEquals(405, $response->getStatusCode()); } - public function testSingletonOnly() + public function testSingletonOnly(): void { Route::singleton('avatar', SingletonTestController::class)->only('show'); @@ -422,7 +422,7 @@ public function testSingletonOnly() $this->assertEquals(405, $response->getStatusCode()); } - public function testSingletonExcept() + public function testSingletonExcept(): void { Route::singleton('avatar', SingletonTestController::class)->except('show'); @@ -446,21 +446,21 @@ public function testSingletonExcept() // $this->assertSame('singleton destroy', $response->getContent()); } - public function testSingletonName() + public function testSingletonName(): void { Route::singleton('avatar', SingletonTestController::class)->name('show', 'foo.show'); $this->assertSame('http://localhost/avatar', route('foo.show')); } - public function testSingletonNames() + public function testSingletonNames(): void { Route::singleton('avatar', SingletonTestController::class)->names(['show' => 'foo.show']); $this->assertSame('http://localhost/avatar', route('foo.show')); } - public function testNestedSingleton() + public function testNestedSingleton(): void { Route::singleton('videos.thumbnail', NestedSingletonTestController::class); @@ -484,7 +484,7 @@ public function testNestedSingleton() $this->assertEquals(405, $response->getStatusCode()); } - public function testCreatableNestedSingleton() + public function testCreatableNestedSingleton(): void { Route::singleton('videos.thumbnail', NestedSingletonTestController::class)->creatable(); @@ -509,7 +509,7 @@ public function testCreatableNestedSingleton() $this->assertSame('singleton destroy for 123', $response->getContent()); } - public function testDestroyableNestedSingleton() + public function testDestroyableNestedSingleton(): void { Route::singleton('videos.thumbnail', NestedSingletonTestController::class)->destroyable(); @@ -534,7 +534,7 @@ public function testDestroyableNestedSingleton() $this->assertSame('singleton destroy for 123', $response->getContent()); } - public function testNestedSingletonParameter() + public function testNestedSingletonParameter(): void { Route::singleton('v.thumbnail', NestedSingletonTestController::class)->parameter('v', 'video'); @@ -544,7 +544,7 @@ public function testNestedSingletonParameter() $this->assertSame('singleton show for 123', $response->getContent()); } - public function testNestedSingletonParameters() + public function testNestedSingletonParameters(): void { Route::singleton('v.thumbnail', NestedSingletonTestController::class)->parameters(['v' => 'video']); @@ -554,7 +554,7 @@ public function testNestedSingletonParameters() $this->assertSame('singleton show for 123', $response->getContent()); } - public function testNestedSingletonWhere() + public function testNestedSingletonWhere(): void { Route::singleton('videos.thumbnail', NestedSingletonTestController::class)->where(['video' => '[a-z]+']); @@ -563,7 +563,7 @@ public function testNestedSingletonWhere() $this->assertEquals(404, $response->getStatusCode()); } - public function testPrefixedSingleton() + public function testPrefixedSingleton(): void { Route::singleton('/user/avatar', SingletonTestController::class); diff --git a/tests/Integration/Routing/RouteViewTest.php b/tests/Integration/Routing/RouteViewTest.php index 748b83de15..3fa503289e 100644 --- a/tests/Integration/Routing/RouteViewTest.php +++ b/tests/Integration/Routing/RouteViewTest.php @@ -6,64 +6,65 @@ use Hypervel\Support\Facades\Route; use Hypervel\Support\Facades\View; +use Hypervel\Testing\TestResponse; class RouteViewTest extends RoutingTestCase { - public function testRouteView() + public function testRouteView(): void { Route::view('route', 'view', ['foo' => 'bar']); - View::addLocation(__DIR__ . '/Fixtures'); + View::addLocation(dirname(__DIR__, 2) . '/Routing/Fixtures'); $this->assertStringContainsString('Test bar', $this->get('/route')->getContent()); $this->assertSame(200, $this->get('/route')->status()); } - public function testRouteViewWithParams() + public function testRouteViewWithParams(): void { Route::view('route/{param}/{param2?}', 'view', ['foo' => 'bar']); - View::addLocation(__DIR__ . '/Fixtures'); + View::addLocation(dirname(__DIR__, 2) . '/Routing/Fixtures'); $this->assertStringContainsString('Test bar', $this->get('/route/value1/value2')->getContent()); $this->assertStringContainsString('Test bar', $this->get('/route/value1')->getContent()); - tap($this->get('/route/value1/value2'), function ($response) { + tap($this->get('/route/value1/value2'), function (TestResponse $response): void { $this->assertSame('value1', $response->viewData('param')); $this->assertSame('value1', $response->baseRequest->route('param')); $this->assertSame('value2', $response->baseRequest->route('param2')); }); - tap($this->get('/route/value1/value2'), function ($response) { + tap($this->get('/route/value1/value2'), function (TestResponse $response): void { $this->assertSame('value2', $response->viewData('param2')); $this->assertSame('value1', $response->baseRequest->route('param')); $this->assertSame('value2', $response->baseRequest->route('param2')); }); } - public function testRouteViewWithStatus() + public function testRouteViewWithStatus(): void { Route::view('route', 'view', ['foo' => 'bar'], 418); - View::addLocation(__DIR__ . '/Fixtures'); + View::addLocation(dirname(__DIR__, 2) . '/Routing/Fixtures'); $this->assertSame(418, $this->get('/route')->status()); } - public function testRouteViewWithHeaders() + public function testRouteViewWithHeaders(): void { Route::view('route', 'view', ['foo' => 'bar'], 418, ['Framework' => 'Hypervel']); - View::addLocation(__DIR__ . '/Fixtures'); + View::addLocation(dirname(__DIR__, 2) . '/Routing/Fixtures'); $this->assertSame('Hypervel', $this->get('/route')->headers->get('Framework')); } - public function testRouteViewOverloadingStatusWithHeaders() + public function testRouteViewOverloadingStatusWithHeaders(): void { Route::view('route', 'view', ['foo' => 'bar'], ['Framework' => 'Hypervel']); - View::addLocation(__DIR__ . '/Fixtures'); + View::addLocation(dirname(__DIR__, 2) . '/Routing/Fixtures'); $this->assertSame('Hypervel', $this->get('/route')->headers->get('Framework')); } diff --git a/tests/Integration/Support/DeferredCallbackTest.php b/tests/Integration/Support/DeferredCallbackTest.php index 8e0dcdb643..591c122f48 100644 --- a/tests/Integration/Support/DeferredCallbackTest.php +++ b/tests/Integration/Support/DeferredCallbackTest.php @@ -4,13 +4,11 @@ namespace Hypervel\Tests\Integration\Support; -use Hypervel\Bus\Queueable; -use Hypervel\Contracts\Queue\ShouldQueue; -use Hypervel\Foundation\Bus\Dispatchable; use Hypervel\Foundation\Http\Middleware\InvokeDeferredCallbacks; use Hypervel\Support\Facades\Route; use Hypervel\Testbench\Attributes\WithConfig; use Hypervel\Testbench\TestCase; +use Hypervel\Tests\Queue\Fixtures\TestSyncJob; class DeferredCallbackTest extends TestCase { @@ -24,24 +22,30 @@ public function testDeferredCallbackIsNotDiscardedBySyncJob(): void $executed = true; }); - dispatch(new DeferredCallbackTestSyncJob); + dispatch(new TestSyncJob); })->middleware(InvokeDeferredCallbacks::class); $this->get('/test'); $this->assertTrue($executed); } -} - -class DeferredCallbackTestSyncJob implements ShouldQueue -{ - use Dispatchable; - use Queueable; - /** - * Handle the job. - */ - public function handle(): void + public function testCallbacksDeferredWithinADeferredCallbackAreInvoked(): void { + $result = []; + + Route::get('/test', function () use (&$result): void { + defer(function () use (&$result): void { + $result[] = 'first'; + + defer(function () use (&$result): void { + $result[] = 'second'; + }); + }); + }); + + $this->get('/test'); + + $this->assertSame(['first', 'second'], $result); } } diff --git a/tests/Mail/Fixtures/GreetingMailable.php b/tests/Mail/Fixtures/GreetingMailable.php new file mode 100644 index 0000000000..593dec193c --- /dev/null +++ b/tests/Mail/Fixtures/GreetingMailable.php @@ -0,0 +1,18 @@ +view('greeting'); + } +} diff --git a/tests/Notifications/Fixtures/DeleteWhenMissingNotification.php b/tests/Notifications/Fixtures/DeleteWhenMissingNotification.php new file mode 100644 index 0000000000..e7b0268f73 --- /dev/null +++ b/tests/Notifications/Fixtures/DeleteWhenMissingNotification.php @@ -0,0 +1,47 @@ +line('Example notification with attachment.') + ->attach(dirname(__DIR__, 2) . '/Integration/Mail/Fixtures/blank_document.pdf', [ + 'as' => 'blank_document.pdf', + 'mime' => 'application/pdf', + ]); + } +} diff --git a/tests/Queue/Fixtures/EloquentTransactionWithAfterCommitTestsJob.php b/tests/Queue/Fixtures/EloquentTransactionWithAfterCommitTestsJob.php new file mode 100644 index 0000000000..d6a6865de7 --- /dev/null +++ b/tests/Queue/Fixtures/EloquentTransactionWithAfterCommitTestsJob.php @@ -0,0 +1,39 @@ +insert([ + ['email' => $this->email, 'token' => sha1($this->email), 'created_at' => CarbonImmutable::now()], + ]); + }); + } +} diff --git a/tests/Queue/Fixtures/TestSyncJob.php b/tests/Queue/Fixtures/TestSyncJob.php new file mode 100644 index 0000000000..4d7a1b1b9d --- /dev/null +++ b/tests/Queue/Fixtures/TestSyncJob.php @@ -0,0 +1,22 @@ +