There is a method in the controller:

public function getById(Country $country) { return $country; } 

when accessing through the browser everything is OK, the Country model is normally loaded by its identifier. In phpunit, it does not load by the passed identifier (in $ country, an empty model without attributes). If you change the controller method to

  public function getById($country) { return Country::find($country); } 

then everything works correctly in phpunit. There was no such problem in Laravel 5.2, I tried phpunit 4 and 5 versions.

    1 answer 1

    If suddenly someone has the same problem - it turned out because of the use of the WithoutMiddleware trait in tests.