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

First example is incorrect #36

Open
NigelGreenway opened this issue Feb 9, 2017 · 4 comments
Open

First example is incorrect #36

NigelGreenway opened this issue Feb 9, 2017 · 4 comments

Comments

@NigelGreenway
Copy link

When trying the same as the first example you have in your README.md file, calling $this->client->response->getBody()->getContent() returns "" in my test meaning the following does not work:

$this->client->get('/');
$this->assertEquals('Hello World', $this->client->response->getBody());

Your example code:

class VersionTest extends LocalWebTestCase
{
    public function testVersion()
    {
        $this->client->get('/version');
        $this->assertEquals(200, $this->client->response->getStatusCode());
        $this->assertEquals($this->app->config('version'), $this->client->response->getBody());
    }
}

We have our own version (replicated) of WebTestCase as we have our own config and setup process.

To get it working, our test make-up is the following:

    public function testHomePage()
    {
        $body = $this->client->get('/');
        $this->assertEquals(200, $this->client->response->getStatusCode());
        $this->assertContains('Hello world', $body);
        $this->assertContains('<title>Welcome</title>', $body);
    }

The main difference with mine is that I am assigning $body = $this->client->get('/'); as ::get calls ::request but ends with return (string)$this->response->getBody();.

Am I missing something or have the docs not been updated? I can PR on the fix in the docs providing I am not missing something first.

@craig-davis
Copy link
Contributor

It will be next week before I can investigate this. I don't particularly like having to fetch into a temporary $body variable. It sounds like something else may be going on.

@NigelGreenway
Copy link
Author

Hi @craig-davis, no worries. If I can get chance I will clone and see what I can find if that helps, but I too am pretty stretched out with spare time at the moment.

@craig-davis
Copy link
Contributor

I've made you a contributor. If you're blocked by something, go ahead and be a responsible member of the group :)

@NigelGreenway
Copy link
Author

@craig-davis thank you, much appreciated.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants