xref: /webtrees/tests/app/Http/RequestHandlers/MapDataImportActionTest.php (revision b50dba3a86d260384d07c30bedf82d8e78ab49f7)
190949315SGreg Roach<?php
290949315SGreg Roach
390949315SGreg Roach/**
490949315SGreg Roach * webtrees: online genealogy
5d11be702SGreg Roach * Copyright (C) 2023 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;
2490949315SGreg Roachuse Fisharebest\Webtrees\TestCase;
2537df441aSGreg Roachuse Nyholm\Psr7\Factory\Psr17Factory;
26*202c018bSGreg Roachuse PHPUnit\Framework\Attributes\CoversClass;
27*202c018bSGreg Roach
2890949315SGreg Roachuse function dirname;
2990949315SGreg Roach
30*202c018bSGreg Roach#[CoversClass(MapDataImportAction::class)]
3190949315SGreg Roachclass MapDataImportActionTest extends TestCase
3290949315SGreg Roach{
33cd94ca66SGreg Roach    protected static bool $uses_database = true;
3490949315SGreg Roach
3590949315SGreg Roach    public function testImportAction(): void
3690949315SGreg Roach    {
3790949315SGreg Roach        $csv              = $this->createUploadedFile(dirname(__DIR__, 3) . '/data/places.csv', 'text/csv');
3837df441aSGreg Roach        $handler          = new MapDataImportAction(new Psr17Factory());
3937df441aSGreg Roach        $request          = self::createRequest(RequestMethodInterface::METHOD_POST, [], ['options' => 'add', 'source' => 'client'], ['localfile' => $csv]);
4090949315SGreg Roach        $response         = $handler->handle($request);
4190949315SGreg Roach
4290949315SGreg Roach        self::assertSame(StatusCodeInterface::STATUS_FOUND, $response->getStatusCode());
4390949315SGreg Roach    }
4490949315SGreg Roach}
45