private function getMediaLibrary() { $library = MediaLibrary::first(); if (!$library) { return MediaLibrary::create(['name' => 'image-library']); } return $library; }
/** * @test */ public function an_image_file_can_be_uploaded_and_successfully_associated_with_a_library() { $this->withoutMiddleware(); $response = $this->call('POST', '/admin/api/blog/images', [], [], ['file' => $this->prepareFileUpload('tests/testpic1.png', 'testpic1')]); $this->assertEquals(200, $response->status()); $library = MediaLibrary::firstOrFail(); $this->assertEquals(1, $library->getMedia()->count(), 'should be one image in library'); $library->clearMediaCollection(); }