diff options
Diffstat (limited to 'tests/app/Http')
31 files changed, 214 insertions, 220 deletions
diff --git a/tests/app/Http/Controllers/Admin/FixLevel0MediaControllerTest.php b/tests/app/Http/Controllers/Admin/FixLevel0MediaControllerTest.php index 62bd43423b..57b18684e2 100644 --- a/tests/app/Http/Controllers/Admin/FixLevel0MediaControllerTest.php +++ b/tests/app/Http/Controllers/Admin/FixLevel0MediaControllerTest.php @@ -2,7 +2,7 @@ /** * webtrees: online genealogy - * Copyright (C) 2019 webtrees development team + * Copyright (C) 2020 webtrees development team * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or @@ -45,7 +45,7 @@ class FixLevel0MediaControllerTest extends TestCase $request = self::createRequest(); $response = $controller->fixLevel0Media($request); - $this->assertSame(StatusCodeInterface::STATUS_OK, $response->getStatusCode()); + self::assertSame(StatusCodeInterface::STATUS_OK, $response->getStatusCode()); } /** @@ -64,7 +64,7 @@ class FixLevel0MediaControllerTest extends TestCase ]); $response = $controller->fixLevel0MediaAction($request); - $this->assertSame(StatusCodeInterface::STATUS_NO_CONTENT, $response->getStatusCode()); + self::assertSame(StatusCodeInterface::STATUS_NO_CONTENT, $response->getStatusCode()); } /** @@ -79,6 +79,6 @@ class FixLevel0MediaControllerTest extends TestCase $request = self::createRequest(RequestMethodInterface::METHOD_GET, ['tree_id' => $tree->id()]); $response = $controller->fixLevel0MediaData($request); - $this->assertSame(StatusCodeInterface::STATUS_OK, $response->getStatusCode()); + self::assertSame(StatusCodeInterface::STATUS_OK, $response->getStatusCode()); } } diff --git a/tests/app/Http/Controllers/Admin/ImportThumbnailsControllerTest.php b/tests/app/Http/Controllers/Admin/ImportThumbnailsControllerTest.php index 8999fa56eb..780d0b6e6e 100644 --- a/tests/app/Http/Controllers/Admin/ImportThumbnailsControllerTest.php +++ b/tests/app/Http/Controllers/Admin/ImportThumbnailsControllerTest.php @@ -2,7 +2,7 @@ /** * webtrees: online genealogy - * Copyright (C) 2019 webtrees development team + * Copyright (C) 2020 webtrees development team * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or @@ -24,7 +24,6 @@ use Fisharebest\Webtrees\Services\PendingChangesService; use Fisharebest\Webtrees\Services\SearchService; use Fisharebest\Webtrees\Services\TreeService; use Fisharebest\Webtrees\TestCase; -use League\Flysystem\Memory\MemoryAdapter; /** * Test ImportThumbnailsController class. @@ -48,7 +47,7 @@ class ImportThumbnailsControllerTest extends TestCase $request = self::createRequest(); $response = $controller->webtrees1Thumbnails($request); - $this->assertSame(StatusCodeInterface::STATUS_OK, $response->getStatusCode()); + self::assertSame(StatusCodeInterface::STATUS_OK, $response->getStatusCode()); } /** @@ -64,7 +63,7 @@ class ImportThumbnailsControllerTest extends TestCase ->withParsedBody(['thumbnail' => 'foo', 'action' => '', 'xref' => [], 'ged' => []]); $response = $controller->webtrees1ThumbnailsAction($request); - $this->assertSame(StatusCodeInterface::STATUS_OK, $response->getStatusCode()); + self::assertSame(StatusCodeInterface::STATUS_OK, $response->getStatusCode()); } /** @@ -79,6 +78,6 @@ class ImportThumbnailsControllerTest extends TestCase $request = self::createRequest()->withQueryParams(['start' => '0', 'length' => '10', 'search' => ['value' => ''], 'draw' => '1']); $response = $controller->webtrees1ThumbnailsData($request); - $this->assertSame(StatusCodeInterface::STATUS_OK, $response->getStatusCode()); + self::assertSame(StatusCodeInterface::STATUS_OK, $response->getStatusCode()); } } diff --git a/tests/app/Http/Controllers/Admin/LocationControllerTest.php b/tests/app/Http/Controllers/Admin/LocationControllerTest.php index 4bc81571b9..378e1d9754 100644 --- a/tests/app/Http/Controllers/Admin/LocationControllerTest.php +++ b/tests/app/Http/Controllers/Admin/LocationControllerTest.php @@ -2,7 +2,7 @@ /** * webtrees: online genealogy - * Copyright (C) 2019 webtrees development team + * Copyright (C) 2020 webtrees development team * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or @@ -22,7 +22,6 @@ namespace Fisharebest\Webtrees\Http\Controllers\Admin; use Fig\Http\Message\RequestMethodInterface; use Fig\Http\Message\StatusCodeInterface; use Fisharebest\Webtrees\Services\GedcomService; -use Fisharebest\Webtrees\Services\TreeService; use Fisharebest\Webtrees\TestCase; use function dirname; @@ -46,7 +45,7 @@ class LocationControllerTest extends TestCase $request = self::createRequest(RequestMethodInterface::METHOD_GET, ['place_id' => '0', 'parent_id' => '0']); $response = $controller->mapDataEdit($request); - $this->assertSame(StatusCodeInterface::STATUS_OK, $response->getStatusCode()); + self::assertSame(StatusCodeInterface::STATUS_OK, $response->getStatusCode()); } /** @@ -70,7 +69,7 @@ class LocationControllerTest extends TestCase ]); $response = $controller->mapDataSave($request); - $this->assertSame(StatusCodeInterface::STATUS_FOUND, $response->getStatusCode()); + self::assertSame(StatusCodeInterface::STATUS_FOUND, $response->getStatusCode()); } /** @@ -83,8 +82,8 @@ class LocationControllerTest extends TestCase $request = self::createRequest(RequestMethodInterface::METHOD_GET, ['parent_id' => '0', 'format' => 'geojson']); $response = $controller->exportLocations($request); - $this->assertSame(StatusCodeInterface::STATUS_OK, $response->getStatusCode()); - $this->assertSame($response->getHeaderLine('Content-Type'), 'application/vnd.geo+json'); + self::assertSame(StatusCodeInterface::STATUS_OK, $response->getStatusCode()); + self::assertSame($response->getHeaderLine('Content-Type'), 'application/vnd.geo+json'); } /** @@ -97,7 +96,7 @@ class LocationControllerTest extends TestCase $request = self::createRequest(RequestMethodInterface::METHOD_GET, ['parent_id' => '0']); $response = $controller->importLocations($request); - $this->assertSame(StatusCodeInterface::STATUS_OK, $response->getStatusCode()); + self::assertSame(StatusCodeInterface::STATUS_OK, $response->getStatusCode()); } /** @@ -111,6 +110,6 @@ class LocationControllerTest extends TestCase $request = self::createRequest(RequestMethodInterface::METHOD_POST, ['parent_id' => '0'], [], ['csv' => $csv]); $response = $controller->importLocationsAction($request); - $this->assertSame(StatusCodeInterface::STATUS_FOUND, $response->getStatusCode()); + self::assertSame(StatusCodeInterface::STATUS_FOUND, $response->getStatusCode()); } } diff --git a/tests/app/Http/Controllers/Admin/MapProviderControllerTest.php b/tests/app/Http/Controllers/Admin/MapProviderControllerTest.php index 1a796bd5c5..ff2e44c80e 100644 --- a/tests/app/Http/Controllers/Admin/MapProviderControllerTest.php +++ b/tests/app/Http/Controllers/Admin/MapProviderControllerTest.php @@ -2,7 +2,7 @@ /** * webtrees: online genealogy - * Copyright (C) 2019 webtrees development team + * Copyright (C) 2020 webtrees development team * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or @@ -41,7 +41,7 @@ class MapProviderControllerTest extends TestCase $request = self::createRequest(); $response = $controller->mapProviderEdit($request); - $this->assertSame(StatusCodeInterface::STATUS_OK, $response->getStatusCode()); + self::assertSame(StatusCodeInterface::STATUS_OK, $response->getStatusCode()); } /** @@ -53,6 +53,6 @@ class MapProviderControllerTest extends TestCase $request = self::createRequest(RequestMethodInterface::METHOD_POST, [], ['provider' => '', 'geonames' => '']); $response = $controller->mapProviderSave($request); - $this->assertSame(StatusCodeInterface::STATUS_FOUND, $response->getStatusCode()); + self::assertSame(StatusCodeInterface::STATUS_FOUND, $response->getStatusCode()); } } diff --git a/tests/app/Http/Controllers/Admin/MediaControllerTest.php b/tests/app/Http/Controllers/Admin/MediaControllerTest.php index af1cbab74c..8abe86dffe 100644 --- a/tests/app/Http/Controllers/Admin/MediaControllerTest.php +++ b/tests/app/Http/Controllers/Admin/MediaControllerTest.php @@ -2,7 +2,7 @@ /** * webtrees: online genealogy - * Copyright (C) 2019 webtrees development team + * Copyright (C) 2020 webtrees development team * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or @@ -21,8 +21,6 @@ namespace Fisharebest\Webtrees\Http\Controllers\Admin; use Fig\Http\Message\RequestMethodInterface; use Fig\Http\Message\StatusCodeInterface; -use Fisharebest\Webtrees\Cache; -use Fisharebest\Webtrees\Contracts\CacheFactoryInterface; use Fisharebest\Webtrees\Contracts\FilesystemFactoryInterface; use Fisharebest\Webtrees\Registry; use Fisharebest\Webtrees\Services\DatatablesService; @@ -45,7 +43,7 @@ class MediaControllerTest extends TestCase { parent::setUp(); - $filesystem_factory = $this->createMock(FilesystemFactoryInterface::class); + $filesystem_factory = self::createMock(FilesystemFactoryInterface::class); $filesystem_factory->method('data')->willReturn(new Filesystem(new NullAdapter())); $filesystem_factory->method('dataName')->willReturn('data/'); Registry::filesystem($filesystem_factory); @@ -63,7 +61,7 @@ class MediaControllerTest extends TestCase $request = self::createRequest(); $response = $controller->index($request); - $this->assertSame(StatusCodeInterface::STATUS_OK, $response->getStatusCode()); + self::assertSame(StatusCodeInterface::STATUS_OK, $response->getStatusCode()); } /** @@ -85,7 +83,7 @@ class MediaControllerTest extends TestCase ]); $response = $controller->data($request); - $this->assertSame(StatusCodeInterface::STATUS_OK, $response->getStatusCode()); + self::assertSame(StatusCodeInterface::STATUS_OK, $response->getStatusCode()); } /** @@ -107,7 +105,7 @@ class MediaControllerTest extends TestCase ]); $response = $controller->data($request); - $this->assertSame(StatusCodeInterface::STATUS_OK, $response->getStatusCode()); + self::assertSame(StatusCodeInterface::STATUS_OK, $response->getStatusCode()); } /** @@ -129,7 +127,7 @@ class MediaControllerTest extends TestCase ]); $response = $controller->data($request); - $this->assertSame(StatusCodeInterface::STATUS_OK, $response->getStatusCode()); + self::assertSame(StatusCodeInterface::STATUS_OK, $response->getStatusCode()); } /** @@ -144,7 +142,7 @@ class MediaControllerTest extends TestCase $request = self::createRequest(); $response = $controller->upload($request); - $this->assertSame(StatusCodeInterface::STATUS_OK, $response->getStatusCode()); + self::assertSame(StatusCodeInterface::STATUS_OK, $response->getStatusCode()); } /** @@ -159,6 +157,6 @@ class MediaControllerTest extends TestCase $request = self::createRequest(); $response = $controller->uploadAction($request); - $this->assertSame(StatusCodeInterface::STATUS_FOUND, $response->getStatusCode()); + self::assertSame(StatusCodeInterface::STATUS_FOUND, $response->getStatusCode()); } } diff --git a/tests/app/Http/Controllers/Admin/UpgradeControllerTest.php b/tests/app/Http/Controllers/Admin/UpgradeControllerTest.php index 2713f9b212..ad52bf033e 100644 --- a/tests/app/Http/Controllers/Admin/UpgradeControllerTest.php +++ b/tests/app/Http/Controllers/Admin/UpgradeControllerTest.php @@ -2,7 +2,7 @@ /** * webtrees: online genealogy - * Copyright (C) 2019 webtrees development team + * Copyright (C) 2020 webtrees development team * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or @@ -31,8 +31,6 @@ use Fisharebest\Webtrees\Services\UpgradeService; use Fisharebest\Webtrees\Services\UserService; use Fisharebest\Webtrees\TestCase; use Illuminate\Support\Collection; -use League\Flysystem\Adapter\NullAdapter; -use League\Flysystem\Filesystem; /** * Test UpgradeController class. @@ -57,7 +55,7 @@ class UpgradeControllerTest extends TestCase $request = self::createRequest(); $response = $controller->wizard($request); - $this->assertSame(StatusCodeInterface::STATUS_OK, $response->getStatusCode()); + self::assertSame(StatusCodeInterface::STATUS_OK, $response->getStatusCode()); } /** @@ -76,7 +74,7 @@ class UpgradeControllerTest extends TestCase $request = self::createRequest(RequestMethodInterface::METHOD_GET, ['continue' => '1']); $response = $controller->wizard($request); - $this->assertSame(StatusCodeInterface::STATUS_OK, $response->getStatusCode()); + self::assertSame(StatusCodeInterface::STATUS_OK, $response->getStatusCode()); } /** @@ -94,7 +92,7 @@ class UpgradeControllerTest extends TestCase $response = $controller->step($request); - $this->assertSame(StatusCodeInterface::STATUS_NO_CONTENT, $response->getStatusCode()); + self::assertSame(StatusCodeInterface::STATUS_NO_CONTENT, $response->getStatusCode()); } /** @@ -102,7 +100,7 @@ class UpgradeControllerTest extends TestCase */ public function testStepCheckOK(): void { - $mock_upgrade_service = $this->createMock(UpgradeService::class); + $mock_upgrade_service = self::createMock(UpgradeService::class); $mock_upgrade_service->method('latestVersion')->willReturn('999.999.999'); $controller = new UpgradeController( new GedcomExportService(), @@ -113,7 +111,7 @@ class UpgradeControllerTest extends TestCase $request = self::createRequest(RequestMethodInterface::METHOD_POST, ['step' => 'Check']); $response = $controller->step($request); - $this->assertSame(StatusCodeInterface::STATUS_OK, $response->getStatusCode()); + self::assertSame(StatusCodeInterface::STATUS_OK, $response->getStatusCode()); } /** @@ -123,7 +121,7 @@ class UpgradeControllerTest extends TestCase { $this->expectException(HttpServerErrorException::class); - $mock_upgrade_service = $this->createMock(UpgradeService::class); + $mock_upgrade_service = self::createMock(UpgradeService::class); $mock_upgrade_service->method('latestVersion')->willReturn(''); $controller = new UpgradeController( new GedcomExportService(), @@ -142,7 +140,7 @@ class UpgradeControllerTest extends TestCase { $this->expectException(HttpServerErrorException::class); - $mock_upgrade_service = $this->createMock(UpgradeService::class); + $mock_upgrade_service = self::createMock(UpgradeService::class); $mock_upgrade_service->method('latestVersion')->willReturn('0.0.0'); $controller = new UpgradeController( new GedcomExportService(), @@ -168,7 +166,7 @@ class UpgradeControllerTest extends TestCase $request = self::createRequest(RequestMethodInterface::METHOD_POST, ['step' => 'Prepare']); $response = $controller->step($request); - $this->assertSame(StatusCodeInterface::STATUS_OK, $response->getStatusCode()); + self::assertSame(StatusCodeInterface::STATUS_OK, $response->getStatusCode()); } /** @@ -185,7 +183,7 @@ class UpgradeControllerTest extends TestCase $request = self::createRequest(RequestMethodInterface::METHOD_POST, ['step' => 'Pending']); $response = $controller->step($request); - $this->assertSame(StatusCodeInterface::STATUS_OK, $response->getStatusCode()); + self::assertSame(StatusCodeInterface::STATUS_OK, $response->getStatusCode()); } /** @@ -219,7 +217,7 @@ class UpgradeControllerTest extends TestCase { $tree = $this->importTree('demo.ged'); $all_trees = Collection::make([$tree->name() => $tree]); - $tree_service = $this->createMock(TreeService::class); + $tree_service = self::createMock(TreeService::class); $tree_service->method('all')->willReturn($all_trees); $controller = new UpgradeController( @@ -231,12 +229,12 @@ class UpgradeControllerTest extends TestCase $request = self::createRequest()->withQueryParams(['step' => 'Export', 'tree' => $tree->name()]); $response = $controller->step($request); - $this->assertSame(StatusCodeInterface::STATUS_OK, $response->getStatusCode()); + self::assertSame(StatusCodeInterface::STATUS_OK, $response->getStatusCode()); // Now overwrite the file we just created $response = $controller->step($request); - $this->assertSame(StatusCodeInterface::STATUS_OK, $response->getStatusCode()); + self::assertSame(StatusCodeInterface::STATUS_OK, $response->getStatusCode()); } /** @@ -246,8 +244,8 @@ class UpgradeControllerTest extends TestCase { $this->expectException(HttpServerErrorException::class); - $mock_upgrade_service = $this->createMock(UpgradeService::class); - $mock_upgrade_service->method('downloadFile')->will($this->throwException(new Exception())); + $mock_upgrade_service = self::createMock(UpgradeService::class); + $mock_upgrade_service->method('downloadFile')->will(self::throwException(new Exception())); $controller = new UpgradeController( new GedcomExportService(), new TreeService(), @@ -263,7 +261,7 @@ class UpgradeControllerTest extends TestCase */ public function testStepDownload(): void { - $mock_upgrade_service = $this->createMock(UpgradeService::class); + $mock_upgrade_service = self::createMock(UpgradeService::class); $mock_upgrade_service->method('downloadFile')->willReturn(123456); $controller = new UpgradeController( new GedcomExportService(), @@ -274,7 +272,7 @@ class UpgradeControllerTest extends TestCase $request = self::createRequest(RequestMethodInterface::METHOD_POST, ['step' => 'Download']); $response = $controller->step($request); - $this->assertSame(StatusCodeInterface::STATUS_OK, $response->getStatusCode()); + self::assertSame(StatusCodeInterface::STATUS_OK, $response->getStatusCode()); } /** @@ -282,7 +280,7 @@ class UpgradeControllerTest extends TestCase */ public function testStepUnzip(): void { - $mock_upgrade_service = $this->createMock(UpgradeService::class); + $mock_upgrade_service = self::createMock(UpgradeService::class); $mock_upgrade_service->method('webtreesZipContents')->willReturn(new Collection()); $controller = new UpgradeController( new GedcomExportService(), @@ -293,6 +291,6 @@ class UpgradeControllerTest extends TestCase $request = self::createRequest(RequestMethodInterface::METHOD_POST, ['step' => 'Unzip']); $response = $controller->step($request); - $this->assertSame(StatusCodeInterface::STATUS_OK, $response->getStatusCode()); + self::assertSame(StatusCodeInterface::STATUS_OK, $response->getStatusCode()); } } diff --git a/tests/app/Http/Controllers/Admin/UsersControllerTest.php b/tests/app/Http/Controllers/Admin/UsersControllerTest.php index f5b70a5847..0e62dd7bc7 100644 --- a/tests/app/Http/Controllers/Admin/UsersControllerTest.php +++ b/tests/app/Http/Controllers/Admin/UsersControllerTest.php @@ -2,7 +2,7 @@ /** * webtrees: online genealogy - * Copyright (C) 2019 webtrees development team + * Copyright (C) 2020 webtrees development team * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or @@ -55,7 +55,7 @@ class UsersControllerTest extends TestCase ->withAttribute('user', Auth::user()); $response = $controller->index($request); - $this->assertSame(StatusCodeInterface::STATUS_OK, $response->getStatusCode()); + self::assertSame(StatusCodeInterface::STATUS_OK, $response->getStatusCode()); } /** @@ -73,7 +73,7 @@ class UsersControllerTest extends TestCase $request = self::createRequest(); $response = $controller->data($request); - $this->assertSame(StatusCodeInterface::STATUS_OK, $response->getStatusCode()); + self::assertSame(StatusCodeInterface::STATUS_OK, $response->getStatusCode()); } /** @@ -91,7 +91,7 @@ class UsersControllerTest extends TestCase $request = self::createRequest(); $response = $controller->create($request); - $this->assertSame(StatusCodeInterface::STATUS_OK, $response->getStatusCode()); + self::assertSame(StatusCodeInterface::STATUS_OK, $response->getStatusCode()); } /** @@ -114,7 +114,7 @@ class UsersControllerTest extends TestCase ]); $response = $controller->save($request); - $this->assertSame(StatusCodeInterface::STATUS_FOUND, $response->getStatusCode()); + self::assertSame(StatusCodeInterface::STATUS_FOUND, $response->getStatusCode()); } /** @@ -133,7 +133,7 @@ class UsersControllerTest extends TestCase $request = self::createRequest(RequestMethodInterface::METHOD_GET, ['user_id' => (string) $user->id()]); $response = $controller->edit($request); - $this->assertSame(StatusCodeInterface::STATUS_OK, $response->getStatusCode()); + self::assertSame(StatusCodeInterface::STATUS_OK, $response->getStatusCode()); } /** @@ -169,6 +169,6 @@ class UsersControllerTest extends TestCase ->withAttribute('user', $user); $response = $controller->update($request); - $this->assertSame(StatusCodeInterface::STATUS_FOUND, $response->getStatusCode()); + self::assertSame(StatusCodeInterface::STATUS_FOUND, $response->getStatusCode()); } } diff --git a/tests/app/Http/Middleware/AuthAdministratorTest.php b/tests/app/Http/Middleware/AuthAdministratorTest.php index b0f7f96bfb..24658c8db9 100644 --- a/tests/app/Http/Middleware/AuthAdministratorTest.php +++ b/tests/app/Http/Middleware/AuthAdministratorTest.php @@ -2,7 +2,7 @@ /** * webtrees: online genealogy - * Copyright (C) 2019 webtrees development team + * Copyright (C) 2020 webtrees development team * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or @@ -40,18 +40,18 @@ class AuthAdministratorTest extends TestCase */ public function testAllowed(): void { - $handler = $this->createMock(RequestHandlerInterface::class); + $handler = self::createMock(RequestHandlerInterface::class); $handler->method('handle')->willReturn(response('lorem ipsum')); - $user = $this->createMock(User::class); + $user = self::createMock(User::class); $user->method('getPreference')->with(User::PREF_IS_ADMINISTRATOR)->willReturn('1'); $request = self::createRequest()->withAttribute('user', $user); $middleware = new AuthAdministrator(); $response = $middleware->process($request, $handler); - $this->assertSame(StatusCodeInterface::STATUS_OK, $response->getStatusCode()); - $this->assertSame('lorem ipsum', (string) $response->getBody()); + self::assertSame(StatusCodeInterface::STATUS_OK, $response->getStatusCode()); + self::assertSame('lorem ipsum', (string) $response->getBody()); } /** @@ -62,10 +62,10 @@ class AuthAdministratorTest extends TestCase $this->expectException(HttpAccessDeniedException::class); $this->expectExceptionMessage('You do not have permission to view this page.'); - $handler = $this->createMock(RequestHandlerInterface::class); + $handler = self::createMock(RequestHandlerInterface::class); $handler->method('handle')->willReturn(response('lorem ipsum')); - $user = $this->createMock(User::class); + $user = self::createMock(User::class); $user->method('getPreference')->with(User::PREF_IS_ADMINISTRATOR)->willReturn(''); $request = self::createRequest()->withAttribute('user', $user); @@ -79,13 +79,13 @@ class AuthAdministratorTest extends TestCase */ public function testNotLoggedIn(): void { - $handler = $this->createMock(RequestHandlerInterface::class); + $handler = self::createMock(RequestHandlerInterface::class); $handler->method('handle')->willReturn(response('lorem ipsum')); $request = self::createRequest()->withAttribute('user', new GuestUser()); $middleware = new AuthAdministrator(); $response = $middleware->process($request, $handler); - $this->assertSame(StatusCodeInterface::STATUS_FOUND, $response->getStatusCode()); + self::assertSame(StatusCodeInterface::STATUS_FOUND, $response->getStatusCode()); } } diff --git a/tests/app/Http/Middleware/AuthEditorTest.php b/tests/app/Http/Middleware/AuthEditorTest.php index 3212bf8c37..cad2a26cae 100644 --- a/tests/app/Http/Middleware/AuthEditorTest.php +++ b/tests/app/Http/Middleware/AuthEditorTest.php @@ -2,7 +2,7 @@ /** * webtrees: online genealogy - * Copyright (C) 2019 webtrees development team + * Copyright (C) 2020 webtrees development team * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or @@ -41,21 +41,21 @@ class AuthEditorTest extends TestCase */ public function testAllowed(): void { - $handler = $this->createMock(RequestHandlerInterface::class); + $handler = self::createMock(RequestHandlerInterface::class); $handler->method('handle')->willReturn(response('lorem ipsum')); - $user = $this->createMock(User::class); + $user = self::createMock(User::class); $user->method('getPreference')->with(User::PREF_IS_ADMINISTRATOR)->willReturn(''); - $tree = $this->createMock(Tree::class); + $tree = self::createMock(Tree::class); $tree->method('getUserPreference')->with($user, User::PREF_TREE_ROLE)->willReturn('edit'); $request = self::createRequest()->withAttribute('tree', $tree)->withAttribute('user', $user); $middleware = new AuthEditor(); $response = $middleware->process($request, $handler); - $this->assertSame(StatusCodeInterface::STATUS_OK, $response->getStatusCode()); - $this->assertSame('lorem ipsum', (string) $response->getBody()); + self::assertSame(StatusCodeInterface::STATUS_OK, $response->getStatusCode()); + self::assertSame('lorem ipsum', (string) $response->getBody()); } /** @@ -66,13 +66,13 @@ class AuthEditorTest extends TestCase $this->expectException(HttpAccessDeniedException::class); $this->expectExceptionMessage('You do not have permission to view this page.'); - $handler = $this->createMock(RequestHandlerInterface::class); + $handler = self::createMock(RequestHandlerInterface::class); $handler->method('handle')->willReturn(response('lorem ipsum')); - $user = $this->createMock(User::class); + $user = self::createMock(User::class); $user->method('getPreference')->with(User::PREF_IS_ADMINISTRATOR)->willReturn(''); - $tree = $this->createMock(Tree::class); + $tree = self::createMock(Tree::class); $tree->method('getUserPreference')->with($user, User::PREF_TREE_ROLE)->willReturn('access'); $request = self::createRequest()->withAttribute('tree', $tree)->withAttribute('user', $user); @@ -86,15 +86,15 @@ class AuthEditorTest extends TestCase */ public function testNotLoggedIn(): void { - $handler = $this->createMock(RequestHandlerInterface::class); + $handler = self::createMock(RequestHandlerInterface::class); $handler->method('handle')->willReturn(response('lorem ipsum')); - $tree = $this->createMock(Tree::class); + $tree = self::createMock(Tree::class); $request = self::createRequest()->withAttribute('tree', $tree)->withAttribute('user', new GuestUser()); $middleware = new AuthEditor(); $response = $middleware->process($request, $handler); - $this->assertSame(StatusCodeInterface::STATUS_FOUND, $response->getStatusCode()); + self::assertSame(StatusCodeInterface::STATUS_FOUND, $response->getStatusCode()); } } diff --git a/tests/app/Http/Middleware/AuthManagerTest.php b/tests/app/Http/Middleware/AuthManagerTest.php index 647a4d26cf..1ec1f6069a 100644 --- a/tests/app/Http/Middleware/AuthManagerTest.php +++ b/tests/app/Http/Middleware/AuthManagerTest.php @@ -2,7 +2,7 @@ /** * webtrees: online genealogy - * Copyright (C) 2019 webtrees development team + * Copyright (C) 2020 webtrees development team * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or @@ -41,21 +41,21 @@ class AuthManagerTest extends TestCase */ public function testAllowed(): void { - $handler = $this->createMock(RequestHandlerInterface::class); + $handler = self::createMock(RequestHandlerInterface::class); $handler->method('handle')->willReturn(response('lorem ipsum')); - $user = $this->createMock(User::class); + $user = self::createMock(User::class); $user->method('getPreference')->with(User::PREF_IS_ADMINISTRATOR)->willReturn(''); - $tree = $this->createMock(Tree::class); + $tree = self::createMock(Tree::class); $tree->method('getUserPreference')->with($user, User::PREF_TREE_ROLE)->willReturn(User::ROLE_MANAGER); $request = self::createRequest()->withAttribute('tree', $tree)->withAttribute('user', $user); $middleware = new AuthManager(); $response = $middleware->process($request, $handler); - $this->assertSame(StatusCodeInterface::STATUS_OK, $response->getStatusCode()); - $this->assertSame('lorem ipsum', (string) $response->getBody()); + self::assertSame(StatusCodeInterface::STATUS_OK, $response->getStatusCode()); + self::assertSame('lorem ipsum', (string) $response->getBody()); } /** @@ -66,13 +66,13 @@ class AuthManagerTest extends TestCase $this->expectException(HttpAccessDeniedException::class); $this->expectExceptionMessage('You do not have permission to view this page.'); - $handler = $this->createMock(RequestHandlerInterface::class); + $handler = self::createMock(RequestHandlerInterface::class); $handler->method('handle')->willReturn(response('lorem ipsum')); - $user = $this->createMock(User::class); + $user = self::createMock(User::class); $user->method('getPreference')->with(User::PREF_IS_ADMINISTRATOR)->willReturn(''); - $tree = $this->createMock(Tree::class); + $tree = self::createMock(Tree::class); $tree->method('getUserPreference')->with($user, User::PREF_TREE_ROLE)->willReturn(User::ROLE_MODERATOR); $request = self::createRequest()->withAttribute('tree', $tree)->withAttribute('user', $user); @@ -86,15 +86,15 @@ class AuthManagerTest extends TestCase */ public function testNotLoggedIn(): void { - $handler = $this->createMock(RequestHandlerInterface::class); + $handler = self::createMock(RequestHandlerInterface::class); $handler->method('handle')->willReturn(response('lorem ipsum')); - $tree = $this->createMock(Tree::class); + $tree = self::createMock(Tree::class); $request = self::createRequest()->withAttribute('tree', $tree)->withAttribute('user', new GuestUser()); $middleware = new AuthManager(); $response = $middleware->process($request, $handler); - $this->assertSame(StatusCodeInterface::STATUS_FOUND, $response->getStatusCode()); + self::assertSame(StatusCodeInterface::STATUS_FOUND, $response->getStatusCode()); } } diff --git a/tests/app/Http/Middleware/AuthMemberTest.php b/tests/app/Http/Middleware/AuthMemberTest.php index d248a1b33a..e143464565 100644 --- a/tests/app/Http/Middleware/AuthMemberTest.php +++ b/tests/app/Http/Middleware/AuthMemberTest.php @@ -2,7 +2,7 @@ /** * webtrees: online genealogy - * Copyright (C) 2019 webtrees development team + * Copyright (C) 2020 webtrees development team * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or @@ -41,21 +41,21 @@ class AuthMemberTest extends TestCase */ public function testAllowed(): void { - $handler = $this->createMock(RequestHandlerInterface::class); + $handler = self::createMock(RequestHandlerInterface::class); $handler->method('handle')->willReturn(response('lorem ipsum')); - $user = $this->createMock(User::class); + $user = self::createMock(User::class); $user->method('getPreference')->with(User::PREF_IS_ADMINISTRATOR)->willReturn(''); - $tree = $this->createMock(Tree::class); + $tree = self::createMock(Tree::class); $tree->method('getUserPreference')->with($user, User::PREF_TREE_ROLE)->willReturn('access'); $request = self::createRequest()->withAttribute('tree', $tree)->withAttribute('user', $user); $middleware = new AuthMember(); $response = $middleware->process($request, $handler); - $this->assertSame(StatusCodeInterface::STATUS_OK, $response->getStatusCode()); - $this->assertSame('lorem ipsum', (string) $response->getBody()); + self::assertSame(StatusCodeInterface::STATUS_OK, $response->getStatusCode()); + self::assertSame('lorem ipsum', (string) $response->getBody()); } /** @@ -66,13 +66,13 @@ class AuthMemberTest extends TestCase $this->expectException(HttpAccessDeniedException::class); $this->expectExceptionMessage('You do not have permission to view this page.'); - $handler = $this->createMock(RequestHandlerInterface::class); + $handler = self::createMock(RequestHandlerInterface::class); $handler->method('handle')->willReturn(response('lorem ipsum')); - $user = $this->createMock(User::class); + $user = self::createMock(User::class); $user->method('getPreference')->with(User::PREF_IS_ADMINISTRATOR)->willReturn(''); - $tree = $this->createMock(Tree::class); + $tree = self::createMock(Tree::class); $tree->method('getUserPreference')->with($user, User::PREF_TREE_ROLE)->willReturn(''); $request = self::createRequest()->withAttribute('tree', $tree)->withAttribute('user', $user); @@ -86,15 +86,15 @@ class AuthMemberTest extends TestCase */ public function testNotLoggedIn(): void { - $handler = $this->createMock(RequestHandlerInterface::class); + $handler = self::createMock(RequestHandlerInterface::class); $handler->method('handle')->willReturn(response('lorem ipsum')); - $tree = $this->createMock(Tree::class); + $tree = self::createMock(Tree::class); $request = self::createRequest()->withAttribute('tree', $tree)->withAttribute('user', new GuestUser()); $middleware = new AuthMember(); $response = $middleware->process($request, $handler); - $this->assertSame(StatusCodeInterface::STATUS_FOUND, $response->getStatusCode()); + self::assertSame(StatusCodeInterface::STATUS_FOUND, $response->getStatusCode()); } } diff --git a/tests/app/Http/Middleware/AuthModeratorTest.php b/tests/app/Http/Middleware/AuthModeratorTest.php index c21be72ca2..81c89fa2a4 100644 --- a/tests/app/Http/Middleware/AuthModeratorTest.php +++ b/tests/app/Http/Middleware/AuthModeratorTest.php @@ -2,7 +2,7 @@ /** * webtrees: online genealogy - * Copyright (C) 2019 webtrees development team + * Copyright (C) 2020 webtrees development team * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or @@ -41,21 +41,21 @@ class AuthModeratorTest extends TestCase */ public function testAllowed(): void { - $handler = $this->createMock(RequestHandlerInterface::class); + $handler = self::createMock(RequestHandlerInterface::class); $handler->method('handle')->willReturn(response('lorem ipsum')); - $user = $this->createMock(User::class); + $user = self::createMock(User::class); $user->method('getPreference')->with(User::PREF_IS_ADMINISTRATOR)->willReturn(''); - $tree = $this->createMock(Tree::class); + $tree = self::createMock(Tree::class); $tree->method('getUserPreference')->with($user, User::PREF_TREE_ROLE)->willReturn(User::ROLE_MODERATOR); $request = self::createRequest()->withAttribute('tree', $tree)->withAttribute('user', $user); $middleware = new AuthModerator(); $response = $middleware->process($request, $handler); - $this->assertSame(StatusCodeInterface::STATUS_OK, $response->getStatusCode()); - $this->assertSame('lorem ipsum', (string) $response->getBody()); + self::assertSame(StatusCodeInterface::STATUS_OK, $response->getStatusCode()); + self::assertSame('lorem ipsum', (string) $response->getBody()); } /** @@ -66,13 +66,13 @@ class AuthModeratorTest extends TestCase $this->expectException(HttpAccessDeniedException::class); $this->expectExceptionMessage('You do not have permission to view this page.'); - $handler = $this->createMock(RequestHandlerInterface::class); + $handler = self::createMock(RequestHandlerInterface::class); $handler->method('handle')->willReturn(response('lorem ipsum')); - $user = $this->createMock(User::class); + $user = self::createMock(User::class); $user->method('getPreference')->with(User::PREF_IS_ADMINISTRATOR)->willReturn(''); - $tree = $this->createMock(Tree::class); + $tree = self::createMock(Tree::class); $tree->method('getUserPreference')->with($user, User::PREF_TREE_ROLE)->willReturn('edit'); $request = self::createRequest()->withAttribute('tree', $tree)->withAttribute('user', $user); @@ -86,15 +86,15 @@ class AuthModeratorTest extends TestCase */ public function testNotLoggedIn(): void { - $handler = $this->createMock(RequestHandlerInterface::class); + $handler = self::createMock(RequestHandlerInterface::class); $handler->method('handle')->willReturn(response('lorem ipsum')); - $tree = $this->createMock(Tree::class); + $tree = self::createMock(Tree::class); $request = self::createRequest()->withAttribute('tree', $tree)->withAttribute('user', new GuestUser()); $middleware = new AuthModerator(); $response = $middleware->process($request, $handler); - $this->assertSame(StatusCodeInterface::STATUS_FOUND, $response->getStatusCode()); + self::assertSame(StatusCodeInterface::STATUS_FOUND, $response->getStatusCode()); } } diff --git a/tests/app/Http/Middleware/BootModulesTest.php b/tests/app/Http/Middleware/BootModulesTest.php index b1817c6725..d99b4a3bfa 100644 --- a/tests/app/Http/Middleware/BootModulesTest.php +++ b/tests/app/Http/Middleware/BootModulesTest.php @@ -2,7 +2,7 @@ /** * webtrees: online genealogy - * Copyright (C) 2019 webtrees development team + * Copyright (C) 2020 webtrees development team * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or @@ -41,12 +41,12 @@ class BootModulesTest extends TestCase { $theme = new WebtreesTheme(); - $handler = $this->createMock(RequestHandlerInterface::class); + $handler = self::createMock(RequestHandlerInterface::class); $handler->method('handle')->willReturn(response('It works!')); - $module_service = $this->createMock(ModuleService::class); + $module_service = self::createMock(ModuleService::class); $module_service - ->expects($this->once()) + ->expects(self::once()) ->method('bootModules') ->with($theme); @@ -54,7 +54,7 @@ class BootModulesTest extends TestCase $middleware = new BootModules($module_service, $theme); $response = $middleware->process($request, $handler); - $this->assertSame(StatusCodeInterface::STATUS_OK, $response->getStatusCode()); - $this->assertSame('It works!', (string) $response->getBody()); + self::assertSame(StatusCodeInterface::STATUS_OK, $response->getStatusCode()); + self::assertSame('It works!', (string) $response->getBody()); } } diff --git a/tests/app/Http/Middleware/CheckCsrfTest.php b/tests/app/Http/Middleware/CheckCsrfTest.php index c0f0a20e5a..0f734583a8 100644 --- a/tests/app/Http/Middleware/CheckCsrfTest.php +++ b/tests/app/Http/Middleware/CheckCsrfTest.php @@ -2,7 +2,7 @@ /** * webtrees: online genealogy - * Copyright (C) 2019 webtrees development team + * Copyright (C) 2020 webtrees development team * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or @@ -40,7 +40,7 @@ class CheckCsrfTest extends TestCase */ public function testMiddleware(): void { - $handler = $this->createMock(RequestHandlerInterface::class); + $handler = self::createMock(RequestHandlerInterface::class); $handler->method('handle')->willReturn(response()); $request = self::createRequest(RequestMethodInterface::METHOD_POST) @@ -49,7 +49,7 @@ class CheckCsrfTest extends TestCase $middleware = new CheckCsrf(); $response = $middleware->process($request, $handler); - $this->assertSame(StatusCodeInterface::STATUS_FOUND, $response->getStatusCode()); - $this->assertSame('http://example.com', $response->getHeaderLine('Location')); + self::assertSame(StatusCodeInterface::STATUS_FOUND, $response->getStatusCode()); + self::assertSame('http://example.com', $response->getHeaderLine('Location')); } } diff --git a/tests/app/Http/Middleware/CheckForMaintenanceModeTest.php b/tests/app/Http/Middleware/CheckForMaintenanceModeTest.php index 4de4b81e4a..5e2270b380 100644 --- a/tests/app/Http/Middleware/CheckForMaintenanceModeTest.php +++ b/tests/app/Http/Middleware/CheckForMaintenanceModeTest.php @@ -2,7 +2,7 @@ /** * webtrees: online genealogy - * Copyright (C) 2019 webtrees development team + * Copyright (C) 2020 webtrees development team * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or @@ -20,6 +20,7 @@ declare(strict_types=1); namespace Fisharebest\Webtrees\Http\Middleware; use Fig\Http\Message\StatusCodeInterface; +use Fisharebest\Webtrees\Http\Middleware\CheckForMaintenanceMode; use Fisharebest\Webtrees\TestCase; use Psr\Http\Server\RequestHandlerInterface; @@ -37,13 +38,13 @@ class CheckForMaintenanceModeTest extends TestCase */ public function testMiddleware(): void { - $handler = $this->createMock(RequestHandlerInterface::class); + $handler = self::createMock(RequestHandlerInterface::class); $handler->method('handle')->willReturn(response()); $request = self::createRequest(); $middleware = new CheckForMaintenanceMode(); $response = $middleware->process($request, $handler); - $this->assertSame(StatusCodeInterface::STATUS_NO_CONTENT, $response->getStatusCode()); + self::assertSame(StatusCodeInterface::STATUS_NO_CONTENT, $response->getStatusCode()); } } diff --git a/tests/app/Http/Middleware/DoHousekeepingTest.php b/tests/app/Http/Middleware/DoHousekeepingTest.php index 8275adfbd5..16eef7bdb0 100644 --- a/tests/app/Http/Middleware/DoHousekeepingTest.php +++ b/tests/app/Http/Middleware/DoHousekeepingTest.php @@ -2,7 +2,7 @@ /** * webtrees: online genealogy - * Copyright (C) 2019 webtrees development team + * Copyright (C) 2020 webtrees development team * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or @@ -38,13 +38,13 @@ class DoHousekeepingTest extends TestCase */ public function testMiddleware(): void { - $handler = $this->createMock(RequestHandlerInterface::class); + $handler = self::createMock(RequestHandlerInterface::class); $handler->method('handle')->willReturn(response()); $request = self::createRequest(); $middleware = new DoHousekeeping(new HousekeepingService()); $response = $middleware->process($request, $handler); - $this->assertSame(StatusCodeInterface::STATUS_NO_CONTENT, $response->getStatusCode()); + self::assertSame(StatusCodeInterface::STATUS_NO_CONTENT, $response->getStatusCode()); } } diff --git a/tests/app/Http/Middleware/HandleExceptionsTest.php b/tests/app/Http/Middleware/HandleExceptionsTest.php index 191a01055a..0d59c4983a 100644 --- a/tests/app/Http/Middleware/HandleExceptionsTest.php +++ b/tests/app/Http/Middleware/HandleExceptionsTest.php @@ -2,7 +2,7 @@ /** * webtrees: online genealogy - * Copyright (C) 2019 webtrees development team + * Copyright (C) 2020 webtrees development team * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or @@ -42,12 +42,12 @@ class HandleExceptionsTest extends TestCase */ public function testMiddleware(): void { - $tree_service = $this->createMock(TreeService::class); + $tree_service = self::createMock(TreeService::class); - $handler = $this->createMock(RequestHandlerInterface::class); + $handler = self::createMock(RequestHandlerInterface::class); $handler->method('handle')->willThrowException(new HttpServerErrorException('eek')); - $module_service = $this->createMock(ModuleService::class); + $module_service = self::createMock(ModuleService::class); $module_service->method('findByInterface')->willReturn(new Collection()); $module_service->method('findByComponent')->willReturn(new Collection()); app()->instance(ModuleService::class, $module_service); @@ -56,7 +56,7 @@ class HandleExceptionsTest extends TestCase $middleware = new HandleExceptions($tree_service); $response = $middleware->process($request, $handler); - $this->assertSame(StatusCodeInterface::STATUS_INTERNAL_SERVER_ERROR, $response->getStatusCode()); + self::assertSame(StatusCodeInterface::STATUS_INTERNAL_SERVER_ERROR, $response->getStatusCode()); app()->forgetInstance(ModuleService::class); app()->forgetInstance(UserService::class); diff --git a/tests/app/Http/Middleware/NoRouteFoundTest.php b/tests/app/Http/Middleware/NoRouteFoundTest.php index cde25fc20e..b2ab8b0d13 100644 --- a/tests/app/Http/Middleware/NoRouteFoundTest.php +++ b/tests/app/Http/Middleware/NoRouteFoundTest.php @@ -2,7 +2,7 @@ /** * webtrees: online genealogy - * Copyright (C) 2019 webtrees development team + * Copyright (C) 2020 webtrees development team * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or @@ -37,13 +37,13 @@ class NoRouteFoundTest extends TestCase */ public function testMiddleware(): void { - $handler = $this->createMock(RequestHandlerInterface::class); + $handler = self::createMock(RequestHandlerInterface::class); $handler->method('handle')->willReturn(response()); $request = self::createRequest(); $middleware = new NoRouteFound(); $response = $middleware->process($request, $handler); - $this->assertSame(StatusCodeInterface::STATUS_FOUND, $response->getStatusCode()); + self::assertSame(StatusCodeInterface::STATUS_FOUND, $response->getStatusCode()); } } diff --git a/tests/app/Http/RequestHandlers/AccountDeleteTest.php b/tests/app/Http/RequestHandlers/AccountDeleteTest.php index cbb8235dba..e257cd9dfa 100644 --- a/tests/app/Http/RequestHandlers/AccountDeleteTest.php +++ b/tests/app/Http/RequestHandlers/AccountDeleteTest.php @@ -2,7 +2,7 @@ /** * webtrees: online genealogy - * Copyright (C) 2019 webtrees development team + * Copyright (C) 2020 webtrees development team * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or @@ -36,11 +36,11 @@ class AccountDeleteTest extends TestCase */ public function testHandler(): void { - $user_service = $this->createMock(UserService::class); + $user_service = self::createMock(UserService::class); $handler = new AccountDelete($user_service); $request = self::createRequest(); $response = $handler->handle($request); - $this->assertSame(StatusCodeInterface::STATUS_FOUND, $response->getStatusCode()); + self::assertSame(StatusCodeInterface::STATUS_FOUND, $response->getStatusCode()); } } diff --git a/tests/app/Http/RequestHandlers/AccountEditTest.php b/tests/app/Http/RequestHandlers/AccountEditTest.php index 08e0bcea28..57a6d43a9c 100644 --- a/tests/app/Http/RequestHandlers/AccountEditTest.php +++ b/tests/app/Http/RequestHandlers/AccountEditTest.php @@ -2,7 +2,7 @@ /** * webtrees: online genealogy - * Copyright (C) 2019 webtrees development team + * Copyright (C) 2020 webtrees development team * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or @@ -42,12 +42,12 @@ class AccountEditTest extends TestCase */ public function testHandler(): void { - $user = $this->createMock(User::class); + $user = self::createMock(User::class); $handler = new AccountEdit(new MessageService(new EmailService(), new UserService()), new ModuleService()); $request = self::createRequest() ->withAttribute('user', $user); $response = $handler->handle($request); - $this->assertSame(StatusCodeInterface::STATUS_OK, $response->getStatusCode()); + self::assertSame(StatusCodeInterface::STATUS_OK, $response->getStatusCode()); } } diff --git a/tests/app/Http/RequestHandlers/AccountUpdateTest.php b/tests/app/Http/RequestHandlers/AccountUpdateTest.php index cabc74e000..560d7ad9df 100644 --- a/tests/app/Http/RequestHandlers/AccountUpdateTest.php +++ b/tests/app/Http/RequestHandlers/AccountUpdateTest.php @@ -2,7 +2,7 @@ /** * webtrees: online genealogy - * Copyright (C) 2019 webtrees development team + * Copyright (C) 2020 webtrees development team * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or @@ -38,20 +38,20 @@ class AccountUpdateTest extends TestCase */ public function testHandler(): void { - $user_service = $this->createMock(UserService::class); + $user_service = self::createMock(UserService::class); - $user = $this->createMock(User::class); - $user->expects($this->once())->method('setEmail')->with('b'); - $user->expects($this->once())->method('setPassword')->with('e'); - $user->expects($this->once())->method('setRealName')->with('d'); - $user->expects($this->once())->method('setUserName')->with('h'); - $user->expects($this->at(6))->method('setPreference')->with(User::PREF_CONTACT_METHOD, 'a'); - $user->expects($this->at(7))->method('setPreference')->with(User::PREF_LANGUAGE, 'c'); - $user->expects($this->at(8))->method('setPreference')->with(User::PREF_TIME_ZONE, 'g'); - $user->expects($this->at(9))->method('setPreference')->with(User::PREF_IS_VISIBLE_ONLINE, 'i'); + $user = self::createMock(User::class); + $user->expects(self::once())->method('setEmail')->with('b'); + $user->expects(self::once())->method('setPassword')->with('e'); + $user->expects(self::once())->method('setRealName')->with('d'); + $user->expects(self::once())->method('setUserName')->with('h'); + $user->expects(self::at(6))->method('setPreference')->with(User::PREF_CONTACT_METHOD, 'a'); + $user->expects(self::at(7))->method('setPreference')->with(User::PREF_LANGUAGE, 'c'); + $user->expects(self::at(8))->method('setPreference')->with(User::PREF_TIME_ZONE, 'g'); + $user->expects(self::at(9))->method('setPreference')->with(User::PREF_IS_VISIBLE_ONLINE, 'i'); - $tree = $this->createMock(Tree::class); - $tree->expects($this->once())->method('setUserPreference')->with($user, User::PREF_TREE_DEFAULT_XREF, 'f'); + $tree = self::createMock(Tree::class); + $tree->expects(self::once())->method('setUserPreference')->with($user, User::PREF_TREE_DEFAULT_XREF, 'f'); $handler = new AccountUpdate($user_service); $request = self::createRequest() @@ -70,6 +70,6 @@ class AccountUpdateTest extends TestCase ]); $response = $handler->handle($request); - $this->assertSame(StatusCodeInterface::STATUS_FOUND, $response->getStatusCode()); + self::assertSame(StatusCodeInterface::STATUS_FOUND, $response->getStatusCode()); } } diff --git a/tests/app/Http/RequestHandlers/ControlPanelControllerTest.php b/tests/app/Http/RequestHandlers/ControlPanelControllerTest.php index b9951cf2a0..f98be0f4c0 100644 --- a/tests/app/Http/RequestHandlers/ControlPanelControllerTest.php +++ b/tests/app/Http/RequestHandlers/ControlPanelControllerTest.php @@ -2,7 +2,7 @@ /** * webtrees: online genealogy - * Copyright (C) 2019 webtrees development team + * Copyright (C) 2020 webtrees development team * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or @@ -57,6 +57,6 @@ class ControlPanelControllerTest extends TestCase $request = self::createRequest(); $response = $handler->handle($request); - $this->assertSame(StatusCodeInterface::STATUS_OK, $response->getStatusCode()); + self::assertSame(StatusCodeInterface::STATUS_OK, $response->getStatusCode()); } } diff --git a/tests/app/Http/RequestHandlers/DeleteUserTest.php b/tests/app/Http/RequestHandlers/DeleteUserTest.php index 68491899ed..efaeb420d0 100644 --- a/tests/app/Http/RequestHandlers/DeleteUserTest.php +++ b/tests/app/Http/RequestHandlers/DeleteUserTest.php @@ -2,7 +2,7 @@ /** * webtrees: online genealogy - * Copyright (C) 2019 webtrees development team + * Copyright (C) 2020 webtrees development team * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or @@ -38,11 +38,11 @@ class DeleteUserTest extends TestCase */ public function testDeleteUser(): void { - $user = $this->createMock(User::class); + $user = self::createMock(User::class); $user->method('id')->willReturn(1); - $user_service = $this->createMock(UserService::class); - $user_service->expects($this->once())->method('find')->willReturn($user); + $user_service = self::createMock(UserService::class); + $user_service->expects(self::once())->method('find')->willReturn($user); $request = self::createRequest() ->withAttribute('user_id', $user->id()); @@ -60,8 +60,8 @@ class DeleteUserTest extends TestCase $this->expectException(HttpNotFoundException::class); $this->expectExceptionMessage('User ID 98765 not found'); - $user_service = $this->createMock(UserService::class); - $user_service->expects($this->once())->method('find')->willReturn(null); + $user_service = self::createMock(UserService::class); + $user_service->expects(self::once())->method('find')->willReturn(null); $request = self::createRequest() ->withAttribute('user_id', 98765); @@ -77,12 +77,12 @@ class DeleteUserTest extends TestCase $this->expectException(HttpAccessDeniedException::class); $this->expectExceptionMessage('Cannot delete an administrator'); - $user = $this->createMock(User::class); + $user = self::createMock(User::class); $user->method('id')->willReturn(1); - $user->expects($this->once())->method('getPreference')->with(User::PREF_IS_ADMINISTRATOR)->willReturn('1'); + $user->expects(self::once())->method('getPreference')->with(User::PREF_IS_ADMINISTRATOR)->willReturn('1'); - $user_service = $this->createMock(UserService::class); - $user_service->expects($this->once())->method('find')->willReturn($user); + $user_service = self::createMock(UserService::class); + $user_service->expects(self::once())->method('find')->willReturn($user); $request = self::createRequest() ->withAttribute('user_id', $user->id()); diff --git a/tests/app/Http/RequestHandlers/LoginPageTest.php b/tests/app/Http/RequestHandlers/LoginPageTest.php index 670b03f187..4f967cf12f 100644 --- a/tests/app/Http/RequestHandlers/LoginPageTest.php +++ b/tests/app/Http/RequestHandlers/LoginPageTest.php @@ -2,7 +2,7 @@ /** * webtrees: online genealogy - * Copyright (C) 2019 webtrees development team + * Copyright (C) 2020 webtrees development team * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or @@ -48,7 +48,7 @@ class LoginPageTest extends TestCase public function testLoginPageAlreadyLoggedIn(): void { $tree_service = new TreeService(); - $user = $this->createMock(User::class); + $user = self::createMock(User::class); $request = self::createRequest()->withAttribute('user', $user); $handler = new LoginPage($tree_service); $response = $handler->handle($request); diff --git a/tests/app/Http/RequestHandlers/MasqueradeTest.php b/tests/app/Http/RequestHandlers/MasqueradeTest.php index 58e369300d..29edb9f263 100644 --- a/tests/app/Http/RequestHandlers/MasqueradeTest.php +++ b/tests/app/Http/RequestHandlers/MasqueradeTest.php @@ -2,7 +2,7 @@ /** * webtrees: online genealogy - * Copyright (C) 2019 webtrees development team + * Copyright (C) 2020 webtrees development team * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or @@ -37,14 +37,14 @@ class MasqueradeTest extends TestCase */ public function testMasqueradeAsUser(): void { - $user1 = $this->createMock(User::class); + $user1 = self::createMock(User::class); $user1->method('id')->willReturn(1); - $user2 = $this->createMock(User::class); + $user2 = self::createMock(User::class); $user2->method('id')->willReturn(2); - $user_service = $this->createMock(UserService::class); - $user_service->expects($this->once())->method('find')->willReturn($user2); + $user_service = self::createMock(UserService::class); + $user_service->expects(self::once())->method('find')->willReturn($user2); $request = self::createRequest() ->withAttribute('user', $user1) @@ -63,11 +63,11 @@ class MasqueradeTest extends TestCase */ public function testCannotMasqueradeAsSelf(): void { - $user = $this->createMock(User::class); + $user = self::createMock(User::class); $user->method('id')->willReturn(1); - $user_service = $this->createMock(UserService::class); - $user_service->expects($this->once())->method('find')->willReturn($user); + $user_service = self::createMock(UserService::class); + $user_service->expects(self::once())->method('find')->willReturn($user); $request = self::createRequest() ->withAttribute('user', $user) @@ -88,11 +88,11 @@ class MasqueradeTest extends TestCase $this->expectException(HttpNotFoundException::class); $this->expectExceptionMessage('User ID 2 not found'); - $user = $this->createMock(User::class); + $user = self::createMock(User::class); $user->method('id')->willReturn(1); - $user_service = $this->createMock(UserService::class); - $user_service->expects($this->once())->method('find')->willReturn(null); + $user_service = self::createMock(UserService::class); + $user_service->expects(self::once())->method('find')->willReturn(null); $request = self::createRequest() ->withAttribute('user', $user) diff --git a/tests/app/Http/RequestHandlers/ModuleActionTest.php b/tests/app/Http/RequestHandlers/ModuleActionTest.php index 11a1131699..dd92d7322d 100644 --- a/tests/app/Http/RequestHandlers/ModuleActionTest.php +++ b/tests/app/Http/RequestHandlers/ModuleActionTest.php @@ -2,7 +2,7 @@ /** * webtrees: online genealogy - * Copyright (C) 2019 webtrees development team + * Copyright (C) 2020 webtrees development team * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or @@ -28,7 +28,6 @@ use Fisharebest\Webtrees\Module\ModuleInterface; use Fisharebest\Webtrees\Services\ModuleService; use Fisharebest\Webtrees\TestCase; use Psr\Http\Message\ResponseInterface; -use Psr\Http\Message\ServerRequestInterface; use function response; @@ -42,9 +41,9 @@ class ModuleActionTest extends TestCase */ public function testModuleAction(): void { - $module_service = $this->createMock(ModuleService::class); + $module_service = self::createMock(ModuleService::class); $module_service - ->expects($this->once()) + ->expects(self::once()) ->method('findByName') ->with('test') ->willReturn($this->fooModule()); @@ -57,8 +56,8 @@ class ModuleActionTest extends TestCase $handler = new ModuleAction($module_service); $response = $handler->handle($request); - $this->assertSame(StatusCodeInterface::STATUS_OK, $response->getStatusCode()); - $this->assertSame('It works!', (string) $response->getBody()); + self::assertSame(StatusCodeInterface::STATUS_OK, $response->getStatusCode()); + self::assertSame('It works!', (string) $response->getBody()); } /** @@ -69,9 +68,9 @@ class ModuleActionTest extends TestCase $this->expectException(HttpNotFoundException::class); $this->expectExceptionMessage('Method getTestingAction() not found in test'); - $module_service = $this->createMock(ModuleService::class); + $module_service = self::createMock(ModuleService::class); $module_service - ->expects($this->once()) + ->expects(self::once()) ->method('findByName') ->with('test') ->willReturn($this->fooModule()); @@ -93,9 +92,9 @@ class ModuleActionTest extends TestCase $this->expectException(HttpNotFoundException::class); $this->expectExceptionMessage('Module test does not exist'); - $module_service = $this->createMock(ModuleService::class); + $module_service = self::createMock(ModuleService::class); $module_service - ->expects($this->once()) + ->expects(self::once()) ->method('findByName') ->with('test') ->willReturn(null); @@ -117,9 +116,9 @@ class ModuleActionTest extends TestCase $this->expectException(HttpAccessDeniedException::class); $this->expectExceptionMessage('Admin only action'); - $module_service = $this->createMock(ModuleService::class); + $module_service = self::createMock(ModuleService::class); $module_service - ->expects($this->once()) + ->expects(self::once()) ->method('findByName') ->with('test') ->willReturn($this->fooModule()); @@ -139,7 +138,7 @@ class ModuleActionTest extends TestCase private function fooModule(): ModuleInterface { return new class extends AbstractModule { - public function getTestAction(ServerRequestInterface $request): ResponseInterface + public function getTestAction(): ResponseInterface { return response('It works!'); } diff --git a/tests/app/Http/RequestHandlers/PasswordRequestPageTest.php b/tests/app/Http/RequestHandlers/PasswordRequestPageTest.php index 67ad4fc708..57388e29d1 100644 --- a/tests/app/Http/RequestHandlers/PasswordRequestPageTest.php +++ b/tests/app/Http/RequestHandlers/PasswordRequestPageTest.php @@ -2,7 +2,7 @@ /** * webtrees: online genealogy - * Copyright (C) 2019 webtrees development team + * Copyright (C) 2020 webtrees development team * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or @@ -45,7 +45,7 @@ class PasswordRequestPageTest extends TestCase */ public function testPasswordRequestPageAlreadyLoggedIn(): void { - $user = $this->createMock(User::class); + $user = self::createMock(User::class); $request = self::createRequest()->withAttribute('user', $user); $handler = new PasswordRequestPage(); $response = $handler->handle($request); diff --git a/tests/app/Http/RequestHandlers/PasswordResetPageTest.php b/tests/app/Http/RequestHandlers/PasswordResetPageTest.php index 3aad986c7e..c61e05dd74 100644 --- a/tests/app/Http/RequestHandlers/PasswordResetPageTest.php +++ b/tests/app/Http/RequestHandlers/PasswordResetPageTest.php @@ -2,7 +2,7 @@ /** * webtrees: online genealogy - * Copyright (C) 2019 webtrees development team + * Copyright (C) 2020 webtrees development team * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or @@ -35,11 +35,11 @@ class PasswordResetPageTest extends TestCase */ public function testPasswordResetPageWithValidToken(): void { - $user = $this->createMock(User::class); + $user = self::createMock(User::class); - $user_service = $this->createMock(UserService::class); + $user_service = self::createMock(UserService::class); $user_service - ->expects($this->once()) + ->expects(self::once()) ->method('findByToken') ->with('1234') ->willReturn($user); @@ -57,9 +57,9 @@ class PasswordResetPageTest extends TestCase */ public function testPasswordResetPageWithoutValidToken(): void { - $user_service = $this->createMock(UserService::class); + $user_service = self::createMock(UserService::class); $user_service - ->expects($this->once()) + ->expects(self::once()) ->method('findByToken') ->with('4321') ->willReturn(null); diff --git a/tests/app/Http/RequestHandlers/PingTest.php b/tests/app/Http/RequestHandlers/PingTest.php index c27ff1aeb1..b8e24567a8 100644 --- a/tests/app/Http/RequestHandlers/PingTest.php +++ b/tests/app/Http/RequestHandlers/PingTest.php @@ -2,7 +2,7 @@ /** * webtrees: online genealogy - * Copyright (C) 2019 webtrees development team + * Copyright (C) 2020 webtrees development team * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or @@ -34,9 +34,9 @@ class PingTest extends TestCase */ public function testPingOK(): void { - $server_check_service = $this->createMock(ServerCheckService::class); - $server_check_service->expects($this->once())->method('serverErrors')->willReturn(new Collection()); - $server_check_service->expects($this->once())->method('serverWarnings')->willReturn(new Collection()); + $server_check_service = self::createMock(ServerCheckService::class); + $server_check_service->expects(self::once())->method('serverErrors')->willReturn(new Collection()); + $server_check_service->expects(self::once())->method('serverWarnings')->willReturn(new Collection()); $request = self::createRequest(); $handler = new Ping($server_check_service); @@ -51,9 +51,9 @@ class PingTest extends TestCase */ public function testPingWarnings(): void { - $server_check_service = $this->createMock(ServerCheckService::class); - $server_check_service->expects($this->once())->method('serverErrors')->willReturn(new Collection()); - $server_check_service->expects($this->once())->method('serverWarnings')->willReturn(new Collection('warning')); + $server_check_service = self::createMock(ServerCheckService::class); + $server_check_service->expects(self::once())->method('serverErrors')->willReturn(new Collection()); + $server_check_service->expects(self::once())->method('serverWarnings')->willReturn(new Collection('warning')); $request = self::createRequest(); $handler = new Ping($server_check_service); @@ -68,8 +68,8 @@ class PingTest extends TestCase */ public function testPingErrors(): void { - $server_check_service = $this->createMock(ServerCheckService::class); - $server_check_service->expects($this->once())->method('serverErrors')->willReturn(new Collection('error')); + $server_check_service = self::createMock(ServerCheckService::class); + $server_check_service->expects(self::once())->method('serverErrors')->willReturn(new Collection('error')); $request = self::createRequest(); $handler = new Ping($server_check_service); diff --git a/tests/app/Http/RequestHandlers/SelectLanguageTest.php b/tests/app/Http/RequestHandlers/SelectLanguageTest.php index 6102c2b5ca..d57d93537e 100644 --- a/tests/app/Http/RequestHandlers/SelectLanguageTest.php +++ b/tests/app/Http/RequestHandlers/SelectLanguageTest.php @@ -2,7 +2,7 @@ /** * webtrees: online genealogy - * Copyright (C) 2019 webtrees development team + * Copyright (C) 2020 webtrees development team * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or diff --git a/tests/app/Http/RequestHandlers/SelectThemeTest.php b/tests/app/Http/RequestHandlers/SelectThemeTest.php index c4d4765f68..4ebad412e1 100644 --- a/tests/app/Http/RequestHandlers/SelectThemeTest.php +++ b/tests/app/Http/RequestHandlers/SelectThemeTest.php @@ -2,7 +2,7 @@ /** * webtrees: online genealogy - * Copyright (C) 2019 webtrees development team + * Copyright (C) 2020 webtrees development team * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or @@ -34,8 +34,8 @@ class SelectThemeTest extends TestCase */ public function testSelectThemeForGuest(): void { - $user = $this->createMock(GuestUser::class); - $user->expects($this->once())->method('setPreference')->with('theme', 'FOO'); + $user = self::createMock(GuestUser::class); + $user->expects(self::once())->method('setPreference')->with('theme', 'FOO'); $request = self::createRequest() ->withAttribute('theme', 'FOO') @@ -52,8 +52,8 @@ class SelectThemeTest extends TestCase */ public function testSelectThemeForUser(): void { - $user = $this->createMock(User::class); - $user->expects($this->once())->method('setPreference')->with('theme', 'FOO'); + $user = self::createMock(User::class); + $user->expects(self::once())->method('setPreference')->with('theme', 'FOO'); $request = self::createRequest() ->withAttribute('user', $user) |
