-
Notifications
You must be signed in to change notification settings - Fork 11.1k
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
[5.2] Add within() method to InteractWithPages #12201
Conversation
b88f800
to
6d541ad
Compare
Pretty cool addition. Maybe in the tests check for what happens when the container doesn't exist. |
@daylerees thank you and good point, it should throw an exception. |
Don't you technically need a subcrawler stack in case you have nested within calls? |
22a8b14
to
d29ef82
Compare
@taylorotwell added support for nested within calls |
d29ef82
to
0fdb3e0
Compare
@@ -18,7 +19,7 @@ | |||
* | |||
* @var \Symfony\Component\DomCrawler\Crawler |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@var array
maybe ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍 That was fast !
e4f6fd3
to
6fb689b
Compare
@lucasmichot thank you. Docblocks fixed. |
Surely the change to that protected property is a massive breaking change for people? |
@GrahamCampbell only if they are creating their own test methods. But let me use sub crawler again. |
Ping @crynobone. |
6fb689b
to
41076ef
Compare
41076ef
to
9dad77c
Compare
Ok done, if someone is using the protected property $crawler directly, it will work like before. If someone wants to use within with custom test methods, they'd need to use |
Thanks. Can you PR some docs for this? |
I'll do! Thank you @taylorotwell |
Hey guys. I just noticed API says that within() method should return instance of $this but actually it doesn't so there is no way to continue with fluent interface after using within() method: https://github.com/laravel/framework/blob/5.2/src/Illuminate/Foundation/Testing/Concerns/InteractsWithPages.php#L213 |
@Flashek I'll solve that issue, thank you. |
done #13200 |
I have needed this several times when writing tests for complex markups.
This method allows to narrow the test assertions or actions to specific areas of the web page.
For example, you have 2 links with the same text in the same page, but you want to make sure you click the one inside the content area:
Same if you want to make sure you see several texts / elements within a certain area of the page (see tests in the commit).