I've upgraded from Laravel 5.0 to 5.1
Test suite works fine and I can run the phpunit command. But, when I'm start to test with the api test, I always get a foreach error.
class ExampleTest extends TestCase {
public function testLoginCredentials()
{
$this->post('/srv/plc/auth/login', ['data' => 'some data'])
->seeJson([
'authorized' => true,
]);
}
}
Above looks like the documentation: http://laravel.com/docs/5.1/testing#testing-json-apis
If I run my test via phpunit, I get the following error:
There was 1 error:
1) ExampleTest::testBasicExample
ErrorException: Invalid argument supplied for foreach()
/Applications/XAMPP/xamppfiles/htdocs/w/server/vendor/framework/src/Illuminate/Support/Arr.php:423
/Applications/XAMPP/xamppfiles/htdocs/w/server/vendor/framework/src/Illuminate/Support/helpers.php:301
/Applications/XAMPP/xamppfiles/htdocs/w/server/vendor/framework/src/Illuminate/Foundation/Testing/CrawlerTrait.php:365
/Applications/XAMPP/xamppfiles/htdocs/whennn/server/vendor/laravel/framework/src/Illuminate/Foundation/Testing/CrawlerTrait.php:352
/Applications/XAMPP/xamppfiles/htdocs/whennn/server/tests/ExampleTest.php:17
/Applications/XAMPP/xamppfiles/lib/php/PHPUnit/TextUI/Command.php:188
/Applications/XAMPP/xamppfiles/lib/php/PHPUnit/TextUI/Command.php:126
FAILURES!
Tests: 1, Assertions: 0, Errors: 1.
If I do a get request with $this->get, I get the same error. Same error with other endpoints.
$this->visit works fine.
After a lot of debugging....
I really don't know why seeJson must be an array.
I expected an 'assertion error', instead of an foreach error