1
我正在使用模型工廠來測試登錄頁面,但是當我運行測試時,我得到一個無效的參數異常。我的模型廠:InvalidArgumentException:意外的值和尾隨數據 - Laravel
$factory->define(App\User::class, function (Faker\Generator $faker) {
return [
'name' => $faker->name,
'email' => $faker->email,
'password' => bcrypt(str_random(60)),
'remember_token' => str_random(100),
'created_at' => '2016-01-20 11:15:35',
'updated_at' => '2016-01-20 12:35:15',
];
});
我的錯誤信息:
InvalidArgumentException: Unexpected data found.
Unexpected data found.
Unexpected data found.
Unexpected data found.
A two digit minute could not be found
A two digit second could not be found
Trailing data
任何人都知道我在哪裏出了錯?
編輯:
Field | Type | Null | Key | Default
name | varchar(255) | NO | | NULL
email | varchar(255) | NO | UNI | NULL
password | varchar(60) | NO | | NULL
remember_token | varchar(100) | YES | | NULL
created_at | timestamp | NO | | 0000-00-00 00:00:00
updated_at | timestamp | NO | | 0000-00-00 00:00:00
編輯2:
public function testLogin()
{
$user = factory(App\User::class)->create
([
'email'=>'[email protected]',
$HashedPassword = Hash::make('password'),
'password' => $HashedPassword
]);
$this->visit('/login')
->type('[email protected]', 'email')
->type('password', 'password')
->press('Login')
->seePageIs('/home');
}
你是什麼樣的模式? –
現在只需加上 – Niall
即可。你打電話給你的工廠怎麼樣?你還有什麼其他的錯誤? –