-
-
Notifications
You must be signed in to change notification settings - Fork 9.7k
[BrowserKit] Bypass Header Informations #26791
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
Conversation
| * @return Crawler | ||
| */ | ||
| public function submit(Form $form, array $values = array()) | ||
| public function submit(Form $form, array $values = array(), $serverParameters = array()) |
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.
Instead of allowing to pass any server parameters, I think we should restrict to only HTTP headers. What do you think?
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.
well, that's not consistent with the request API, which expects to get things in the $_SERVER format. I think consistency is better for now.
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.
Not sure I understand consistency here. Changing anything besides HTTP headers when submitting a form should not be allowed.
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.
I mean, consistency between the different APIs of BrowserKit (namely request and submit here)
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.
I created the Pull Request to Mink BrowserKit to show the exakt usage for my usecase. Therefor I might leave it as it is. If you would prefer to filter parameters i can implement that as well
…ient This: symfony/symfony#26791 needs to be merged
|
Is there something i can to about the failed test AppVeyor? |
|
As this is a new feature, this pull request should be rebased on master. |
This enables browser Testingtools like mink to pass headerfiles while doing a form submmit
|
We rebased but the master test is still failing. |
|
Thank you @CFJulien. |
This PR was merged into the 4.1-dev branch.
Discussion
----------
[BrowserKit] Bypass Header Informations
This enables browser Testingtools like mink to pass headerfiles while doing a form submit
| Q | A
| ------------- | ---
| Branch? | master
| Bug fix? | yes
| New feature? | no
| BC breaks? | no
| Deprecations? | no
| Tests pass? | yes
| Fixed tickets |
| License | MIT
| Doc PR |
<!--
Write a short README entry for your feature/bugfix here (replace this comment block.)
This will help people understand your PR and can be used as a start of the Doc PR.
Additionally:
- Bug fixes must be submitted against the lowest branch where they apply
(lowest branches are regularly merged to upper ones so they get the fixes too).
- Features and deprecations must be submitted against the master branch.
-->
We tried to do some Browsertesting with Mink and Behat, something like:
```gherkin
Scenario Outline: greet in native language
Given the browser language is "<lang>"
And I called the website
When I fill in "PHP" for "username"
And I submit the form
Then I should see "<greeting>"
Examples:
| lang | greeting |
| en | Hello |
| de | Hallo |
| fr | Bonjour |
| zh | 你好 |
| ru | привет |
| be | Bonjour |
```
```php
public function theBrowserLanguageIs($arg1)
{
$this->getSession()->setRequestHeader('Accept', '*/*');
$this->getSession()->setRequestHeader('Accept-Language', $arg1);
}
```
While everything works fine with visit form submit didn't send the headers. At Mink theres also an open issue for that
minkphp/MinkBrowserKitDriver#79
but actually the problem was between the mink browserkit and the symfony client.
Commits
-------
fa2063e [BroserKit] Enable passthrew header information on submit
This enables browser Testingtools like mink to pass headerfiles while doing a form submit
We tried to do some Browsertesting with Mink and Behat, something like:
While everything works fine with visit form submit didn't send the headers. At Mink theres also an open issue for that
minkphp/MinkBrowserKitDriver#79
but actually the problem was between the mink browserkit and the symfony client.