8000 [Testing] Add docs for new WebTestCase assertions by Pierstoval · Pull Request #11271 · symfony/symfony-docs · GitHub
[go: up one dir, main page]

Skip to content

[Testing] Add docs for new WebTestCase assertions #11271

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
Apr 7, 2019
Merged

[Testing] Add docs for new WebTestCase assertions #11271

merged 1 commit into from
Apr 7, 2019

Conversation

Pierstoval
Copy link
Contributor

@Pierstoval Pierstoval changed the title Add basics of new WebTestCase assertions [Testing] Add docs for new WebTestCase assertions Apr 1, 2019
@Pierstoval
Copy link
Contributor Author

Should I add examples for every assertion? To me they all seem self-explanatory, but I could be more exhaustive with examples 😄

@Pierstoval
Copy link
Contributor Author

Also, to reference this page in a better way in the docs (so it can be easily accessible), I may need some advices and tips on where I could add links to this new page 👍

@OskarStark
Copy link
Contributor

Hey Alex, thank you for this nice new feature and the documentation so far.

To be honest I am not sure if replacing the explicit example with the shortcuts is the right way.
I think the user should what is done internally. An idea could be to write it that way:

    $this->assertGreaterThan(
        0,
        $crawler->filter('html:contains("Hello World")')->count()
    );
    
    // or use a shortcut
    $this->assertSelectorTextContains('html', 'Hello World');

Not sure we should add so many versionadded directive (I mean for every new method one). I am for grouping them under a sub-headline. and add only one versionadded.

What do you think @symfony/team-symfony-docs ?

Copy link
Contributor
@OskarStark OskarStark left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I left some thoughts which could improve the docs a bit. 💭
You should not change everything before we heard some other thoughts from the docs-team.

friendly ping @symfony/team-symfony-docs ❤️

.. note::

These assertions will not work with `symfony/panther`_ as they use the
``Request`` and ``Response`` objects coming from the ``HttpFoundation``
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would remove the explanation about why they don't work with Panther (nobody cares). Wouldn't it be possible to make them work?

Copy link
Contributor
8000

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe not adding it directly here, but adding a Troubleshooting headline at the end and explain the panther case sounds helpful to me.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To make them work we should make all assertions compatible with both HttpFoundation and BrowserKit classes (especially Request and Response), and make sure the Browser class used is also compatible with Panther.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

... which is quite possible, right? I suppose you meant "constraints" and not "assertions" here.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep, I wasn't originally planning to use constraints, but since you updated the PR with it, we can make them compatible with both classes indeed 😄

8000

@Pierstoval
Copy link
Contributor Author

Thanks for the review! I'm a bit busy this week but I'll fix everything as soon as possible 👍

@Pierstoval
Copy link
Contributor Author

I fixed many of your reviews, and I think we should also plan to make the assertions compatible with Panther for more flexibility 👍

Copy link
Contributor
@OskarStark OskarStark left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I left some minor comments!

@Pierstoval
Copy link
Contributor Author
Pierstoval commented Apr 3, 2019

@OskarStark Implemented your reviews 😉

@Pierstoval
Copy link
Contributor Author

About the Panther compatibility, I think we should update Panther itself first, because of these lines throwing an exception on getRequest() and getResponse().

testing.rst Outdated

This assertion will internally call ``$crawler->filter('html')``, which allows
you to use CSS selectors to filter any HTML element in the page and check for
its existence, attributes, text, etc.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As the new method is much nicer than the previous one, let's update the code example directly using this assertion. We can then reduce this .. versionadded:: directive to "The WebTestCase assertions were introduced in Symfony 4.3." and add the .. seealso:: directive below it.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I just added what you suggested, what do you think? 🙂

Response
~~~~~~~~

- ``assertResponseIsSuccessful()``
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe it is usefull to have the full signature here or transform them all to :method:`` links?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We decided to not do this because Symfony API isn’t available anymore.

Yesterday I talked to @Nyholm, @dmaicher and @xabbuh about fixing this by unsung github. MaBe you can talk to each other directly

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We cannot link to a specific method when using GitHub, so that's a bit sad. For class, it will be a good solution though. We must discuss whether it's usefull to link functions, or just like to the class on github directly

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

in a PR github seems to have this method information. Otherwiese we could have a proxy wich calculates the needed line number on demand for the github url

@HeahDude HeahDude added this to the 4.3 milestone Apr 6, 2019
@wouterj wouterj added the ⭐️ EU-FOSSA Hackathon https://symfony.com/blog/the-symfony-and-api-platform-hackathon-is-coming label Apr 7, 2019
@wouterj
Copy link
Member
wouterj commented Apr 7, 2019

Great! Thanks for documenting this feature! (and by this merge, your PR has become part of the EUFOSSA hackathon as well 😃 )

@wouterj wouterj merged commit 3b1a1a1 into symfony:master Apr 7, 2019
wouterj added a commit that referenced this pull request Apr 7, 2019
…rstoval)

This PR was merged into the master branch.

Discussion
----------

[Testing] Add docs for new WebTestCase assertions

Fixes #11266 , as of symfony/symfony#30813

Commits
-------

3b1a1a1 Add docs of new WebTestCase assertions
@Pierstoval Pierstoval deleted the assertions branch April 7, 2019 14:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
⭐️ EU-FOSSA Hackathon https://symfony.com/blog/the-symfony-and-api-platform-hackathon-is-coming PHPUnitBridge Status: Reviewed
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants
0