Skip to content
This repository has been archived by the owner on Sep 16, 2021. It is now read-only.

Fix randomly failing test #255

Merged
merged 1 commit into from
Aug 27, 2015
Merged

Fix randomly failing test #255

merged 1 commit into from
Aug 27, 2015

Conversation

wouterj
Copy link
Member

@wouterj wouterj commented Aug 27, 2015

This tests randomly failed on HHVM. I have no idea why, but the tests was a bit... strange.

The controller passes $templating->render to new Response(), which is perfect (as render() returns a string).

The tests however mocked the render method and returned a Response object. This results in: new Response(new Response(...));. This is a bit strange and not compliant with the API docs of this method.

It works, as Response typecasts the object to a string and Response::__toString returns, besides lots of other stuff, also the response content. This however, did fail for HHVM sometimes.

Besides that, this method actually made the test test something. Before, it just tested that the templating was used, but not if the correct templates are used in the render call.


/** @var Response $response */
$response = $this->controller->indexAction('xml', 'test');

$this->assertEquals(new Response('some-xml-string'), $response->getContent());
$this->assertEquals('some-xml-string', $response->getContent());
Copy link
Member Author

Choose a reason for hiding this comment

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

this was the actual cause of the random test failures: We compared a Response object to $response->getContent(). That means that PHP/HHVM needed to convert the first argument to a string before comparing with getContent. Some versions of HHVM did not do this and threw an exception: Comparing an object with a string

Copy link
Member

Choose a reason for hiding this comment

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

lsmith77 added a commit that referenced this pull request Aug 27, 2015
@lsmith77 lsmith77 merged commit 37c25b7 into master Aug 27, 2015
@lsmith77 lsmith77 removed the wip/poc label Aug 27, 2015
@lsmith77 lsmith77 deleted the fix_test branch August 27, 2015 14:38
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants