xref: /webtrees/tests/app/Http/RequestHandlers/UserEditActionTest.php (revision cd94ca6664a143daa60d394f7b9cad6d42ec1b1d)
14c3563c0SGreg Roach<?php
24c3563c0SGreg Roach
34c3563c0SGreg Roach/**
44c3563c0SGreg Roach * webtrees: online genealogy
589f7189bSGreg Roach * Copyright (C) 2021 webtrees development team
64c3563c0SGreg Roach * This program is free software: you can redistribute it and/or modify
74c3563c0SGreg Roach * it under the terms of the GNU General Public License as published by
84c3563c0SGreg Roach * the Free Software Foundation, either version 3 of the License, or
94c3563c0SGreg Roach * (at your option) any later version.
104c3563c0SGreg Roach * This program is distributed in the hope that it will be useful,
114c3563c0SGreg Roach * but WITHOUT ANY WARRANTY; without even the implied warranty of
124c3563c0SGreg Roach * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
134c3563c0SGreg Roach * GNU General Public License for more details.
144c3563c0SGreg 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/>.
164c3563c0SGreg Roach */
174c3563c0SGreg Roach
184c3563c0SGreg Roachdeclare(strict_types=1);
194c3563c0SGreg Roach
204c3563c0SGreg Roachnamespace Fisharebest\Webtrees\Http\RequestHandlers;
214c3563c0SGreg Roach
224c3563c0SGreg Roachuse Fig\Http\Message\RequestMethodInterface;
234c3563c0SGreg Roachuse Fig\Http\Message\StatusCodeInterface;
244c3563c0SGreg Roachuse Fisharebest\Webtrees\Services\EmailService;
254c3563c0SGreg Roachuse Fisharebest\Webtrees\Services\TreeService;
264c3563c0SGreg Roachuse Fisharebest\Webtrees\Services\UserService;
274c3563c0SGreg Roachuse Fisharebest\Webtrees\TestCase;
284c3563c0SGreg Roach
294c3563c0SGreg Roach/**
304c3563c0SGreg Roach * Test UserEditActionTest class.
314c3563c0SGreg Roach *
324c3563c0SGreg Roach * @covers \Fisharebest\Webtrees\Http\RequestHandlers\UserEditAction
334c3563c0SGreg Roach */
344c3563c0SGreg Roachclass UserEditActionTest extends TestCase
354c3563c0SGreg Roach{
36*cd94ca66SGreg Roach    protected static bool $uses_database = true;
374c3563c0SGreg Roach
384c3563c0SGreg Roach    /**
394c3563c0SGreg Roach     * @return void
404c3563c0SGreg Roach     */
414c3563c0SGreg Roach    public function testHandler(): void
424c3563c0SGreg Roach    {
434c3563c0SGreg Roach        $mail_service = new EmailService();
444c3563c0SGreg Roach        $tree_service = new TreeService();
454c3563c0SGreg Roach        $user_service = new UserService();
464c3563c0SGreg Roach        $user         = $user_service->create('user', 'real', 'email', 'pass');
474c3563c0SGreg Roach        $handler      = new UserEditAction($mail_service, $tree_service, $user_service);
484c3563c0SGreg Roach        $request      = self::createRequest(RequestMethodInterface::METHOD_POST, [], [
494c3563c0SGreg Roach            'user_id'        => $user->id(),
504c3563c0SGreg Roach            'username'       => '',
514c3563c0SGreg Roach            'real_name'      => '',
524c3563c0SGreg Roach            'email'          => '',
534c3563c0SGreg Roach            'theme'          => '',
544c3563c0SGreg Roach            'password'       => '',
554c3563c0SGreg Roach            'language'       => '',
564c3563c0SGreg Roach            'timezone'       => '',
574c3563c0SGreg Roach            'comment'        => '',
584c3563c0SGreg Roach            'contact-method' => '',
594c3563c0SGreg Roach            'auto_accept'    => '',
604c3563c0SGreg Roach            'canadmin'       => '',
614c3563c0SGreg Roach            'visible-online' => '',
624c3563c0SGreg Roach            'verified'       => '',
634c3563c0SGreg Roach            'approved'       => '',
644c3563c0SGreg Roach        ])
654c3563c0SGreg Roach            ->withAttribute('user', $user);
664c3563c0SGreg Roach        $response     = $handler->handle($request);
674c3563c0SGreg Roach
684c3563c0SGreg Roach        self::assertSame(StatusCodeInterface::STATUS_FOUND, $response->getStatusCode());
694c3563c0SGreg Roach    }
704c3563c0SGreg Roach}
71