Level 74
The way you are doing it with assertEquals is fine. There are however more assertions to be found here
I'm new to Laravel and am tinkering with tests. The following tests for a substring in the response:
$response = $this->get('/hello');
$response->assertSee('Hello World!');
I didn't find a assertion for equality so I'm wondering how to do this. The following seems to work:
$response = $this->get('/hello');
$content = $response->getContent();
$this->assertEquals('Hello World!', $content);
Is this a reasonable approach? I'm skeptical because this is really the result of me hunting through the source code to find what appeared to be an appropriate method. I think it goes like this:
$response is in TestResponse
TestResponse has a method __get($key) returning $this-baseResponse-{$key}
TestResponse having a getContent() methodTestResponse::getContent() is derived from the TestReponse::$baseResponse which is in Illuminate\Http\Response
Illuminate\Http\Response extends Symfony\Component\HttpFoundation\Response
Symfony\Component\HttpFoundation\Response has a getContent() method which returns the string property $content
I'm using
Thanks.
Please or to participate in this conversation.