post(route("admin:gallery:create")); $galleryId = $response->json('name'); $response = $this->get(route("access:gallery", ['id' => $galleryId])); $response->assertStatus(ResponseAlias::HTTP_OK); $response->assertJson(['name' => $galleryId, 'files' => []]); $response = $this->post( route("admin:file:upload", ['galleryId' => $galleryId]), ['file' => UploadedFile::fake()->image('avatar.jpg')] ); $responsed = $this->get(route("access:gallery", ['id' => $galleryId])); $response->assertStatus(ResponseAlias::HTTP_OK); $responsed->assertJson(['name' => $galleryId, 'files' => [$response->json('fileId')]]); return ['galleryId' => $galleryId, 'fileId' => $response->json('fileId')]; } /** * Тестируем скачивание файла * @test * @depends listGallery * @param array $data * @return void */ public function getPhoto(array $data): void { $response = $this->get(route("access:file", $data)); $response->assertStatus(ResponseAlias::HTTP_OK); $this->delete(route("admin:gallery:remove",['id'=>$data['galleryId']])); $response = $this->get(route("access:file", $data)); $response->assertStatus(ResponseAlias::HTTP_BAD_REQUEST); } }