I have clean install of Laravel 5.0, and I have issues with phpunit tests.
If I create a test for user model, I'm getting error - User class not found.
If I test controllers, works fine, controller classes are detected.
As a temporary workaround, just to test if it is working, I added class User inside UserTest.php.
I tried to add folder models in app folder, placing the class inside, similar as it was in Laravel 4.2, changed composer.json as well, ran composer dump-autoload, but it didn't work.
class UserTest extends TestCase
public function setUp()
public function testEmptyNameFailExpected()
$user = new User;
$user->name = '';
$result = $user->isValid();
use Illuminate\Contracts\Auth\Authenticatable as AuthenticatableContract;
use Illuminate\Contracts\Auth\CanResetPassword as CanResetPasswordContract;
class User extends Model implements AuthenticatableContract, CanResetPasswordContract
use Authenticatable, CanResetPassword;
* The database table used by the model.
* @var string
protected $table = 'users';
* The attributes that are mass assignable.
* @var array
protected $fillable = ['name', 'email', 'password'];
public static $rules = [ 'name' => 'required|min:3' ];
* The attributes excluded from the model's JSON form.
* @var array
protected $hidden = ['password', 'remember_token'];
* validate input
* @return bool
public function isValid()
$validation = Validator::make($this->attributes, static ::$rules);
if ($validation->passes()) return true;
$this->errors = $validation->messages();
I noticed two problems with your code:
You said your test folder is
That is incorrect. In a clean install of Laravel 5.0 - the test class is in the base folder - not the
app folder - so it should be
Also - your User is namespaced in Laravel 5.0 - so your code will need to be
$user = new \App\User;