. */ declare(strict_types=1); namespace Fisharebest\Webtrees\Http\RequestHandlers; use Fig\Http\Message\RequestMethodInterface; use Fig\Http\Message\StatusCodeInterface; use Fisharebest\Webtrees\Services\DatatablesService; use Fisharebest\Webtrees\Services\GedcomImportService; use Fisharebest\Webtrees\Services\LinkedRecordService; use Fisharebest\Webtrees\Services\MediaFileService; use Fisharebest\Webtrees\Services\TreeService; use Fisharebest\Webtrees\TestCase; use Illuminate\Support\Collection; use PHPUnit\Framework\Attributes\CoversClass; #[CoversClass(ManageMediaData::class)] class ManageMediaDataTest extends TestCase { protected static bool $uses_database = true; public function testDataLocal(): void { $datatables_service = new DatatablesService(); $gedcom_import_service = new GedcomImportService(); $linked_record_service = new LinkedRecordService(); $media_file_service = $this->createMock(MediaFileService::class); $media_file_service->method('allMediaFolders')->willReturn(new Collection(['media/'])); $tree_service = new TreeService($gedcom_import_service); $handler = new ManageMediaData($datatables_service, $linked_record_service, $media_file_service, $tree_service); $request = self::createRequest(RequestMethodInterface::METHOD_GET, [ 'files' => 'local', 'media_folder' => 'media/', 'subfolders' => 'include', 'search' => ['value' => ''], 'start' => '0', 'length' => '10', ]); $response = $handler->handle($request); self::assertSame(StatusCodeInterface::STATUS_OK, $response->getStatusCode()); } public function testDataExternal(): void { $datatables_service = new DatatablesService(); $gedcom_import_service = new GedcomImportService(); $linked_record_service = new LinkedRecordService(); $media_file_service = $this->createMock(MediaFileService::class); $media_file_service->method('allMediaFolders')->willReturn(new Collection(['media/'])); $tree_service = new TreeService($gedcom_import_service); $handler = new ManageMediaData($datatables_service, $linked_record_service, $media_file_service, $tree_service); $request = self::createRequest(RequestMethodInterface::METHOD_GET, [ 'files' => 'local', 'media_folder' => 'media/', 'subfolders' => 'include', 'search' => ['value' => ''], 'start' => '0', 'length' => '10', ]); $response = $handler->handle($request); self::assertSame(StatusCodeInterface::STATUS_OK, $response->getStatusCode()); } public function testDataUnused(): void { $datatables_service = new DatatablesService(); $gedcom_import_service = new GedcomImportService(); $linked_record_service = new LinkedRecordService(); $media_file_service = $this->createMock(MediaFileService::class); $media_file_service->method('allMediaFolders')->willReturn(new Collection(['media/'])); $tree_service = new TreeService($gedcom_import_service); $handler = new ManageMediaData($datatables_service, $linked_record_service, $media_file_service, $tree_service); $request = self::createRequest(RequestMethodInterface::METHOD_GET, [ 'files' => 'local', 'media_folder' => 'media/', 'subfolders' => 'include', 'search' => ['value' => ''], 'start' => '0', 'length' => '10', ]); $response = $handler->handle($request); self::assertSame(StatusCodeInterface::STATUS_OK, $response->getStatusCode()); } }