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

DOM Crawler component triggers deprecation error when calling its own method #35889

Closed
cGuille opened this issue Feb 27, 2020 · 2 comments
Closed

Comments

@cGuille
Copy link

cGuille commented Feb 27, 2020

Symfony version(s) affected: 4.4.4

Description

The Symfony\Component\DomCrawler\Test\Constraint::CrawlerSelectorTextContains::matches method uses the Symfony\Component\DomCrawler\Crawler::text() method in such a way that it triggers a deprecation error.

While not a being a critical bug, I think a component should not trigger its own deprecation errors. It looks like the app using the component is doing something wrong but it is not.

How to reproduce

I am running a WebTestCase that has the following assertion:

$this->assertPageTitleContains('Expected title');

The page's <title> element has a text content with multiple spaces, like this:

<title>    Site name
    –
    Expected title</title>

Possible Solution

The constraint could explicitly pass the optional arguments to the text() method.

Additional context

Here is the deprecation error that shows up in the test report of my company's symfony application:

  4x: "Symfony\Component\DomCrawler\Crawler::text()" will normalize whitespaces by default in Symfony 5.0, set the second "$normalizeWhitespace" argument to false to retrieve the non-normalized version of the text.

The method call:
https://github.com/symfony/dom-crawler/blob/4.4/Test/Constraint/CrawlerSelectorTextContains.php#L48

The deprecation trigger:
https://github.com/symfony/dom-crawler/blob/4.4/Crawler.php#L617-L620

There is probably the same issue with the CrawlerSelectorTextSame contraint:
https://github.com/symfony/dom-crawler/blob/4.4/Test/Constraint/CrawlerSelectorTextSame.php#L48

@xabbuh
Copy link
Member

xabbuh commented Feb 28, 2020

see #35899

fabpot added a commit that referenced this issue Mar 2, 2020
…rtion (xabbuh)

This PR was merged into the 4.4 branch.

Discussion
----------

[DomCrawler] prevent deprecation being triggered from assertion

| Q             | A
| ------------- | ---
| Branch?       | 4.4
| Bug fix?      | yes
| New feature?  | no
| Deprecations? | no
| Tickets       | Fix #35889
| License       | MIT
| Doc PR        |

Commits
-------

b01a10c prevent deprecation being triggered from assertion
@fabpot fabpot closed this as completed Mar 2, 2020
@cGuille
Copy link
Author

cGuille commented Mar 3, 2020

Thanks!

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

No branches or pull requests

4 participants