1*4c3563c0SGreg Roach<?php 2*4c3563c0SGreg Roach 3*4c3563c0SGreg Roach/** 4*4c3563c0SGreg Roach * webtrees: online genealogy 5*4c3563c0SGreg Roach * Copyright (C) 2020 webtrees development team 6*4c3563c0SGreg Roach * This program is free software: you can redistribute it and/or modify 7*4c3563c0SGreg Roach * it under the terms of the GNU General Public License as published by 8*4c3563c0SGreg Roach * the Free Software Foundation, either version 3 of the License, or 9*4c3563c0SGreg Roach * (at your option) any later version. 10*4c3563c0SGreg Roach * This program is distributed in the hope that it will be useful, 11*4c3563c0SGreg Roach * but WITHOUT ANY WARRANTY; without even the implied warranty of 12*4c3563c0SGreg Roach * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13*4c3563c0SGreg Roach * GNU General Public License for more details. 14*4c3563c0SGreg Roach * You should have received a copy of the GNU General Public License 15*4c3563c0SGreg Roach * along with this program. If not, see <http://www.gnu.org/licenses/>. 16*4c3563c0SGreg Roach */ 17*4c3563c0SGreg Roach 18*4c3563c0SGreg Roachdeclare(strict_types=1); 19*4c3563c0SGreg Roach 20*4c3563c0SGreg Roachnamespace Fisharebest\Webtrees\Http\RequestHandlers; 21*4c3563c0SGreg Roach 22*4c3563c0SGreg Roachuse Fig\Http\Message\RequestMethodInterface; 23*4c3563c0SGreg Roachuse Fig\Http\Message\StatusCodeInterface; 24*4c3563c0SGreg Roachuse Fisharebest\Webtrees\Services\EmailService; 25*4c3563c0SGreg Roachuse Fisharebest\Webtrees\Services\TreeService; 26*4c3563c0SGreg Roachuse Fisharebest\Webtrees\Services\UserService; 27*4c3563c0SGreg Roachuse Fisharebest\Webtrees\TestCase; 28*4c3563c0SGreg Roach 29*4c3563c0SGreg Roach/** 30*4c3563c0SGreg Roach * Test UserEditActionTest class. 31*4c3563c0SGreg Roach * 32*4c3563c0SGreg Roach * @covers \Fisharebest\Webtrees\Http\RequestHandlers\UserEditAction 33*4c3563c0SGreg Roach */ 34*4c3563c0SGreg Roachclass UserEditActionTest extends TestCase 35*4c3563c0SGreg Roach{ 36*4c3563c0SGreg Roach protected static $uses_database = true; 37*4c3563c0SGreg Roach 38*4c3563c0SGreg Roach /** 39*4c3563c0SGreg Roach * @return void 40*4c3563c0SGreg Roach */ 41*4c3563c0SGreg Roach public function testHandler(): void 42*4c3563c0SGreg Roach { 43*4c3563c0SGreg Roach $mail_service = new EmailService(); 44*4c3563c0SGreg Roach $tree_service = new TreeService(); 45*4c3563c0SGreg Roach $user_service = new UserService(); 46*4c3563c0SGreg Roach $user = $user_service->create('user', 'real', 'email', 'pass'); 47*4c3563c0SGreg Roach $handler = new UserEditAction($mail_service, $tree_service, $user_service); 48*4c3563c0SGreg Roach $request = self::createRequest(RequestMethodInterface::METHOD_POST, [], [ 49*4c3563c0SGreg Roach 'user_id' => $user->id(), 50*4c3563c0SGreg Roach 'username' => '', 51*4c3563c0SGreg Roach 'real_name' => '', 52*4c3563c0SGreg Roach 'email' => '', 53*4c3563c0SGreg Roach 'theme' => '', 54*4c3563c0SGreg Roach 'password' => '', 55*4c3563c0SGreg Roach 'language' => '', 56*4c3563c0SGreg Roach 'timezone' => '', 57*4c3563c0SGreg Roach 'comment' => '', 58*4c3563c0SGreg Roach 'contact-method' => '', 59*4c3563c0SGreg Roach 'auto_accept' => '', 60*4c3563c0SGreg Roach 'canadmin' => '', 61*4c3563c0SGreg Roach 'visible-online' => '', 62*4c3563c0SGreg Roach 'verified' => '', 63*4c3563c0SGreg Roach 'approved' => '', 64*4c3563c0SGreg Roach ]) 65*4c3563c0SGreg Roach ->withAttribute('user', $user); 66*4c3563c0SGreg Roach $response = $handler->handle($request); 67*4c3563c0SGreg Roach 68*4c3563c0SGreg Roach self::assertSame(StatusCodeInterface::STATUS_FOUND, $response->getStatusCode()); 69*4c3563c0SGreg Roach } 70*4c3563c0SGreg Roach} 71