fix(tests): Migrate permission system from web to sanctum guard #133
+23
−6
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
Fixes guard mismatch in test files and User model by explicitly declaring 'sanctum' guard for all permissions and the User model. Resolves 403 Forbidden errors in RBAC tests.
Related Issues
Fixes #126 (RoleApiTest)
Fixes #127 (PersonApiTest - was already partially fixed with 'web')
Fixes #128 (Covered by RoleApiTest)
Fixes #129 (User Model $guard_name)
Part of: #125 (EPIC: Guard Migration)
Changes
Test Files (Guard Declaration)
'guard_name' => 'sanctum'to 3 Permission::create() + 1 Role::create()'guard_name'from 'web' to 'sanctum' (2 permissions)Model (Guard Declaration)
protected $guard_name = 'sanctum'with PHPDoc @var string type hintDocumentation
Technical Context
Problem:
givePermissionTo()uses User model's guard, not permission's guardSolution:
Both User model AND permissions must explicitly use 'sanctum' guard.
Testing
Results:
Impact
✅ Architecture Semantically Correct: Token-auth uses sanctum guard
✅ Self-Documenting Code: Explicit guard declaration
✅ Zero Technical Debt: No guard mismatch confusion
✅ Unblocks RBAC Phase 4: Issue #108 can proceed
4-Pass Review
✅ Pass 1 - Comprehensive: PSR-12, PHPDoc, tests, CHANGELOG
✅ Pass 2 - Deep Dive: Domain policy, REUSE 3.3, security
✅ Pass 3 - Best Practices: Hidden files, governance
✅ Pass 4 - Security: No secrets, .gitignore complete
Pre-Merge Checklist