16c21f8beSGreg Roach<?php 26c21f8beSGreg Roach 36c21f8beSGreg Roach/** 46c21f8beSGreg Roach * webtrees: online genealogy 5d11be702SGreg Roach * Copyright (C) 2023 webtrees development team 66c21f8beSGreg Roach * This program is free software: you can redistribute it and/or modify 76c21f8beSGreg Roach * it under the terms of the GNU General Public License as published by 86c21f8beSGreg Roach * the Free Software Foundation, either version 3 of the License, or 96c21f8beSGreg Roach * (at your option) any later version. 106c21f8beSGreg Roach * This program is distributed in the hope that it will be useful, 116c21f8beSGreg Roach * but WITHOUT ANY WARRANTY; without even the implied warranty of 126c21f8beSGreg Roach * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 136c21f8beSGreg Roach * GNU General Public License for more details. 146c21f8beSGreg Roach * You should have received a copy of the GNU General Public License 156c21f8beSGreg Roach * along with this program. If not, see <https://www.gnu.org/licenses/>. 166c21f8beSGreg Roach */ 176c21f8beSGreg Roach 186c21f8beSGreg Roachdeclare(strict_types=1); 196c21f8beSGreg Roach 206c21f8beSGreg Roachnamespace Fisharebest\Webtrees\Http\RequestHandlers; 216c21f8beSGreg Roach 226c21f8beSGreg Roachuse Fig\Http\Message\RequestMethodInterface; 236c21f8beSGreg Roachuse Fig\Http\Message\StatusCodeInterface; 246c21f8beSGreg Roachuse Fisharebest\Webtrees\Services\DatatablesService; 256c21f8beSGreg Roachuse Fisharebest\Webtrees\Services\SiteLogsService; 266c21f8beSGreg Roachuse Fisharebest\Webtrees\TestCase; 276c21f8beSGreg Roachuse Illuminate\Database\Query\Builder; 28202c018bSGreg Roachuse PHPUnit\Framework\Attributes\CoversClass; 296c21f8beSGreg Roachuse Psr\Http\Message\ResponseInterface; 306c21f8beSGreg Roach 31202c018bSGreg Roach#[CoversClass(SiteLogsData::class)] 326c21f8beSGreg Roachclass SiteLogsDataTest extends TestCase 336c21f8beSGreg Roach{ 346c21f8beSGreg Roach public function testResponse(): void 356c21f8beSGreg Roach { 366c21f8beSGreg Roach $request = self::createRequest( 376c21f8beSGreg Roach RequestMethodInterface::METHOD_GET, 386c21f8beSGreg Roach ['tree' => 'a', 'from' => 'b', 'to' => 'c', 'type' => 'd', 'text' => 'e', 'ip' => 'f', 'username' => 'g'] 396c21f8beSGreg Roach ); 406c21f8beSGreg Roach 41*62ff2f18SGreg Roach $query = $this->createMock(Builder::class); 426c21f8beSGreg Roach 43*62ff2f18SGreg Roach $site_logs_service = $this->createMock(SiteLogsService::class); 446c21f8beSGreg Roach $site_logs_service->method('logsQuery')->willReturn($query); 456c21f8beSGreg Roach 46*62ff2f18SGreg Roach $response = $this->createMock(ResponseInterface::class); 476c21f8beSGreg Roach $response->method('getStatusCode')->willReturn(StatusCodeInterface::STATUS_OK); 486c21f8beSGreg Roach 49*62ff2f18SGreg Roach $data_tables_service = $this->createMock(DatatablesService::class); 506c21f8beSGreg Roach $data_tables_service->method('handleQuery')->willReturn($response); 516c21f8beSGreg Roach 526c21f8beSGreg Roach $handler = new SiteLogsData($data_tables_service, $site_logs_service); 536c21f8beSGreg Roach $response = $handler->handle($request); 546c21f8beSGreg Roach 556c21f8beSGreg Roach self::assertSame(StatusCodeInterface::STATUS_OK, $response->getStatusCode()); 566c21f8beSGreg Roach } 576c21f8beSGreg Roach} 58