Skip to content

[FrameworkBundle] Allow to use the BrowserKit assertions with Panther and API Platform's test client #32207

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
Jul 4, 2019

Conversation

dunglas
Copy link
Member

@dunglas dunglas commented Jun 27, 2019

Q A
Branch? 4.3
Bug fix? yes
New feature? no
BC breaks? no
Deprecations? no
Tests pass? yes
Fixed tickets n/a
License MIT
Doc PR n/a

I'm adding a testing client for API Platform that implements the interfaces of HttpClient: api-platform/core#2608
Most PHPUnit assertions provided by Symfony are useful and can be reused, but the ones using the crawler are not relevant and pollute auto-complete suggestions (because a web API usually returns JSON, not HTML).

This PR splits the existing trait to allow reusing the HTTP related assertions only.

@dunglas
Copy link
Member Author

dunglas commented Jun 27, 2019

Actually, we should create two different traits:

  • One containing only visual assertions, that could be made compatible with Panther, but is useless to test an API
  • Another one for HTTP assertions, that are useful for API testing, but not usable with Panther because W3C WebDriver doesn't give access to the main HTTP request (you cannot retrieve the status code, the headers and other non-visual data).

The current trait can use both new traits to preserve BC. WDYT?

@dunglas dunglas force-pushed the isolate-browserkit-assertions branch 2 times, most recently from cf394c3 to 850d193 Compare June 28, 2019 09:34
@dunglas dunglas changed the title [FrameworkBundle] Isolate non-visual assertions for API testing [FrameworkBundle] Allow to use the BrowserKit assertions with Panther and the API Platform testing client Jun 28, 2019
@dunglas dunglas changed the title [FrameworkBundle] Allow to use the BrowserKit assertions with Panther and the API Platform testing client [FrameworkBundle] Allow to use the BrowserKit assertions with Panther and API Platform's test client Jun 28, 2019
@dunglas
Copy link
Member Author

dunglas commented Jun 28, 2019

Fixed the getClient method to allow Panther too. Can this patch qualifies as a bug fix?
Also, maybe these two new traits should be moved in their respective components?

@nicolas-grekas nicolas-grekas added this to the next milestone Jun 28, 2019
@nicolas-grekas
Copy link
Member

The current trait can use both new traits to preserve BC. WDYT?

makes sense to me

@dunglas
Copy link
Member Author

dunglas commented Jun 28, 2019

Maybe could we just merge this one in 4.3 then?

@dunglas dunglas force-pushed the isolate-browserkit-assertions branch from 850d193 to c8f1002 Compare July 3, 2019 21:27
@dunglas dunglas changed the base branch from 4.4 to 4.3 July 3, 2019 21:28
@dunglas dunglas force-pushed the isolate-browserkit-assertions branch from c8f1002 to e85485f Compare July 3, 2019 21:30
@fabpot fabpot changed the base branch from 4.3 to 4.4 July 4, 2019 06:46
@fabpot fabpot force-pushed the isolate-browserkit-assertions branch from e85485f to cd0341e Compare July 4, 2019 06:46
@fabpot
Copy link
Member

fabpot commented Jul 4, 2019

Thank you @dunglas.

@fabpot fabpot merged commit cd0341e into symfony:4.4 Jul 4, 2019
fabpot added a commit that referenced this pull request Jul 4, 2019
…ns with Panther and API Platform's test client (dunglas)

This PR was submitted for the 4.3 branch but it was merged into the 4.4 branch instead (closes #32207).

Discussion
----------

[FrameworkBundle] Allow to use the BrowserKit assertions with Panther and API Platform's test client

| Q             | A
| ------------- | ---
| Branch?       | 4.3
| Bug fix?      | yes
| New feature?  | no <!-- please update src/**/CHANGELOG.md files -->
| BC breaks?    | no     <!-- see https://symfony.com/bc -->
| Deprecations? | no <!-- please update UPGRADE-*.md and src/**/CHANGELOG.md files -->
| Tests pass?   | yes    <!-- please add some, will be required by reviewers -->
| Fixed tickets | n/a
| License       | MIT
| Doc PR        | n/a

I'm adding a testing client for API Platform that implements the interfaces of HttpClient: api-platform/core#2608
Most PHPUnit assertions provided by Symfony are useful and can be reused, but the ones using the crawler are not relevant and pollute auto-complete suggestions (because a web API usually returns JSON, not HTML).

This PR splits the existing trait to allow reusing the HTTP related assertions only.

Commits
-------

cd0341e [FrameworkBundle] Allow to use the BrowserKit assertions with Panther and API Platform's test client
@dunglas dunglas deleted the isolate-browserkit-assertions branch August 20, 2019 18:25
fabpot added a commit that referenced this pull request Aug 21, 2019
…ompatible with Panther (dunglas)

This PR was merged into the 4.3 branch.

Discussion
----------

[FrameworkBundle] Fix BrowserKit assertions to make them compatible with Panther

| Q             | A
| ------------- | ---
| Branch?       | 4.3
| Bug fix?      | yes
| New feature?  | no <!-- please update src/**/CHANGELOG.md files -->
| BC breaks?    | no     <!-- see https://symfony.com/bc -->
| Deprecations? | no <!-- please update UPGRADE-*.md and src/**/CHANGELOG.md files -->
| Tests pass?   | yes    <!-- please add some, will be required by reviewers -->
| Fixed tickets | n/a   <!-- #-prefixed issue number(s), if any -->
| License       | MIT
| Doc PR        | todo (remove the line telling that these assertions aren't compatible with Panther)

Backport of essential fixes provided by #32207. It allows most assertions to work with Panther even when using Symfony 4.3.

Commits
-------

2316dc3 [FrameworkBundle] Fix BrowserKit assertions to make them compatible with Panther
@nicolas-grekas nicolas-grekas modified the milestones: next, 4.4 Oct 27, 2019
This was referenced Nov 12, 2019
vasilvestre added a commit to vasilvestre/core that referenced this pull request Oct 20, 2023
vasilvestre added a commit to vasilvestre/core that referenced this pull request Oct 20, 2023
soyuka pushed a commit to api-platform/core that referenced this pull request Oct 30, 2023
* ci: fix phpunit


???

* Unset handler_id for symfony 6.3+

* Fix serializer configuration for PHP 8.1 (dev)

* Fix api-platform/api-platform#2437

* Fix excepted deprecation in swagger


Trigger deprecation to fit tests. Can change test if needed


forgot semicolon


try fix deprecation

* remove copied WebTestCase to fix 8.1 dev

PR symfony/symfony#32207 got merged

* fix no deprecation

* try tag legacy to valide


add a bc layer for reworked profiler UI

* fix warning about deprecated method


ensure method exists

* skip an exceptDeprecation, this case fails for a particular CI run

* remove uneccesary changes

* change BC deprecation system for doctrine

* fix some deprecations about validation html mode and attributes for recent sf

* fix doctrine lexer deprecations

* fix bootstrap missing

* improve doc for sf 6


f


Fix tiny bug & deprecation


--

* fix possible deprecation on 7.4

* Update ci.yml

* Update ci.yml
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.

5 participants