- Can I use this package to test Laravel’s private methods without breaking production code?
- Yes, this package lets you wrap Laravel objects to access private/protected methods in tests without altering visibility. It’s useful for legacy code or complex internals where refactoring isn’t practical. However, it’s not Laravel-specific—it’s a general PHP utility.
- Does this work with Laravel’s built-in testing tools like `actingAs()` or `partialMock()`?
- No, this package doesn’t integrate with Laravel’s testing helpers. It’s a standalone utility for accessing non-public members, while Laravel’s tools focus on authentication and mocking. Use it alongside Laravel’s tools for broader test coverage.
- What Laravel versions does this package support?
- This package has no Laravel dependencies and works with any PHP version Laravel supports (8.0+ recommended). It’s a pure PHP utility, so compatibility depends on your PHP version, not Laravel itself.
- How do I install and set up this package in a Laravel project?
- Install via Composer: `composer require wikimedia/testing-access-wrapper`. No Laravel-specific setup is needed—just wrap your object in tests using `new AccessWrapper($yourObject)`. It’s designed for manual inclusion in test classes.
- Is this package maintained for Laravel, or is it tied to MediaWiki?
- This package originates from MediaWiki and isn’t actively maintained for Laravel. It’s a lightweight utility for testing permission logic similar to MediaWiki’s system. If MediaWiki’s auth model changes, the package may need updates.
- Can I use this to test Laravel’s authentication system (e.g., spatie/laravel-permission)?
- No, this package isn’t designed for Laravel’s auth systems. It’s tailored for MediaWiki’s permission model (e.g., `Title` and `User` objects). For Laravel, use `spatie/laravel-permission` or Laravel’s native `actingAs()` instead.
- Will this package slow down my Laravel application in production?
- No, this package is only for testing and has no runtime overhead in production. It’s a utility to wrap objects during test execution, so it won’t affect performance outside test environments.
- Are there alternatives for accessing private methods in Laravel tests?
- Yes, consider Laravel’s `partialMock()` or PHPUnit’s reflection extensions. For permission testing, `spatie/laravel-permission` or `orchid/permissions` are better fits. This package is niche—best for MediaWiki-Laravel hybrid apps.
- How do I map MediaWiki’s `Title` or `User` objects to Laravel’s models in tests?
- You’ll need to manually adapt the wrapper’s logic. For example, replace `Title` checks with Laravel’s `Post` or `Article` models in your test assertions. The package doesn’t provide Laravel-specific mappings—it’s a generic tool.
- Is this package safe to use in CI/CD pipelines for Laravel projects?
- Yes, it’s safe for CI/CD as it’s a testing-only utility. However, ensure your tests don’t accidentally rely on MediaWiki-specific logic that might break in Laravel. Review test coverage to avoid false positives.