1 回答

TA貢獻(xiàn)1852條經(jīng)驗(yàn) 獲得超1個(gè)贊
我設(shè)法找到了解決此問(wèn)題的方法。這是因?yàn)閒ile是一個(gè)數(shù)組,這意味著它在測(cè)試時(shí)需要有鍵和索引。
這顯示在下面的代碼中:
/** @test */
public function a_user_with_permission_can_add_files_to_the_library()
{
$this->withoutExceptionHandling();
Storage::fake('library');
$this->setupPermissions();
$user = factory(User::class)->create();
$user->assignRole('admin');
// Assert the uploading an image returns a 200 response
$this->actingAs($user)
->post(route('admin.library.store'), [
'category' => 'Some category',
'file' => [
0 => UploadedFile::fake()->create("test.jpg", 100),
1 => UploadedFile::fake()->create("test.png", 100),
2 => UploadedFile::fake()->create("test.doc", 100),
3 => UploadedFile::fake()->create("test.ppt", 100),
4 => UploadedFile::fake()->create("test.pdf", 100),
]
])->assertStatus(200);
$this->assertEquals(5, Library::count());
}
- 1 回答
- 0 關(guān)注
- 181 瀏覽
添加回答
舉報(bào)