我不知道如何使用 dataProvider 进行带有文件字段的 laravel 测试:
public function requiredFormValidationProvider()
{
$faker = Faker::create('es_ES');
$password = $faker->password;
$avatar = File::create('avatar', 200);
$fields = [
['avatar', $avatar],
['name', $faker->name()],
['company', $faker->company],
['company_role', 'Administrador'],
['phone_number_1', $faker->phoneNumber],
['phone_number_2', $faker->phoneNumber],
['country_code', self::COUNTRY_CODE],
['language', 'es'],
['old_password', self::PASSWORD],
['password', $password],
['password_confirmation', $password],
];
return $fields;
}
“头像”字段是图像或文件,但我有一个错误:
1) Tests\Feature\Users\ProfileTest::testProfileEdit with data set #0 ('avatar', Illuminate\Http\Testing\File Object (...))
Session has unexpected error: avatar
Failed asserting that true is false.