xref: /webtrees/tests/app/Http/RequestHandlers/MapDataImportActionTest.php (revision fab8f60ffe219e3a08aa73f137c194f4b2533bb9)
190949315SGreg Roach<?php
290949315SGreg Roach
390949315SGreg Roach/**
490949315SGreg Roach * webtrees: online genealogy
590949315SGreg Roach * Copyright (C) 2021 webtrees development team
690949315SGreg Roach * This program is free software: you can redistribute it and/or modify
790949315SGreg Roach * it under the terms of the GNU General Public License as published by
890949315SGreg Roach * the Free Software Foundation, either version 3 of the License, or
990949315SGreg Roach * (at your option) any later version.
1090949315SGreg Roach * This program is distributed in the hope that it will be useful,
1190949315SGreg Roach * but WITHOUT ANY WARRANTY; without even the implied warranty of
1290949315SGreg Roach * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1390949315SGreg Roach * GNU General Public License for more details.
1490949315SGreg Roach * You should have received a copy of the GNU General Public License
1589f7189bSGreg Roach * along with this program. If not, see <https://www.gnu.org/licenses/>.
1690949315SGreg Roach */
1790949315SGreg Roach
1890949315SGreg Roachdeclare(strict_types=1);
1990949315SGreg Roach
2090949315SGreg Roachnamespace Fisharebest\Webtrees\Http\RequestHandlers;
2190949315SGreg Roach
2290949315SGreg Roachuse Fig\Http\Message\RequestMethodInterface;
2390949315SGreg Roachuse Fig\Http\Message\StatusCodeInterface;
24*fab8f60fSGreg Roachuse Fisharebest\Webtrees\Services\MapDataService;
2590949315SGreg Roachuse Fisharebest\Webtrees\TestCase;
2690949315SGreg Roach
2790949315SGreg Roachuse function dirname;
2890949315SGreg Roach
2990949315SGreg Roach/**
3090949315SGreg Roach * Test the location import.
3190949315SGreg Roach *
3290949315SGreg Roach * @covers \Fisharebest\Webtrees\Http\RequestHandlers\MapDataImportAction
3390949315SGreg Roach */
3490949315SGreg Roachclass MapDataImportActionTest extends TestCase
3590949315SGreg Roach{
3690949315SGreg Roach    protected static $uses_database = true;
3790949315SGreg Roach
3890949315SGreg Roach    /**
3990949315SGreg Roach     * @return void
4090949315SGreg Roach     */
4190949315SGreg Roach    public function testImportAction(): void
4290949315SGreg Roach    {
43*fab8f60fSGreg Roach        $map_data_service = new MapDataService();
4490949315SGreg Roach        $csv              = $this->createUploadedFile(dirname(__DIR__, 3) . '/data/places.csv', 'text/csv');
45*fab8f60fSGreg Roach        $handler          = new MapDataImportAction($map_data_service);
4690949315SGreg Roach        $request          = self::createRequest(RequestMethodInterface::METHOD_POST, [], [], ['serverfile' => $csv]);
4790949315SGreg Roach        $response         = $handler->handle($request);
4890949315SGreg Roach
4990949315SGreg Roach        self::assertSame(StatusCodeInterface::STATUS_FOUND, $response->getStatusCode());
5090949315SGreg Roach    }
5190949315SGreg Roach}
52