mardi 27 octobre 2015

Seed test data for phpunit test - class name must be valid object or string

I'm trying to create and run tests for a Laravel 5.1 project.

Running test:

phpunit --filter testGetUser UserTest tests/UserTest.php

Gives me:

[Symfony\Component\Debug\Exception\FatalErrorException]
Class name must be a valid object or a string

private function seedUser()
{
    return [
        'email' => 'myemail',
        'password' => Hash::make("password"),
        ...
    ];
}

public function testGetUser()
{

    $user = User::create($this->seedUser());

    die(print_r($user));

I don't quite get the error as I am following the way I normally create a User model.

Call Stack: the error seems to be happening in the constructor of the User Model:

App\Data\Eloquent\Model->__construct() /Users/me/Sites/laravel/myapp/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Model.php:544



from Newest questions tagged laravel-5 - Stack Overflow http://ift.tt/1NyyEZV
via IFTTT

Aucun commentaire:

Enregistrer un commentaire