Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support to invade Testable #8264

Merged
merged 1 commit into from
Apr 6, 2024

Conversation

PerryvanderMeer
Copy link
Contributor

Every now and then I involve private and protected functions and properties in my tests.
It can be challenging to access those while testing, although invade() is the ideal solution.

This PR adds support for accessing protected and private functions and properties while testing via ->invade().

$component = Livewire::test(new class extends Component {
    protected string $foo = 'bar';
});

$component->invade()->foo; // bar

I have this by default in my projects via a Mixin, but it may be useful to others as well.

@joshhanley joshhanley changed the title [3.x] Add support to invade Testable Add support to invade Testable Apr 5, 2024
@calebporzio
Copy link
Collaborator

This is pretty cool!

@calebporzio calebporzio merged commit 5ff3fb0 into livewire:main Apr 6, 2024
5 checks passed
@PerryvanderMeer PerryvanderMeer deleted the add-invade-to-testable branch April 6, 2024 14:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants