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

[BrowserKit] Added test for followRedirect method (POST method) #19392

Closed
wants to merge 2 commits into from
Closed

[BrowserKit] Added test for followRedirect method (POST method) #19392

wants to merge 2 commits into from

Conversation

zomberg
Copy link
Contributor

@zomberg zomberg commented Jul 20, 2016

Q A
Branch? 2.7
Bug fix? no
New feature? no
BC breaks? no
Deprecations? no
Tests pass? yes
Fixed tickets ~
License MIT
Doc PR ~

Test covers 'else' branches in these conditions:

if (in_array($this->internalResponse->getStatus(), array(302, 303))) {
    $method = 'get';
    $files = array();
    $content = null;
} else {
    $method = $request->getMethod();
    $files = $request->getFiles();
    $content = $request->getContent();
}

if ('get' === strtolower($method)) {
    // Don't forward parameters for GET request as it should reach the redirection URI
    $parameters = array();
} else {
    $parameters = $request->getParameters();
}

@nicolas-grekas
Copy link
Member

👍

@javiereguiluz
Copy link
Member

👍

Status: reviewed

@zomberg thanks for another nice PR!

$client->request('POST', 'http://www.example.com/foo/foobar', $parameters, $files, $server, $content);

$this->assertEquals('http://www.example.com/redirected', $client->getRequest()->getUri(), '->followRedirect() follows a redirect with POST method');
$this->assertArrayHasKey('foo', $client->getRequest()->getParameters(), '->followRedirect() keeps parameters with POST method');
Copy link
Member

Choose a reason for hiding this comment

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

missing assertion about keeping the POST method

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Added.

@nicolas-grekas
Copy link
Member

Thank you @zomberg.

nicolas-grekas added a commit that referenced this pull request Jul 25, 2016
…method) (zomberg)

This PR was squashed before being merged into the 2.7 branch (closes #19392).

Discussion
----------

[BrowserKit] Added test for followRedirect method (POST method)

| Q             | A
| ------------- | ---
| Branch?       | 2.7
| Bug fix?      | no
| New feature?  | no
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets | ~
| License       | MIT
| Doc PR        | ~

Test covers 'else' branches in these conditions:
```php
if (in_array($this->internalResponse->getStatus(), array(302, 303))) {
    $method = 'get';
    $files = array();
    $content = null;
} else {
    $method = $request->getMethod();
    $files = $request->getFiles();
    $content = $request->getContent();
}

if ('get' === strtolower($method)) {
    // Don't forward parameters for GET request as it should reach the redirection URI
    $parameters = array();
} else {
    $parameters = $request->getParameters();
}
```

Commits
-------

2ace5d8 [BrowserKit] Added test for followRedirect method (POST method)
@zomberg zomberg deleted the browser_kit_test branch July 26, 2016 12:30
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

5 participants