08-06-2023, 04:25 PM
What I'm trying is to get the response content as string from an unit test with Lumen response:
```php
class MovieQueryTest extends TestCase
{
use DatabaseMigrations;
public function testCanSearch()
{
Movie::create([
'name' => 'Fast & Furious 8',
'alias' => 'Fast and Furious 8',
'year' => 2016
]);
$response = $this->post('/graphql', [
'query' => '{movies(search: "Fast & Furious"){data{name}}}'
]);
$response->getContent(); // Error: Call to undefined method MovieQueryTest::getContent()
$response->getOriginalContent(); // Error: Call to undefined method MovieQueryTest::getOriginalContent()
$response->content; // ErrorException: Undefined property: MovieQueryTest::$content
}
}
```
But I'm unable to figure out how to get the response content.
I don't want to use the Lumen `TestCase->seeJson()` method.
I just need to get the response content.
```php
class MovieQueryTest extends TestCase
{
use DatabaseMigrations;
public function testCanSearch()
{
Movie::create([
'name' => 'Fast & Furious 8',
'alias' => 'Fast and Furious 8',
'year' => 2016
]);
$response = $this->post('/graphql', [
'query' => '{movies(search: "Fast & Furious"){data{name}}}'
]);
$response->getContent(); // Error: Call to undefined method MovieQueryTest::getContent()
$response->getOriginalContent(); // Error: Call to undefined method MovieQueryTest::getOriginalContent()
$response->content; // ErrorException: Undefined property: MovieQueryTest::$content
}
}
```
But I'm unable to figure out how to get the response content.
I don't want to use the Lumen `TestCase->seeJson()` method.
I just need to get the response content.