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

[DomCrawler] compare CrawlerSelector constraints against all matches #36062

Closed
wants to merge 4 commits into from
Closed

[DomCrawler] compare CrawlerSelector constraints against all matches #36062

wants to merge 4 commits into from

Conversation

m-unkel
Copy link

@m-unkel m-unkel commented Mar 13, 2020

Q A
Branch? 4.4+
Bug fix? yes
New feature? no
Deprecations? no
Tickets
License MIT
Doc PR

The Symfony documentation explains that...

To assert that the phrase "Hello World" is present in the page's main title, you can use this assertion:

$this->assertSelectorTextContains('html h1.title', 'Hello World');

Using native PHPUnit methods, the same assertion would look like this:

$this->assertGreaterThan( 0, $crawler->filter('html h1.title:contains("Hello World")')->count() );

..this is ONLY true if the selector has only one match.

This pull requests changes the constraint behaviour to compare all matches against the provided criteria. If this is not the desired behaviour, please fix the documentation.

assertion is successfully if there is at least one node that matches the criteria
@m-unkel m-unkel changed the title compare constraint against all matches DomCrawler Constraint: compare against all matches Mar 13, 2020
@m-unkel m-unkel changed the title DomCrawler Constraint: compare against all matches [DomCrawler] Constraints: compare against all matches Mar 13, 2020
@m-unkel m-unkel changed the title [DomCrawler] Constraints: compare against all matches [DomCrawler] compare CrawlerSelctor constraints against all matches Mar 13, 2020
@m-unkel m-unkel changed the title [DomCrawler] compare CrawlerSelctor constraints against all matches [DomCrawler] compare CrawlerSelector constraints against all matches Mar 16, 2020
@nicolas-grekas nicolas-grekas added this to the 4.4 milestone Mar 19, 2020
@nicolas-grekas
Copy link
Member

Can you please add some tests?

@m-unkel
Copy link
Author

m-unkel commented Mar 19, 2020

There it is! If there is anything missing please let me know.

@nicolas-grekas
Copy link
Member

Thank you for opening. I'm closing in favor of #36158, where the discussion actually happened.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants