Skip to content
This repository was archived by the owner on Apr 20, 2021. It is now read-only.

Fix set content headers#218

Merged
sanpii merged 4 commits intoBehatch:masterfrom
razbakov:217-content-type-header
Jan 25, 2018
Merged

Fix set content headers#218
sanpii merged 4 commits intoBehatch:masterfrom
razbakov:217-content-type-header

Conversation

@razbakov
Copy link
Copy Markdown
Contributor

CONTENT_* are not prefixed with HTTP_ in PHP when building $_SERVER
Code taken from Behat\Mink\Driver\BrowserKitDriver::setRequestHeader

Closes #217

@razbakov razbakov mentioned this pull request Aug 31, 2017
@sanpii
Copy link
Copy Markdown
Member

sanpii commented Aug 31, 2017

Please, make one PR per fonctionnality/fix.

Moreover, it’s not a good idea to depends on an extrenal service for the test.

Thank you.

Comment thread .travis.yml
- 7.0
- 7.1
- nightly
- hhvm
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Instead of removing ci-tests on hhvm we should actually follow the advice of travis:
HHVM is no longer supported on Ubuntu Precise. Please consider using Trusty with `dist: trusty`.

Comment thread src/Context/RestContext.php Outdated
$expected = str_replace('\\"', '"', $expected);
$actual = $this->request->getContent();
$message = "The string '$expected' is not equal to the response of the current page";
$message = "Response is: $actual";
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Now we don't see the $expected anymore in the message.
Maybe something like "The response of the current page is not '$expected', it is: $actual"

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

You see expected always right before the error message.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

That depends on your output formt. With the format (-f) pretty (which is default) you see the expected before the error message, but not with e.g. progress or PhpStormBehatFormatter.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

What about the following methods?

It make more sense to see $actual in error message, rather than $expected

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Yes, the $actual should be in the message. But in my opinion, also the $expected to make life easier when something fails.

Comment thread src/Context/RestContext.php Outdated
"The header '$name' doesn't contain '$value'"
$actual = $this->request->getHttpHeader($name);
$this->assertContains($value, $actual,
"The header '$name' value is '$actual'"
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Same as above, now missing the expected value.
Maybe something like "The header '$name' doesn't contain '$value', it is: $actual"

@mitalcoi
Copy link
Copy Markdown

also wait for this merge 👍

CONTENT_* are not prefixed with HTTP_ in PHP when building $_SERVER
Code taken from Behat\Mink\Driver\BrowserKitDriver::setRequestHeader

Closes #217
in order to test Goutte Client
@razbakov
Copy link
Copy Markdown
Contributor Author

@mitalcoi @elkangaroo @sanpii please review again, I made suggested changes.
I can't split those commits to different PRs, because they all are related to this issue.

Comment thread src/Context/RestContext.php Outdated
public function theHeaderShouldBeContains($name, $value)
{
trigger_error(
sprintf('The %s function is deprecated since version 3.0 and will be removed in 3.1. Use the %s::theHeaderShouldContain function instead.', __METHOD__, __CLASS__),
Copy link
Copy Markdown
Member

@sanpii sanpii Jan 19, 2018

Choose a reason for hiding this comment

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

Deprecated since 3.1 and removed n 4.0 instead.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

fixed

Copy link
Copy Markdown
Contributor Author

@razbakov razbakov Jan 19, 2018

Choose a reason for hiding this comment

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

fixed to 3.1 and 4.0

@Behatch Behatch deleted a comment from razbakov Jan 19, 2018
- fix function name theHeaderShouldContain (was theHeaderShouldBeContains)
- add $actual to assert exception to simplify debugging
@OskarStark
Copy link
Copy Markdown
Contributor

any idea why travis failed?

@sanpii
Copy link
Copy Markdown
Member

sanpii commented Jan 19, 2018

@OskarStark it looks like a problem with selenium. Maybe a chromium update?

@OskarStark
Copy link
Copy Markdown
Contributor

Could you restart the build?

I tried the change manually in my project and it works.
If it is a problem with the current selenium version, can you merge and create a release anyway?

If you need help, you can add me as a collaborator to this project, I'm still member of the Sonata-Project ;-)

@OskarStark
Copy link
Copy Markdown
Contributor

Closes #212

@sanpii sanpii added this to the 3.1 milestone Jan 25, 2018
@sanpii sanpii merged commit 40c2346 into Behatch:master Jan 25, 2018
@razbakov razbakov deleted the 217-content-type-header branch January 25, 2018 10:28
@OskarStark
Copy link
Copy Markdown
Contributor

any news here?

Is this PR (which is not release yet) maybe related to the travis problem?
Behat/MinkExtension#311

I had the same issue and if I apply the change manually it worked for me 👍

@OskarStark
Copy link
Copy Markdown
Contributor

@sanpii https://github.com/Behat/MinkExtension/releases/tag/2.3.1 is released and should fix this error.

Can you please restart the travis job?

@sanpii
Copy link
Copy Markdown
Member

sanpii commented Mar 5, 2018

@OskarStark I relaunched the test, they still fails…

Help welcome: #242

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Not possible to set content-type header

5 participants