Weave Code
Code Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message
Testing Access Wrapper

Testing Access Wrapper Laravel Package

wikimedia/testing-access-wrapper

Small PHP utility from Wikimedia that wraps objects to access otherwise non-public (protected/private) methods and properties in tests. Helps write focused unit tests without changing production visibility, acting as a thin “testing access wrapper.”

Deep Wiki
Context7

wikimedia/testing-access-wrapper is a lightweight PHP utility for testing that provides a controlled way to access non-public methods and properties on objects. It helps you write focused unit tests without permanently changing visibility just to assert internal behavior.

Use it to wrap an instance and interact with otherwise inaccessible members in a clear, explicit manner—ideal for legacy code or complex internals where full refactoring isn’t practical.

  • Wrap an object to access private/protected members in tests
  • Invoke non-public methods and read/write non-public properties
  • Keeps production code untouched while improving test coverage
  • Minimal, dependency-light helper suited for PHPUnit-style workflows
Frequently asked questions about Testing Access Wrapper
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.
Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
davejamesmiller/laravel-breadcrumbs
artisanry/parsedown
christhompsontldr/phpsdk
enqueue/dsn
bunny/bunny
enqueue/test
enqueue/null
enqueue/amqp-tools
milesj/emojibase
bower-asset/punycode
bower-asset/inputmask
bower-asset/jquery
bower-asset/yii2-pjax
laravel/nova
spatie/laravel-mailcoach
spatie/laravel-superseeder
laravel/liferaft
nst/json-test-suite
danielmiessler/sec-lists
jackalope/jackalope-transport