Open hskrasek opened 9 years ago
I m getting the same error:
ErrorException: Undefined property: CompanyTest::$response
/var/www/html/intrepid-api/vendor/laracasts/integrated/src/Extensions/Traits/LaravelTestCase.php:113 /var/www/html/intrepid-api/vendor/laracasts/integrated/src/Extensions/Traits/ApiRequests.php:170 /var/www/html/intrepid-api/app/tests/controllers/CompanyTest.php:9
This is the test function:
public function testBasicExample()
{
$token = Token::find(1);
$this->get('v1/companies?token='.$token->token)->seeJson();
}
This error happens because the class Illuminate\Foundation\Testing\ApplicationTrait
does not have the $response
property in Laravel 4. But you can add it in like this:
Providing you're extending Laracasts\Integrated\Extensions\Laravel
in TestCase
class, try and add this method in app/tests/TestCase.php:
public function __get($name)
{
if ($name === 'response') return $this->client->getResponse();
}
If you extend Laracasts\Integrated\Extensions\Laravel
directly in your test class, just add the method above in it
Thanks Stephan, that solved the problem.
@arrahman you're welcome :)
+1
+1 Awesome. Thank you!
+1, nice quick solution. Guessing this package isn't going to be updated since it got integrated with L5. All good though.
I am trying to test a JSON API written in Laravel 4.2. I have the following test case below:
And when I run the tests I get the following in the terminal:
Not sure if this is a bug, or something I am doing incorrectly.