1*a0801ffbSGreg Roach<?php 2*a0801ffbSGreg Roach/** 3*a0801ffbSGreg Roach * webtrees: online genealogy 4*a0801ffbSGreg Roach * Copyright (C) 2019 webtrees development team 5*a0801ffbSGreg Roach * This program is free software: you can redistribute it and/or modify 6*a0801ffbSGreg Roach * it under the terms of the GNU General Public License as published by 7*a0801ffbSGreg Roach * the Free Software Foundation, either version 3 of the License, or 8*a0801ffbSGreg Roach * (at your option) any later version. 9*a0801ffbSGreg Roach * This program is distributed in the hope that it will be useful, 10*a0801ffbSGreg Roach * but WITHOUT ANY WARRANTY; without even the implied warranty of 11*a0801ffbSGreg Roach * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12*a0801ffbSGreg Roach * GNU General Public License for more details. 13*a0801ffbSGreg Roach * You should have received a copy of the GNU General Public License 14*a0801ffbSGreg Roach * along with this program. If not, see <http://www.gnu.org/licenses/>. 15*a0801ffbSGreg Roach */ 16*a0801ffbSGreg Roachdeclare(strict_types=1); 17*a0801ffbSGreg Roach 18*a0801ffbSGreg Roachuse Fisharebest\Webtrees\GuestUser; 19*a0801ffbSGreg Roachuse Fisharebest\Webtrees\Http\RequestHandlers\SelectLanguage; 20*a0801ffbSGreg Roachuse Fisharebest\Webtrees\Services\UserService; 21*a0801ffbSGreg Roachuse Fisharebest\Webtrees\TestCase; 22*a0801ffbSGreg Roach 23*a0801ffbSGreg Roach/** 24*a0801ffbSGreg Roach * @covers \Fisharebest\Webtrees\Http\RequestHandlers\SelectLanguage 25*a0801ffbSGreg Roach */ 26*a0801ffbSGreg Roachclass SelectLanguageTest extends TestCase 27*a0801ffbSGreg Roach{ 28*a0801ffbSGreg Roach protected static $uses_database = true; 29*a0801ffbSGreg Roach 30*a0801ffbSGreg Roach /** 31*a0801ffbSGreg Roach * @return void 32*a0801ffbSGreg Roach */ 33*a0801ffbSGreg Roach public function testSelectLanguageForGuest(): void 34*a0801ffbSGreg Roach { 35*a0801ffbSGreg Roach $user = new GuestUser(); 36*a0801ffbSGreg Roach $handler = new SelectLanguage($user); 37*a0801ffbSGreg Roach $request = self::createRequest('POST', ['route' => 'language'], ['language' => 'fr']); 38*a0801ffbSGreg Roach $response = $handler->handle($request); 39*a0801ffbSGreg Roach 40*a0801ffbSGreg Roach self::assertSame(self::STATUS_NO_CONTENT, $response->getStatusCode()); 41*a0801ffbSGreg Roach } 42*a0801ffbSGreg Roach 43*a0801ffbSGreg Roach /** 44*a0801ffbSGreg Roach * @return void 45*a0801ffbSGreg Roach */ 46*a0801ffbSGreg Roach public function testSelectLanguageForUser(): void 47*a0801ffbSGreg Roach { 48*a0801ffbSGreg Roach $user_service = new UserService(); 49*a0801ffbSGreg Roach $user = $user_service->create('user', 'real', 'email', 'pass'); 50*a0801ffbSGreg Roach $handler = new SelectLanguage($user); 51*a0801ffbSGreg Roach $request = self::createRequest('POST', ['route' => 'language'], ['language' => 'fr']); 52*a0801ffbSGreg Roach $response = $handler->handle($request); 53*a0801ffbSGreg Roach 54*a0801ffbSGreg Roach self::assertSame(self::STATUS_NO_CONTENT, $response->getStatusCode()); 55*a0801ffbSGreg Roach } 56*a0801ffbSGreg Roach} 57*a0801ffbSGreg Roach 58