dimanche 20 mars 2016

phpunit on laravel returns

when I run phpunit on the UserTest.php class that is defined so :

use App\User;

class UserTest extends TestCase
{
    protected $user;

    public function setUp() {
        $this->user = factory(User::class)->create();
    }

    /** @test */
    public function returns_full_name (){
        return $this->assertEquals('rakibi anass',$this->user->full_name());
    }

}

I get this error :

PHP Fatal error: Call to a member function make() on null in /home/vagrant/Sites/troisdemis/vendor/laravel/framework/src/Illuminate/Foundation/helpers.php on line 62

and this is how I defined the Factory::user

$factory->define(App\User::class, function ($faker) {
    return [
       'firstname' => 'anass',
       'lastname'  => 'rakibi'
       'email'     => 'anass.rakibi@gmail.com',
       'password'  => 'secret',
       'remember_token' => str_random(10),
    ];
});



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire