From 84ac69c90896aee3105dadfca0e9d066ca21457a Mon Sep 17 00:00:00 2001 From: lukinovec Date: Fri, 27 Jun 2025 14:58:17 +0200 Subject: [PATCH] Fully cover shouldSkipPathLeadingThrough in tests --- tests/RLS/TableManagerTest.php | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/tests/RLS/TableManagerTest.php b/tests/RLS/TableManagerTest.php index ae737788..4a0e9da6 100644 --- a/tests/RLS/TableManagerTest.php +++ b/tests/RLS/TableManagerTest.php @@ -428,9 +428,15 @@ test('table rls manager generates shortest paths that lead to the tenants table expect($manager->shortestPaths())->toEqual($expectedShortestPaths); - // Add non-nullable comment_id foreign key + // Add non-nullable comment_id comment constraint Schema::table('ratings', function (Blueprint $table) { - $table->foreignId('comment_id')->comment('rls')->constrained('comments')->onUpdate('cascade')->onDelete('cascade'); + $table->string('comment_id')->comment('rls comments.id'); + + // Nullable constraint with a non-RLS comment. + // Skipped when scopeByDefault is false, + // not ignored when scopeByDefault is true, but still, + // not preferred since comment_id is valid and non-nullable. + $table->foreignId('author_id')->nullable()->comment('random comment')->constrained('authors'); }); // Non-nullable paths are preferred over nullable paths