Skip to content

feat(live): improve TestLiveComponent::actingAs() #1461

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

Merged
merged 1 commit into from
Feb 21, 2024

Conversation

kbond
Copy link
Member

@kbond kbond commented Feb 5, 2024

Q A
Bug fix? no
New feature? no
Issues n/a
License MIT

(depends on #1460)

Currently, if you have a component that requires authentication for all actions (ie #[IsGranted] on the component class), in your tests, as soon as you call $this->createLiveComponent(...), you'll get an access denied exception. You never get a chance to call ->actingAs().

This PR makes the initial request for the live component lazy. Only when the initial request is required (for other methods), is it made. This gives you the chance to call ->actingAs() before the initial render.

@carsonbot carsonbot added the Status: Needs Review Needs to be reviewed label Feb 5, 2024
@daFish
Copy link
Contributor

daFish commented Feb 6, 2024

@kbond Using your changes works in my case. I no longer get the CSRF-exception.

@kbond kbond force-pushed the feat/live-improve-test-helper branch 2 times, most recently from aa732fc to 0546030 Compare February 10, 2024 16:34
@kbond
Copy link
Member Author

kbond commented Feb 10, 2024

Rebased and fixed the failing test I introduced in #1460.

@kbond kbond force-pushed the feat/live-improve-test-helper branch from 0546030 to f9d27c6 Compare February 16, 2024 14:41
@weaverryan weaverryan force-pushed the feat/live-improve-test-helper branch from f9d27c6 to d0a4713 Compare February 21, 2024 00:35
@weaverryan
Copy link
Member

Thanks Kevin!

@weaverryan weaverryan merged commit 01a42fe into symfony:2.x Feb 21, 2024
@kbond kbond deleted the feat/live-improve-test-helper branch February 21, 2024 00:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Status: Needs Review Needs to be reviewed
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants