diff options
| author | Greg Roach <greg@subaqua.co.uk> | 2024-06-10 10:06:23 +0100 |
|---|---|---|
| committer | Greg Roach <greg@subaqua.co.uk> | 2024-06-10 17:16:35 +0100 |
| commit | 00ef1d3af59aba99c1ae5c92c7e655525c97797b (patch) | |
| tree | 9a133f704205c9ed86460935123beeeddd77dfd4 | |
| parent | 9660ebfefe26982c97c5f787230b1c6c5e61c1e1 (diff) | |
| download | webtrees-00ef1d3af59aba99c1ae5c92c7e655525c97797b.tar.gz webtrees-00ef1d3af59aba99c1ae5c92c7e655525c97797b.tar.bz2 webtrees-00ef1d3af59aba99c1ae5c92c7e655525c97797b.zip | |
Fix: #4989 - mismatch between individual and family lists
87 files changed, 1807 insertions, 1918 deletions
diff --git a/app/Http/RequestHandlers/ControlPanel.php b/app/Http/RequestHandlers/ControlPanel.php index 4653f0c63c..dd2de521bd 100644 --- a/app/Http/RequestHandlers/ControlPanel.php +++ b/app/Http/RequestHandlers/ControlPanel.php @@ -165,7 +165,7 @@ class ControlPanel implements RequestHandlerInterface 'repositories' => $this->totalRepositories(), 'notes' => $this->totalNotes(), 'submitters' => $this->totalSubmitters(), - 'individual_list_module' => $this->module_service->findByInterface(IndividualListModule::class)->last(), + 'individual_list_module' => $this->module_service->findByInterface(IndividualListModule::class)->first(), 'family_list_module' => $this->module_service->findByInterface(FamilyListModule::class)->first(), 'media_list_module' => $this->module_service->findByInterface(MediaListModule::class)->first(), 'note_list_module' => $this->module_service->findByInterface(NoteListModule::class)->first(), diff --git a/app/Http/RequestHandlers/RedirectAncestryPhp.php b/app/Http/RequestHandlers/RedirectAncestryPhp.php index 74418ff196..2eabca891e 100644 --- a/app/Http/RequestHandlers/RedirectAncestryPhp.php +++ b/app/Http/RequestHandlers/RedirectAncestryPhp.php @@ -23,6 +23,7 @@ use Fig\Http\Message\StatusCodeInterface; use Fisharebest\Webtrees\Auth; use Fisharebest\Webtrees\Http\Exceptions\HttpGoneException; use Fisharebest\Webtrees\Module\AncestorsChartModule; +use Fisharebest\Webtrees\Module\ModuleChartInterface; use Fisharebest\Webtrees\Registry; use Fisharebest\Webtrees\Services\ModuleService; use Fisharebest\Webtrees\Services\TreeService; @@ -53,24 +54,29 @@ class RedirectAncestryPhp implements RequestHandlerInterface public function handle(ServerRequestInterface $request): ResponseInterface { - $ged = Validator::queryParams($request)->string('ged', Site::getPreference('DEFAULT_GEDCOM')); - $root_id = Validator::queryParams($request)->string('rootid', ''); - $generations = Validator::queryParams($request)->string('PEDIGREE_GENERATIONS', AncestorsChartModule::DEFAULT_GENERATIONS); - $chart_style = Validator::queryParams($request)->string('chart_style', ''); - $tree = $this->tree_service->all()->get($ged); - $module = $this->module_service->findByInterface(AncestorsChartModule::class)->first(); + $ged = Validator::queryParams($request)->string('ged', Site::getPreference('DEFAULT_GEDCOM')); + $tree = $this->tree_service->all()->get($ged); - if ($tree instanceof Tree && $module instanceof AncestorsChartModule) { - $individual = Registry::individualFactory()->make($root_id, $tree) ?? $tree->significantIndividual(Auth::user()); + if ($tree instanceof Tree) { + $module = $this->module_service + ->findByComponent(ModuleChartInterface::class, $tree, Auth::user()) + ->first(static fn (ModuleChartInterface $module): bool => $module instanceof AncestorsChartModule); - $url = $module->chartUrl($individual, [ - 'generations' => $generations, - 'style' => self::CHART_STYLES[$chart_style] ?? AncestorsChartModule::DEFAULT_STYLE, - ]); + if ($module instanceof AncestorsChartModule) { + $xref = Validator::queryParams($request)->string('rootid', ''); + $generations = Validator::queryParams($request)->string('PEDIGREE_GENERATIONS', AncestorsChartModule::DEFAULT_GENERATIONS); + $chart_style = Validator::queryParams($request)->string('chart_style', ''); + $individual = Registry::individualFactory()->make($xref, $tree) ?? $tree->significantIndividual(Auth::user()); - return Registry::responseFactory() - ->redirectUrl($url, StatusCodeInterface::STATUS_MOVED_PERMANENTLY) - ->withHeader('Link', '<' . $url . '>; rel="canonical"'); + $url = $module->chartUrl($individual, [ + 'generations' => $generations, + 'style' => self::CHART_STYLES[$chart_style] ?? AncestorsChartModule::DEFAULT_STYLE, + ]); + + return Registry::responseFactory() + ->redirectUrl($url, StatusCodeInterface::STATUS_MOVED_PERMANENTLY) + ->withHeader('Link', '<' . $url . '>; rel="canonical"'); + } } throw new HttpGoneException(); diff --git a/app/Http/RequestHandlers/RedirectBranchesPhp.php b/app/Http/RequestHandlers/RedirectBranchesPhp.php index fb2b46a7b0..b4a7022919 100644 --- a/app/Http/RequestHandlers/RedirectBranchesPhp.php +++ b/app/Http/RequestHandlers/RedirectBranchesPhp.php @@ -20,8 +20,10 @@ declare(strict_types=1); namespace Fisharebest\Webtrees\Http\RequestHandlers; use Fig\Http\Message\StatusCodeInterface; +use Fisharebest\Webtrees\Auth; use Fisharebest\Webtrees\Http\Exceptions\HttpGoneException; use Fisharebest\Webtrees\Module\BranchesListModule; +use Fisharebest\Webtrees\Module\ModuleListInterface; use Fisharebest\Webtrees\Registry; use Fisharebest\Webtrees\Services\ModuleService; use Fisharebest\Webtrees\Services\TreeService; @@ -32,6 +34,8 @@ use Psr\Http\Message\ResponseInterface; use Psr\Http\Message\ServerRequestInterface; use Psr\Http\Server\RequestHandlerInterface; +use function route; + /** * Redirect URLs created by webtrees 1.x (and PhpGedView). */ @@ -45,26 +49,28 @@ class RedirectBranchesPhp implements RequestHandlerInterface public function handle(ServerRequestInterface $request): ResponseInterface { - $ged = Validator::queryParams($request)->string('ged', Site::getPreference('DEFAULT_GEDCOM')); - $soundex_dm = Validator::queryParams($request)->string('soundex_dm', ''); - $soundex_std = Validator::queryParams($request)->string('soundex_std', ''); - $surname = Validator::queryParams($request)->string('surname', ''); - $tree = $this->tree_service->all()->get($ged); - $module = $this->module_service->findByInterface(BranchesListModule::class)->first(); + $ged = Validator::queryParams($request)->string('ged', Site::getPreference('DEFAULT_GEDCOM')); + $tree = $this->tree_service->all()->get($ged); + + if ($tree instanceof Tree) { + $module = $this->module_service + ->findByComponent(ModuleListInterface::class, $tree, Auth::user()) + ->first(static fn (ModuleListInterface $module): bool => $module instanceof BranchesListModule); - if ($tree instanceof Tree && $module instanceof BranchesListModule) { - $url = route('module', [ - 'module' => $module->name(), - 'action' => 'Page', - 'soundex_dm' => $soundex_dm, - 'soundex_std' => $soundex_std, - 'surname' => $surname, - 'tree' => $tree->name(), - ]); + if ($module instanceof BranchesListModule) { + $url = route('module', [ + 'module' => $module->name(), + 'action' => 'Page', + 'soundex_dm' => Validator::queryParams($request)->string('soundex_dm', ''), + 'soundex_std' => Validator::queryParams($request)->string('soundex_std', ''), + 'surname' => Validator::queryParams($request)->string('surname', ''), + 'tree' => $tree->name(), + ]); - return Registry::responseFactory() - ->redirectUrl($url, StatusCodeInterface::STATUS_MOVED_PERMANENTLY) - ->withHeader('Link', '<' . $url . '>; rel="canonical"'); + return Registry::responseFactory() + ->redirectUrl($url, StatusCodeInterface::STATUS_MOVED_PERMANENTLY) + ->withHeader('Link', '<' . $url . '>; rel="canonical"'); + } } throw new HttpGoneException(); diff --git a/app/Http/RequestHandlers/RedirectCompactPhp.php b/app/Http/RequestHandlers/RedirectCompactPhp.php index aa65d062e4..c1056dedf2 100644 --- a/app/Http/RequestHandlers/RedirectCompactPhp.php +++ b/app/Http/RequestHandlers/RedirectCompactPhp.php @@ -23,6 +23,7 @@ use Fig\Http\Message\StatusCodeInterface; use Fisharebest\Webtrees\Auth; use Fisharebest\Webtrees\Http\Exceptions\HttpGoneException; use Fisharebest\Webtrees\Module\CompactTreeChartModule; +use Fisharebest\Webtrees\Module\ModuleChartInterface; use Fisharebest\Webtrees\Registry; use Fisharebest\Webtrees\Services\ModuleService; use Fisharebest\Webtrees\Services\TreeService; @@ -51,19 +52,24 @@ class RedirectCompactPhp implements RequestHandlerInterface */ public function handle(ServerRequestInterface $request): ResponseInterface { - $ged = Validator::queryParams($request)->string('ged', Site::getPreference('DEFAULT_GEDCOM')); - $root_id = Validator::queryParams($request)->string('rootid', ''); - $tree = $this->tree_service->all()->get($ged); - $module = $this->module_service->findByInterface(CompactTreeChartModule::class)->first(); + $ged = Validator::queryParams($request)->string('ged', Site::getPreference('DEFAULT_GEDCOM')); + $tree = $this->tree_service->all()->get($ged); - if ($tree instanceof Tree && $module instanceof CompactTreeChartModule) { - $individual = Registry::individualFactory()->make($root_id, $tree) ?? $tree->significantIndividual(Auth::user()); + if ($tree instanceof Tree) { + $module = $this->module_service + ->findByComponent(ModuleChartInterface::class, $tree, Auth::user()) + ->first(static fn (ModuleChartInterface $module): bool => $module instanceof CompactTreeChartModule); - $url = $module->chartUrl($individual, []); + if ($module instanceof CompactTreeChartModule) { + $root_id = Validator::queryParams($request)->string('rootid', ''); + $individual = Registry::individualFactory()->make($root_id, $tree) ?? $tree->significantIndividual(Auth::user()); - return Registry::responseFactory() - ->redirectUrl($url, StatusCodeInterface::STATUS_MOVED_PERMANENTLY) - ->withHeader('Link', '<' . $url . '>; rel="canonical"'); + $url = $module->chartUrl($individual, []); + + return Registry::responseFactory() + ->redirectUrl($url, StatusCodeInterface::STATUS_MOVED_PERMANENTLY) + ->withHeader('Link', '<' . $url . '>; rel="canonical"'); + } } throw new HttpGoneException(); diff --git a/app/Http/RequestHandlers/RedirectDescendencyPhp.php b/app/Http/RequestHandlers/RedirectDescendencyPhp.php index 77c1a8353f..629785a2c6 100644 --- a/app/Http/RequestHandlers/RedirectDescendencyPhp.php +++ b/app/Http/RequestHandlers/RedirectDescendencyPhp.php @@ -23,6 +23,7 @@ use Fig\Http\Message\StatusCodeInterface; use Fisharebest\Webtrees\Auth; use Fisharebest\Webtrees\Http\Exceptions\HttpGoneException; use Fisharebest\Webtrees\Module\DescendancyChartModule; +use Fisharebest\Webtrees\Module\ModuleChartInterface; use Fisharebest\Webtrees\Registry; use Fisharebest\Webtrees\Services\ModuleService; use Fisharebest\Webtrees\Services\TreeService; @@ -53,24 +54,29 @@ class RedirectDescendencyPhp implements RequestHandlerInterface public function handle(ServerRequestInterface $request): ResponseInterface { - $ged = Validator::queryParams($request)->string('ged', Site::getPreference('DEFAULT_GEDCOM')); - $root_id = Validator::queryParams($request)->string('rootid', ''); - $generations = Validator::queryParams($request)->string('generations', DescendancyChartModule::DEFAULT_GENERATIONS); - $chart_style = Validator::queryParams($request)->string('chart_style', ''); - $tree = $this->tree_service->all()->get($ged); - $module = $this->module_service->findByInterface(DescendancyChartModule::class)->first(); + $ged = Validator::queryParams($request)->string('ged', Site::getPreference('DEFAULT_GEDCOM')); + $tree = $this->tree_service->all()->get($ged); - if ($tree instanceof Tree && $module instanceof DescendancyChartModule) { - $individual = Registry::individualFactory()->make($root_id, $tree) ?? $tree->significantIndividual(Auth::user()); + if ($tree instanceof Tree) { + $module = $this->module_service + ->findByComponent(ModuleChartInterface::class, $tree, Auth::user()) + ->first(static fn (ModuleChartInterface $module): bool => $module instanceof DescendancyChartModule); - $url = $module->chartUrl($individual, [ - 'generations' => $generations, - 'style' => self::CHART_STYLES[$chart_style] ?? DescendancyChartModule::CHART_STYLE_TREE, - ]); + if ($module instanceof DescendancyChartModule) { + $root_id = Validator::queryParams($request)->string('rootid', ''); + $generations = Validator::queryParams($request)->string('generations', DescendancyChartModule::DEFAULT_GENERATIONS); + $chart_style = Validator::queryParams($request)->string('chart_style', ''); + $individual = Registry::individualFactory()->make($root_id, $tree) ?? $tree->significantIndividual(Auth::user()); - return Registry::responseFactory() - ->redirectUrl($url, StatusCodeInterface::STATUS_MOVED_PERMANENTLY) - ->withHeader('Link', '<' . $url . '>; rel="canonical"'); + $url = $module->chartUrl($individual, [ + 'generations' => $generations, + 'style' => self::CHART_STYLES[$chart_style] ?? DescendancyChartModule::CHART_STYLE_TREE, + ]); + + return Registry::responseFactory() + ->redirectUrl($url, StatusCodeInterface::STATUS_MOVED_PERMANENTLY) + ->withHeader('Link', '<' . $url . '>; rel="canonical"'); + } } throw new HttpGoneException(); diff --git a/app/Http/RequestHandlers/RedirectFamListPhp.php b/app/Http/RequestHandlers/RedirectFamListPhp.php index d994e242d3..04099e7a5d 100644 --- a/app/Http/RequestHandlers/RedirectFamListPhp.php +++ b/app/Http/RequestHandlers/RedirectFamListPhp.php @@ -20,8 +20,10 @@ declare(strict_types=1); namespace Fisharebest\Webtrees\Http\RequestHandlers; use Fig\Http\Message\StatusCodeInterface; +use Fisharebest\Webtrees\Auth; use Fisharebest\Webtrees\Http\Exceptions\HttpGoneException; use Fisharebest\Webtrees\Module\FamilyListModule; +use Fisharebest\Webtrees\Module\ModuleListInterface; use Fisharebest\Webtrees\Registry; use Fisharebest\Webtrees\Services\ModuleService; use Fisharebest\Webtrees\Services\TreeService; @@ -45,31 +47,29 @@ class RedirectFamListPhp implements RequestHandlerInterface public function handle(ServerRequestInterface $request): ResponseInterface { - $ged = Validator::queryParams($request)->string('ged', Site::getPreference('DEFAULT_GEDCOM')); - $alpha = Validator::queryParams($request)->string('alpha', ''); - $falpha = Validator::queryParams($request)->string('falpha', ''); - $show = Validator::queryParams($request)->string('show', ''); - $show_all = Validator::queryParams($request)->string('show_all', ''); - $show_all_firstnames = Validator::queryParams($request)->string('show_all_firstnames', ''); - $show_marnm = Validator::queryParams($request)->string('show_marnm', ''); - $surname = Validator::queryParams($request)->string('', ''); - $tree = $this->tree_service->all()->get($ged); - $module = $this->module_service->findByInterface(FamilyListModule::class)->first(); + $ged = Validator::queryParams($request)->string('ged', Site::getPreference('DEFAULT_GEDCOM')); + $tree = $this->tree_service->all()->get($ged); - if ($tree instanceof Tree && $module instanceof FamilyListModule) { - $url = $module->listUrl($tree, [ - 'alpha' => $alpha, - 'falpha' => $falpha, - 'show' => $show, - 'show_all' => $show_all, - 'show_all_firstnames' => $show_all_firstnames, - 'show_marnm' => $show_marnm, - 'surname' => $surname, - ]); + if ($tree instanceof Tree) { + $module = $this->module_service + ->findByComponent(ModuleListInterface::class, $tree, Auth::user()) + ->first(static fn (ModuleListInterface $module): bool => $module instanceof FamilyListModule); - return Registry::responseFactory() - ->redirectUrl($url, StatusCodeInterface::STATUS_MOVED_PERMANENTLY) - ->withHeader('Link', '<' . $url . '>; rel="canonical"'); + if ($module instanceof FamilyListModule) { + $url = $module->listUrl($tree, [ + 'alpha' => Validator::queryParams($request)->string('alpha', ''), + 'falpha' => Validator::queryParams($request)->string('falpha', ''), + 'show' => Validator::queryParams($request)->string('show', ''), + 'show_all' => Validator::queryParams($request)->string('show_all', ''), + 'show_all_firstnames' => Validator::queryParams($request)->string('show_all_firstnames', ''), + 'show_marnm' => Validator::queryParams($request)->string('show_marnm', ''), + 'surname' => Validator::queryParams($request)->string('', ''), + ]); + + return Registry::responseFactory() + ->redirectUrl($url, StatusCodeInterface::STATUS_MOVED_PERMANENTLY) + ->withHeader('Link', '<' . $url . '>; rel="canonical"'); + } } throw new HttpGoneException(); diff --git a/app/Http/RequestHandlers/RedirectFamilyBookPhp.php b/app/Http/RequestHandlers/RedirectFamilyBookPhp.php index 752cc9e399..13cb5b91ae 100644 --- a/app/Http/RequestHandlers/RedirectFamilyBookPhp.php +++ b/app/Http/RequestHandlers/RedirectFamilyBookPhp.php @@ -23,6 +23,7 @@ use Fig\Http\Message\StatusCodeInterface; use Fisharebest\Webtrees\Auth; use Fisharebest\Webtrees\Http\Exceptions\HttpGoneException; use Fisharebest\Webtrees\Module\FamilyBookChartModule; +use Fisharebest\Webtrees\Module\ModuleChartInterface; use Fisharebest\Webtrees\Registry; use Fisharebest\Webtrees\Services\ModuleService; use Fisharebest\Webtrees\Services\TreeService; @@ -46,24 +47,29 @@ class RedirectFamilyBookPhp implements RequestHandlerInterface public function handle(ServerRequestInterface $request): ResponseInterface { - $ged = Validator::queryParams($request)->string('ged', Site::getPreference('DEFAULT_GEDCOM')); - $root_id = Validator::queryParams($request)->string('rootid', ''); - $generations = Validator::queryParams($request)->string('generations', FamilyBookChartModule::DEFAULT_GENERATIONS); - $descent = Validator::queryParams($request)->string('descent', FamilyBookChartModule::DEFAULT_DESCENDANT_GENERATIONS); - $tree = $this->tree_service->all()->get($ged); - $module = $this->module_service->findByInterface(FamilyBookChartModule::class)->first(); + $ged = Validator::queryParams($request)->string('ged', Site::getPreference('DEFAULT_GEDCOM')); + $tree = $this->tree_service->all()->get($ged); - if ($tree instanceof Tree && $module instanceof FamilyBookChartModule) { - $individual = Registry::individualFactory()->make($root_id, $tree) ?? $tree->significantIndividual(Auth::user()); + if ($tree instanceof Tree) { + $module = $this->module_service + ->findByComponent(ModuleChartInterface::class, $tree, Auth::user()) + ->first(static fn (ModuleChartInterface $module): bool => $module instanceof FamilyBookChartModule); - $url = $module->chartUrl($individual, [ - 'book_size' => $generations, - 'generations' => $descent, - ]); + if ($module instanceof FamilyBookChartModule) { + $root_id = Validator::queryParams($request)->string('rootid', ''); + $generations = Validator::queryParams($request)->string('generations', FamilyBookChartModule::DEFAULT_GENERATIONS); + $descent = Validator::queryParams($request)->string('descent', FamilyBookChartModule::DEFAULT_DESCENDANT_GENERATIONS); + $individual = Registry::individualFactory()->make($root_id, $tree) ?? $tree->significantIndividual(Auth::user()); - return Registry::responseFactory() - ->redirectUrl($url, StatusCodeInterface::STATUS_MOVED_PERMANENTLY) - ->withHeader('Link', '<' . $url . '>; rel="canonical"'); + $url = $module->chartUrl($individual, [ + 'book_size' => $generations, + 'generations' => $descent, + ]); + + return Registry::responseFactory() + ->redirectUrl($url, StatusCodeInterface::STATUS_MOVED_PERMANENTLY) + ->withHeader('Link', '<' . $url . '>; rel="canonical"'); + } } throw new HttpGoneException(); diff --git a/app/Http/RequestHandlers/RedirectFanChartPhp.php b/app/Http/RequestHandlers/RedirectFanChartPhp.php index 6a21cfa204..d4e9250499 100644 --- a/app/Http/RequestHandlers/RedirectFanChartPhp.php +++ b/app/Http/RequestHandlers/RedirectFanChartPhp.php @@ -23,6 +23,7 @@ use Fig\Http\Message\StatusCodeInterface; use Fisharebest\Webtrees\Auth; use Fisharebest\Webtrees\Http\Exceptions\HttpGoneException; use Fisharebest\Webtrees\Module\FanChartModule; +use Fisharebest\Webtrees\Module\ModuleChartInterface; use Fisharebest\Webtrees\Registry; use Fisharebest\Webtrees\Services\ModuleService; use Fisharebest\Webtrees\Services\TreeService; @@ -46,26 +47,31 @@ class RedirectFanChartPhp implements RequestHandlerInterface public function handle(ServerRequestInterface $request): ResponseInterface { - $ged = Validator::queryParams($request)->string('ged', Site::getPreference('DEFAULT_GEDCOM')); - $root_id = Validator::queryParams($request)->string('rootid', ''); - $generations = Validator::queryParams($request)->string('generations', '4'); - $style = Validator::queryParams($request)->string('style', '4'); - $width = Validator::queryParams($request)->integer('width', FanChartModule::DEFAULT_WIDTH); - $tree = $this->tree_service->all()->get($ged); - $module = $this->module_service->findByInterface(FanChartModule::class)->first(); + $ged = Validator::queryParams($request)->string('ged', Site::getPreference('DEFAULT_GEDCOM')); + $tree = $this->tree_service->all()->get($ged); - if ($tree instanceof Tree && $module instanceof FanChartModule) { - $individual = Registry::individualFactory()->make($root_id, $tree) ?? $tree->significantIndividual(Auth::user()); + if ($tree instanceof Tree) { + $module = $this->module_service + ->findByComponent(ModuleChartInterface::class, $tree, Auth::user()) + ->first(static fn (ModuleChartInterface $module): bool => $module instanceof FanChartModule); - $url = $module->chartUrl($individual, [ - 'generations' => $generations, - 'style' => $style, - 'width' => $width, - ]); + if ($module instanceof FanChartModule) { + $root_id = Validator::queryParams($request)->string('rootid', ''); + $generations = Validator::queryParams($request)->string('generations', '4'); + $style = Validator::queryParams($request)->string('style', '4'); + $width = Validator::queryParams($request)->integer('width', FanChartModule::DEFAULT_WIDTH); + $individual = Registry::individualFactory()->make($root_id, $tree) ?? $tree->significantIndividual(Auth::user()); - return Registry::responseFactory() - ->redirectUrl($url, StatusCodeInterface::STATUS_MOVED_PERMANENTLY) - ->withHeader('Link', '<' . $url . '>; rel="canonical"'); + $url = $module->chartUrl($individual, [ + 'generations' => $generations, + 'style' => $style, + 'width' => $width, + ]); + + return Registry::responseFactory() + ->redirectUrl($url, StatusCodeInterface::STATUS_MOVED_PERMANENTLY) + ->withHeader('Link', '<' . $url . '>; rel="canonical"'); + } } throw new HttpGoneException(); diff --git a/app/Http/RequestHandlers/RedirectHourGlassPhp.php b/app/Http/RequestHandlers/RedirectHourGlassPhp.php index e5298f2050..b7de880a75 100644 --- a/app/Http/RequestHandlers/RedirectHourGlassPhp.php +++ b/app/Http/RequestHandlers/RedirectHourGlassPhp.php @@ -23,6 +23,7 @@ use Fig\Http\Message\StatusCodeInterface; use Fisharebest\Webtrees\Auth; use Fisharebest\Webtrees\Http\Exceptions\HttpGoneException; use Fisharebest\Webtrees\Module\HourglassChartModule; +use Fisharebest\Webtrees\Module\ModuleChartInterface; use Fisharebest\Webtrees\Registry; use Fisharebest\Webtrees\Services\ModuleService; use Fisharebest\Webtrees\Services\TreeService; @@ -46,24 +47,29 @@ class RedirectHourGlassPhp implements RequestHandlerInterface public function handle(ServerRequestInterface $request): ResponseInterface { - $ged = Validator::queryParams($request)->string('ged', Site::getPreference('DEFAULT_GEDCOM')); - $root_id = Validator::queryParams($request)->string('rootid', ''); - $generations = Validator::queryParams($request)->string('generations', HourglassChartModule::DEFAULT_GENERATIONS); - $show_spouse = Validator::queryParams($request)->boolean('show_spouse', HourglassChartModule::DEFAULT_SPOUSES); - $tree = $this->tree_service->all()->get($ged); - $module = $this->module_service->findByInterface(HourglassChartModule::class)->first(); + $ged = Validator::queryParams($request)->string('ged', Site::getPreference('DEFAULT_GEDCOM')); + $tree = $this->tree_service->all()->get($ged); - if ($tree instanceof Tree && $module instanceof HourglassChartModule) { - $individual = Registry::individualFactory()->make($root_id, $tree) ?? $tree->significantIndividual(Auth::user()); + if ($tree instanceof Tree) { + $module = $this->module_service + ->findByComponent(ModuleChartInterface::class, $tree, Auth::user()) + ->first(static fn (ModuleChartInterface $module): bool => $module instanceof HourglassChartModule); - $url = $module->chartUrl($individual, [ - 'generations' => $generations, - 'spouse' => $show_spouse - ]); + if ($module instanceof HourglassChartModule) { + $root_id = Validator::queryParams($request)->string('rootid', ''); + $generations = Validator::queryParams($request)->string('generations', HourglassChartModule::DEFAULT_GENERATIONS); + $show_spouse = Validator::queryParams($request)->boolean('show_spouse', HourglassChartModule::DEFAULT_SPOUSES); + $individual = Registry::individualFactory()->make($root_id, $tree) ?? $tree->significantIndividual(Auth::user()); - return Registry::responseFactory() - ->redirectUrl($url, StatusCodeInterface::STATUS_MOVED_PERMANENTLY) - ->withHeader('Link', '<' . $url . '>; rel="canonical"'); + $url = $module->chartUrl($individual, [ + 'generations' => $generations, + 'spouse' => $show_spouse, + ]); + + return Registry::responseFactory() + ->redirectUrl($url, StatusCodeInterface::STATUS_MOVED_PERMANENTLY) + ->withHeader('Link', '<' . $url . '>; rel="canonical"'); + } } throw new HttpGoneException(); diff --git a/app/Http/RequestHandlers/RedirectIndiListPhp.php b/app/Http/RequestHandlers/RedirectIndiListPhp.php index 04d7b13be6..4a91cdd394 100644 --- a/app/Http/RequestHandlers/RedirectIndiListPhp.php +++ b/app/Http/RequestHandlers/RedirectIndiListPhp.php @@ -20,8 +20,10 @@ declare(strict_types=1); namespace Fisharebest\Webtrees\Http\RequestHandlers; use Fig\Http\Message\StatusCodeInterface; +use Fisharebest\Webtrees\Auth; use Fisharebest\Webtrees\Http\Exceptions\HttpGoneException; use Fisharebest\Webtrees\Module\IndividualListModule; +use Fisharebest\Webtrees\Module\ModuleListInterface; use Fisharebest\Webtrees\Registry; use Fisharebest\Webtrees\Services\ModuleService; use Fisharebest\Webtrees\Services\TreeService; @@ -45,31 +47,29 @@ class RedirectIndiListPhp implements RequestHandlerInterface public function handle(ServerRequestInterface $request): ResponseInterface { - $ged = Validator::queryParams($request)->string('ged', Site::getPreference('DEFAULT_GEDCOM')); - $alpha = Validator::queryParams($request)->string('alpha', ''); - $falpha = Validator::queryParams($request)->string('falpha', ''); - $show = Validator::queryParams($request)->string('show', ''); - $show_all = Validator::queryParams($request)->string('show_all', ''); - $show_all_firstnames = Validator::queryParams($request)->string('show_all_firstnames', ''); - $show_marnm = Validator::queryParams($request)->string('show_marnm', ''); - $surname = Validator::queryParams($request)->string('', ''); - $tree = $this->tree_service->all()->get($ged); - $module = $this->module_service->findByInterface(IndividualListModule::class)->first(); + $ged = Validator::queryParams($request)->string('ged', Site::getPreference('DEFAULT_GEDCOM')); + $tree = $this->tree_service->all()->get($ged); - if ($tree instanceof Tree && $module instanceof IndividualListModule) { - $url = $module->listUrl($tree, [ - 'alpha' => $alpha, - 'falpha' => $falpha, - 'show' => $show, - 'show_all' => $show_all, - 'show_all_firstnames' => $show_all_firstnames, - 'show_marnm' => $show_marnm, - 'surname' => $surname, - ]); + if ($tree instanceof Tree) { + $module = $this->module_service + ->findByComponent(ModuleListInterface::class, $tree, Auth::user()) + ->first(static fn (ModuleListInterface $module): bool => $module instanceof IndividualListModule); - return Registry::responseFactory() - ->redirectUrl($url, StatusCodeInterface::STATUS_MOVED_PERMANENTLY) - ->withHeader('Link', '<' . $url . '>; rel="canonical"'); + if ($module instanceof IndividualListModule) { + $url = $module->listUrl($tree, [ + 'alpha' => Validator::queryParams($request)->string('alpha', ''), + 'falpha' => Validator::queryParams($request)->string('falpha', ''), + 'show' => Validator::queryParams($request)->string('show', ''), + 'show_all' => Validator::queryParams($request)->string('show_all', ''), + 'show_all_firstnames' => Validator::queryParams($request)->string('show_all_firstnames', ''), + 'show_marnm' => Validator::queryParams($request)->string('show_marnm', ''), + 'surname' => Validator::queryParams($request)->string('', ''), + ]); + + return Registry::responseFactory() + ->redirectUrl($url, StatusCodeInterface::STATUS_MOVED_PERMANENTLY) + ->withHeader('Link', '<' . $url . '>; rel="canonical"'); + } } throw new HttpGoneException(); diff --git a/app/Http/RequestHandlers/RedirectLifeSpanPhp.php b/app/Http/RequestHandlers/RedirectLifeSpanPhp.php index 6ccab54978..de5263a516 100644 --- a/app/Http/RequestHandlers/RedirectLifeSpanPhp.php +++ b/app/Http/RequestHandlers/RedirectLifeSpanPhp.php @@ -23,6 +23,7 @@ use Fig\Http\Message\StatusCodeInterface; use Fisharebest\Webtrees\Auth; use Fisharebest\Webtrees\Http\Exceptions\HttpGoneException; use Fisharebest\Webtrees\Module\LifespansChartModule; +use Fisharebest\Webtrees\Module\ModuleChartInterface; use Fisharebest\Webtrees\Registry; use Fisharebest\Webtrees\Services\ModuleService; use Fisharebest\Webtrees\Services\TreeService; @@ -46,19 +47,24 @@ class RedirectLifeSpanPhp implements RequestHandlerInterface public function handle(ServerRequestInterface $request): ResponseInterface { - $ged = Validator::queryParams($request)->string('ged', Site::getPreference('DEFAULT_GEDCOM')); - $tree = $this->tree_service->all()->get($ged); - $module = $this->module_service->findByInterface(LifespansChartModule::class)->first(); + $ged = Validator::queryParams($request)->string('ged', Site::getPreference('DEFAULT_GEDCOM')); + $tree = $this->tree_service->all()->get($ged); - if ($tree instanceof Tree && $module instanceof LifespansChartModule) { - $individual = $tree->significantIndividual(Auth::user()); + if ($tree instanceof Tree) { + $module = $this->module_service + ->findByComponent(ModuleChartInterface::class, $tree, Auth::user()) + ->first(static fn (ModuleChartInterface $module): bool => $module instanceof LifespansChartModule); - // This chart stored a list of individuals in the session, which we won't have. - $url = $module->chartUrl($individual, []); + if ($module instanceof LifespansChartModule) { + $individual = $tree->significantIndividual(Auth::user()); - return Registry::responseFactory() - ->redirectUrl($url, StatusCodeInterface::STATUS_MOVED_PERMANENTLY) - ->withHeader('Link', '<' . $url . '>; rel="canonical"'); + // This chart stored a list of individuals in the session, which we won't have. + $url = $module->chartUrl($individual, []); + + return Registry::responseFactory() + ->redirectUrl($url, StatusCodeInterface::STATUS_MOVED_PERMANENTLY) + ->withHeader('Link', '<' . $url . '>; rel="canonical"'); + } } throw new HttpGoneException(); diff --git a/app/Http/RequestHandlers/RedirectMediaListPhp.php b/app/Http/RequestHandlers/RedirectMediaListPhp.php index 91c31ebd36..7a61edf1a8 100644 --- a/app/Http/RequestHandlers/RedirectMediaListPhp.php +++ b/app/Http/RequestHandlers/RedirectMediaListPhp.php @@ -20,8 +20,10 @@ declare(strict_types=1); namespace Fisharebest\Webtrees\Http\RequestHandlers; use Fig\Http\Message\StatusCodeInterface; +use Fisharebest\Webtrees\Auth; use Fisharebest\Webtrees\Http\Exceptions\HttpGoneException; use Fisharebest\Webtrees\Module\MediaListModule; +use Fisharebest\Webtrees\Module\ModuleListInterface; use Fisharebest\Webtrees\Registry; use Fisharebest\Webtrees\Services\ModuleService; use Fisharebest\Webtrees\Services\TreeService; @@ -45,27 +47,27 @@ class RedirectMediaListPhp implements RequestHandlerInterface public function handle(ServerRequestInterface $request): ResponseInterface { - $ged = Validator::queryParams($request)->string('ged', Site::getPreference('DEFAULT_GEDCOM')); - $folder = Validator::queryParams($request)->string('folder', ''); - $form_type = Validator::queryParams($request)->string('form_type', ''); - $filter = Validator::queryParams($request)->string('filter', ''); - $max = Validator::queryParams($request)->string('max', ''); - $subdirs = Validator::queryParams($request)->string('subdirs', ''); - $tree = $this->tree_service->all()->get($ged); - $module = $this->module_service->findByInterface(MediaListModule::class)->first(); + $ged = Validator::queryParams($request)->string('ged', Site::getPreference('DEFAULT_GEDCOM')); + $tree = $this->tree_service->all()->get($ged); - if ($tree instanceof Tree && $module instanceof MediaListModule) { - $url = $module->listUrl($tree, [ - 'folder' => $folder, - 'form_type' => $form_type, - 'max' => $max, - 'filter' => $filter, - 'subdirs' => $subdirs, - ]); + if ($tree instanceof Tree) { + $module = $this->module_service + ->findByComponent(ModuleListInterface::class, $tree, Auth::user()) + ->first(static fn (ModuleListInterface $module): bool => $module instanceof MediaListModule); - return Registry::responseFactory() - ->redirectUrl($url, StatusCodeInterface::STATUS_MOVED_PERMANENTLY) - ->withHeader('Link', '<' . $url . '>; rel="canonical"'); + if ($module instanceof MediaListModule) { + $url = $module->listUrl($tree, [ + 'filter' => Validator::queryParams($request)->string('filter', ''), + 'folder' => Validator::queryParams($request)->string('folder', ''), + 'form_type' => Validator::queryParams($request)->string('form_type', ''), + 'max' => Validator::queryParams($request)->string('max', ''), + 'subdirs' => Validator::queryParams($request)->string('subdirs', ''), + ]); + + return Registry::responseFactory() + ->redirectUrl($url, StatusCodeInterface::STATUS_MOVED_PERMANENTLY) + ->withHeader('Link', '<' . $url . '>; rel="canonical"'); + } } throw new HttpGoneException(); diff --git a/app/Http/RequestHandlers/RedirectNoteListPhp.php b/app/Http/RequestHandlers/RedirectNoteListPhp.php index 76a132ded5..3edfa86c70 100644 --- a/app/Http/RequestHandlers/RedirectNoteListPhp.php +++ b/app/Http/RequestHandlers/RedirectNoteListPhp.php @@ -20,7 +20,9 @@ declare(strict_types=1); namespace Fisharebest\Webtrees\Http\RequestHandlers; use Fig\Http\Message\StatusCodeInterface; +use Fisharebest\Webtrees\Auth; use Fisharebest\Webtrees\Http\Exceptions\HttpGoneException; +use Fisharebest\Webtrees\Module\ModuleListInterface; use Fisharebest\Webtrees\Module\NoteListModule; use Fisharebest\Webtrees\Registry; use Fisharebest\Webtrees\Services\ModuleService; @@ -45,16 +47,21 @@ class RedirectNoteListPhp implements RequestHandlerInterface public function handle(ServerRequestInterface $request): ResponseInterface { - $ged = Validator::queryParams($request)->string('ged', Site::getPreference('DEFAULT_GEDCOM')); - $tree = $this->tree_service->all()->get($ged); - $module = $this->module_service->findByInterface(NoteListModule::class)->first(); + $ged = Validator::queryParams($request)->string('ged', Site::getPreference('DEFAULT_GEDCOM')); + $tree = $this->tree_service->all()->get($ged); - if ($tree instanceof Tree && $module instanceof NoteListModule) { - $url = $module->listUrl($tree); + if ($tree instanceof Tree) { + $module = $this->module_service + ->findByComponent(ModuleListInterface::class, $tree, Auth::user()) + ->first(static fn (ModuleListInterface $module): bool => $module instanceof NoteListModule); - return Registry::responseFactory() - ->redirectUrl($url, StatusCodeInterface::STATUS_MOVED_PERMANENTLY) - ->withHeader('Link', '<' . $url . '>; rel="canonical"'); + if ($module instanceof NoteListModule) { + $url = $module->listUrl($tree); + + return Registry::responseFactory() + ->redirectUrl($url, StatusCodeInterface::STATUS_MOVED_PERMANENTLY) + ->withHeader('Link', '<' . $url . '>; rel="canonical"'); + } } throw new HttpGoneException(); diff --git a/app/Http/RequestHandlers/RedirectPedigreePhp.php b/app/Http/RequestHandlers/RedirectPedigreePhp.php index 9b5db751dc..f2764e81c1 100644 --- a/app/Http/RequestHandlers/RedirectPedigreePhp.php +++ b/app/Http/RequestHandlers/RedirectPedigreePhp.php @@ -22,6 +22,7 @@ namespace Fisharebest\Webtrees\Http\RequestHandlers; use Fig\Http\Message\StatusCodeInterface; use Fisharebest\Webtrees\Auth; use Fisharebest\Webtrees\Http\Exceptions\HttpGoneException; +use Fisharebest\Webtrees\Module\ModuleChartInterface; use Fisharebest\Webtrees\Module\PedigreeChartModule; use Fisharebest\Webtrees\Registry; use Fisharebest\Webtrees\Services\ModuleService; @@ -45,10 +46,6 @@ class RedirectPedigreePhp implements RequestHandlerInterface 3 => 'bottom', ]; - /** - * @param ModuleService $module_service - * @param TreeService $tree_service - */ public function __construct( private readonly ModuleService $module_service, private readonly TreeService $tree_service, @@ -57,24 +54,29 @@ class RedirectPedigreePhp implements RequestHandlerInterface public function handle(ServerRequestInterface $request): ResponseInterface { - $ged = Validator::queryParams($request)->string('ged', Site::getPreference('DEFAULT_GEDCOM')); - $root_id = Validator::queryParams($request)->string('rootid', ''); - $generations = Validator::queryParams($request)->string('generations', PedigreeChartModule::DEFAULT_GENERATIONS); - $orientation = Validator::queryParams($request)->string('orientation', ''); - $tree = $this->tree_service->all()->get($ged); - $module = $this->module_service->findByInterface(PedigreeChartModule::class)->first(); + $ged = Validator::queryParams($request)->string('ged', Site::getPreference('DEFAULT_GEDCOM')); + $tree = $this->tree_service->all()->get($ged); - if ($tree instanceof Tree && $module instanceof PedigreeChartModule) { - $individual = Registry::individualFactory()->make($root_id, $tree) ?? $tree->significantIndividual(Auth::user()); + if ($tree instanceof Tree) { + $module = $this->module_service + ->findByComponent(ModuleChartInterface::class, $tree, Auth::user()) + ->first(static fn (ModuleChartInterface $module): bool => $module instanceof PedigreeChartModule); - $url = $module->chartUrl($individual, [ - 'generations' => $generations, - 'style' => self::CHART_STYLES[$orientation] ?? PedigreeChartModule::DEFAULT_STYLE, - ]); + if ($module instanceof PedigreeChartModule) { + $root_id = Validator::queryParams($request)->string('rootid', ''); + $generations = Validator::queryParams($request)->string('generations', PedigreeChartModule::DEFAULT_GENERATIONS); + $orientation = Validator::queryParams($request)->string('orientation', ''); + $individual = Registry::individualFactory()->make($root_id, $tree) ?? $tree->significantIndividual(Auth::user()); - return Registry::responseFactory() - ->redirectUrl($url, StatusCodeInterface::STATUS_MOVED_PERMANENTLY) - ->withHeader('Link', '<' . $url . '>; rel="canonical"'); + $url = $module->chartUrl($individual, [ + 'generations' => $generations, + 'style' => self::CHART_STYLES[$orientation] ?? PedigreeChartModule::DEFAULT_STYLE, + ]); + + return Registry::responseFactory() + ->redirectUrl($url, StatusCodeInterface::STATUS_MOVED_PERMANENTLY) + ->withHeader('Link', '<' . $url . '>; rel="canonical"'); + } } throw new HttpGoneException(); diff --git a/app/Http/RequestHandlers/RedirectPlaceListPhp.php b/app/Http/RequestHandlers/RedirectPlaceListPhp.php index 48fdc6c596..56d33de938 100644 --- a/app/Http/RequestHandlers/RedirectPlaceListPhp.php +++ b/app/Http/RequestHandlers/RedirectPlaceListPhp.php @@ -20,7 +20,10 @@ declare(strict_types=1); namespace Fisharebest\Webtrees\Http\RequestHandlers; use Fig\Http\Message\StatusCodeInterface; +use Fisharebest\Webtrees\Auth; use Fisharebest\Webtrees\Http\Exceptions\HttpGoneException; +use Fisharebest\Webtrees\Module\ModuleListInterface; +use Fisharebest\Webtrees\Module\NoteListModule; use Fisharebest\Webtrees\Module\PlaceHierarchyListModule; use Fisharebest\Webtrees\Registry; use Fisharebest\Webtrees\Services\ModuleService; @@ -45,18 +48,24 @@ class RedirectPlaceListPhp implements RequestHandlerInterface public function handle(ServerRequestInterface $request): ResponseInterface { - $ged = Validator::queryParams($request)->string('ged', Site::getPreference('DEFAULT_GEDCOM')); - $action2 = Validator::queryParams($request)->string('action2', ''); - $place_id = Validator::queryParams($request)->string('place_id', ''); - $tree = $this->tree_service->all()->get($ged); - $module = $this->module_service->findByInterface(PlaceHierarchyListModule::class)->first(); + $ged = Validator::queryParams($request)->string('ged', Site::getPreference('DEFAULT_GEDCOM')); + $tree = $this->tree_service->all()->get($ged); - if ($tree instanceof Tree && $module instanceof PlaceHierarchyListModule) { - $url = $module->listUrl($tree, ['action2' => $action2, 'place_id' => $place_id]); + if ($tree instanceof Tree) { + $module = $this->module_service + ->findByComponent(ModuleListInterface::class, $tree, Auth::user()) + ->first(static fn (ModuleListInterface $module): bool => $module instanceof PlaceHierarchyListModule); - return Registry::responseFactory() - ->redirectUrl($url, StatusCodeInterface::STATUS_MOVED_PERMANENTLY) - ->withHeader('Link', '<' . $url . '>; rel="canonical"'); + if ($module instanceof PlaceHierarchyListModule) { + $url = $module->listUrl($tree, [ + 'action2' => Validator::queryParams($request)->string('action2', ''), + 'place_id' => Validator::queryParams($request)->string('place_id', ''), + ]); + + return Registry::responseFactory() + ->redirectUrl($url, StatusCodeInterface::STATUS_MOVED_PERMANENTLY) + ->withHeader('Link', '<' . $url . '>; rel="canonical"'); + } } throw new HttpGoneException(); diff --git a/app/Http/RequestHandlers/RedirectRelationshipPhp.php b/app/Http/RequestHandlers/RedirectRelationshipPhp.php index 3a1cac06e9..5b78ae0794 100644 --- a/app/Http/RequestHandlers/RedirectRelationshipPhp.php +++ b/app/Http/RequestHandlers/RedirectRelationshipPhp.php @@ -22,6 +22,7 @@ namespace Fisharebest\Webtrees\Http\RequestHandlers; use Fig\Http\Message\StatusCodeInterface; use Fisharebest\Webtrees\Auth; use Fisharebest\Webtrees\Http\Exceptions\HttpGoneException; +use Fisharebest\Webtrees\Module\ModuleChartInterface; use Fisharebest\Webtrees\Module\RelationshipsChartModule; use Fisharebest\Webtrees\Registry; use Fisharebest\Webtrees\Services\ModuleService; @@ -46,26 +47,30 @@ class RedirectRelationshipPhp implements RequestHandlerInterface public function handle(ServerRequestInterface $request): ResponseInterface { - $ged = Validator::queryParams($request)->string('ged', Site::getPreference('DEFAULT_GEDCOM')); - $pid1 = Validator::queryParams($request)->string('pid1', ''); - $pid2 = Validator::queryParams($request)->string('pid2', ''); - $ancestors = Validator::queryParams($request)->string('ancestors', '0'); - $recursion = Validator::queryParams($request)->string('recursion', '0'); - $tree = $this->tree_service->all()->get($ged); - $module = $this->module_service->findByInterface(RelationshipsChartModule::class)->first(); + $ged = Validator::queryParams($request)->string('ged', Site::getPreference('DEFAULT_GEDCOM')); + $tree = $this->tree_service->all()->get($ged); - if ($tree instanceof Tree && $module instanceof RelationshipsChartModule) { - $individual = Registry::individualFactory()->make($pid1, $tree) ?? $tree->significantIndividual(Auth::user()); + if ($tree instanceof Tree) { + $module = $this->module_service + ->findByComponent(ModuleChartInterface::class, $tree, Auth::user()) + ->first(static fn (ModuleChartInterface $module): bool => $module instanceof RelationshipsChartModule); - $url = $module->chartUrl($individual, [ - 'xref2' => $pid2, - 'ancestors' => $ancestors, - 'recursion' => $recursion, - ]); + if ($module instanceof RelationshipsChartModule) { + $pid1 = Validator::queryParams($request)->string('pid1', ''); + $user = Auth::user(); + $individual = Registry::individualFactory()->make($pid1, $tree) ?? $tree->significantIndividual($user); - return Registry::responseFactory() - ->redirectUrl($url, StatusCodeInterface::STATUS_MOVED_PERMANENTLY) - ->withHeader('Link', '<' . $url . '>; rel="canonical"'); + $url = $module->chartUrl($individual, [ + 'ancestors' => Validator::queryParams($request)->string('ancestors', '0'), + 'recursion' => Validator::queryParams($request)->string('recursion', '0'), + 'xref1' => $pid1, + 'xref2' => Validator::queryParams($request)->string('pid2', ''), + ]); + + return Registry::responseFactory() + ->redirectUrl($url, StatusCodeInterface::STATUS_MOVED_PERMANENTLY) + ->withHeader('Link', '<' . $url . '>; rel="canonical"'); + } } throw new HttpGoneException(); diff --git a/app/Http/RequestHandlers/RedirectRepoListPhp.php b/app/Http/RequestHandlers/RedirectRepoListPhp.php index affd9325e7..110d9b53ca 100644 --- a/app/Http/RequestHandlers/RedirectRepoListPhp.php +++ b/app/Http/RequestHandlers/RedirectRepoListPhp.php @@ -20,7 +20,9 @@ declare(strict_types=1); namespace Fisharebest\Webtrees\Http\RequestHandlers; use Fig\Http\Message\StatusCodeInterface; +use Fisharebest\Webtrees\Auth; use Fisharebest\Webtrees\Http\Exceptions\HttpGoneException; +use Fisharebest\Webtrees\Module\ModuleListInterface; use Fisharebest\Webtrees\Module\RepositoryListModule; use Fisharebest\Webtrees\Registry; use Fisharebest\Webtrees\Services\ModuleService; @@ -45,16 +47,21 @@ class RedirectRepoListPhp implements RequestHandlerInterface public function handle(ServerRequestInterface $request): ResponseInterface { - $ged = Validator::queryParams($request)->string('ged', Site::getPreference('DEFAULT_GEDCOM')); - $tree = $this->tree_service->all()->get($ged); - $module = $this->module_service->findByInterface(RepositoryListModule::class)->first(); + $ged = Validator::queryParams($request)->string('ged', Site::getPreference('DEFAULT_GEDCOM')); + $tree = $this->tree_service->all()->get($ged); - if ($tree instanceof Tree && $module instanceof RepositoryListModule) { - $url = $module->listUrl($tree); + if ($tree instanceof Tree) { + $module = $this->module_service + ->findByComponent(ModuleListInterface::class, $tree, Auth::user()) + ->first(static fn (ModuleListInterface $module): bool => $module instanceof RepositoryListModule); - return Registry::responseFactory() - ->redirectUrl($url, StatusCodeInterface::STATUS_MOVED_PERMANENTLY) - ->withHeader('Link', '<' . $url . '>; rel="canonical"'); + if ($module instanceof RepositoryListModule) { + $url = $module->listUrl($tree); + + return Registry::responseFactory() + ->redirectUrl($url, StatusCodeInterface::STATUS_MOVED_PERMANENTLY) + ->withHeader('Link', '<' . $url . '>; rel="canonical"'); + } } throw new HttpGoneException(); diff --git a/app/Http/RequestHandlers/RedirectSourceListPhp.php b/app/Http/RequestHandlers/RedirectSourceListPhp.php index c23df93d9e..2782236bbe 100644 --- a/app/Http/RequestHandlers/RedirectSourceListPhp.php +++ b/app/Http/RequestHandlers/RedirectSourceListPhp.php @@ -20,7 +20,9 @@ declare(strict_types=1); namespace Fisharebest\Webtrees\Http\RequestHandlers; use Fig\Http\Message\StatusCodeInterface; +use Fisharebest\Webtrees\Auth; use Fisharebest\Webtrees\Http\Exceptions\HttpGoneException; +use Fisharebest\Webtrees\Module\ModuleListInterface; use Fisharebest\Webtrees\Module\SourceListModule; use Fisharebest\Webtrees\Registry; use Fisharebest\Webtrees\Services\ModuleService; @@ -45,16 +47,21 @@ class RedirectSourceListPhp implements RequestHandlerInterface public function handle(ServerRequestInterface $request): ResponseInterface { - $ged = Validator::queryParams($request)->string('ged', Site::getPreference('DEFAULT_GEDCOM')); - $tree = $this->tree_service->all()->get($ged); - $module = $this->module_service->findByInterface(SourceListModule::class)->first(); + $ged = Validator::queryParams($request)->string('ged', Site::getPreference('DEFAULT_GEDCOM')); + $tree = $this->tree_service->all()->get($ged); - if ($tree instanceof Tree && $module instanceof SourceListModule) { - $url = $module->listUrl($tree); + if ($tree instanceof Tree) { + $module = $this->module_service + ->findByComponent(ModuleListInterface::class, $tree, Auth::user()) + ->first(static fn (ModuleListInterface $module): bool => $module instanceof SourceListModule); - return Registry::responseFactory() - ->redirectUrl($url, StatusCodeInterface::STATUS_MOVED_PERMANENTLY) - ->withHeader('Link', '<' . $url . '>; rel="canonical"'); + if ($module instanceof SourceListModule) { + $url = $module->listUrl($tree); + + return Registry::responseFactory() + ->redirectUrl($url, StatusCodeInterface::STATUS_MOVED_PERMANENTLY) + ->withHeader('Link', '<' . $url . '>; rel="canonical"'); + } } throw new HttpGoneException(); diff --git a/app/Http/RequestHandlers/RedirectStatisticsPhp.php b/app/Http/RequestHandlers/RedirectStatisticsPhp.php index 6e9569adee..aca5391efe 100644 --- a/app/Http/RequestHandlers/RedirectStatisticsPhp.php +++ b/app/Http/RequestHandlers/RedirectStatisticsPhp.php @@ -22,6 +22,7 @@ namespace Fisharebest\Webtrees\Http\RequestHandlers; use Fig\Http\Message\StatusCodeInterface; use Fisharebest\Webtrees\Auth; use Fisharebest\Webtrees\Http\Exceptions\HttpGoneException; +use Fisharebest\Webtrees\Module\ModuleChartInterface; use Fisharebest\Webtrees\Module\StatisticsChartModule; use Fisharebest\Webtrees\Registry; use Fisharebest\Webtrees\Services\ModuleService; @@ -46,19 +47,24 @@ class RedirectStatisticsPhp implements RequestHandlerInterface public function handle(ServerRequestInterface $request): ResponseInterface { - $ged = Validator::queryParams($request)->string('ged', Site::getPreference('DEFAULT_GEDCOM')); - $tree = $this->tree_service->all()->get($ged); - $module = $this->module_service->findByInterface(StatisticsChartModule::class)->first(); + $ged = Validator::queryParams($request)->string('ged', Site::getPreference('DEFAULT_GEDCOM')); + $tree = $this->tree_service->all()->get($ged); - if ($tree instanceof Tree && $module instanceof StatisticsChartModule) { - $individual = $tree->significantIndividual(Auth::user()); + if ($tree instanceof Tree) { + $module = $this->module_service + ->findByComponent(ModuleChartInterface::class, $tree, Auth::user()) + ->first(static fn (ModuleChartInterface $module): bool => $module instanceof StatisticsChartModule); - // This chart stored a list of individuals in the session, which we won't have. - $url = $module->chartUrl($individual, []); + if ($module instanceof StatisticsChartModule) { + $individual = $tree->significantIndividual(Auth::user()); - return Registry::responseFactory() - ->redirectUrl($url, StatusCodeInterface::STATUS_MOVED_PERMANENTLY) - ->withHeader('Link', '<' . $url . '>; rel="canonical"'); + // This chart stored a list of individuals in the session, which we won't have. + $url = $module->chartUrl($individual, []); + + return Registry::responseFactory() + ->redirectUrl($url, StatusCodeInterface::STATUS_MOVED_PERMANENTLY) + ->withHeader('Link', '<' . $url . '>; rel="canonical"'); + } } throw new HttpGoneException(); diff --git a/app/Http/RequestHandlers/RedirectTimeLinePhp.php b/app/Http/RequestHandlers/RedirectTimeLinePhp.php index d53614553b..e2141e19c2 100644 --- a/app/Http/RequestHandlers/RedirectTimeLinePhp.php +++ b/app/Http/RequestHandlers/RedirectTimeLinePhp.php @@ -22,6 +22,7 @@ namespace Fisharebest\Webtrees\Http\RequestHandlers; use Fig\Http\Message\StatusCodeInterface; use Fisharebest\Webtrees\Auth; use Fisharebest\Webtrees\Http\Exceptions\HttpGoneException; +use Fisharebest\Webtrees\Module\ModuleChartInterface; use Fisharebest\Webtrees\Module\TimelineChartModule; use Fisharebest\Webtrees\Registry; use Fisharebest\Webtrees\Services\ModuleService; @@ -46,19 +47,25 @@ class RedirectTimeLinePhp implements RequestHandlerInterface public function handle(ServerRequestInterface $request): ResponseInterface { - $ged = Validator::queryParams($request)->string('ged', Site::getPreference('DEFAULT_GEDCOM')); - $pids = Validator::queryParams($request)->array('pids'); - $tree = $this->tree_service->all()->get($ged); - $module = $this->module_service->findByInterface(TimelineChartModule::class)->first(); + $ged = Validator::queryParams($request)->string('ged', Site::getPreference('DEFAULT_GEDCOM')); + $tree = $this->tree_service->all()->get($ged); - if ($tree instanceof Tree && $module instanceof TimelineChartModule) { - $individual = Registry::individualFactory()->make($pids[0] ?? '', $tree) ?? $tree->significantIndividual(Auth::user()); + if ($tree instanceof Tree) { + $module = $this->module_service + ->findByComponent(ModuleChartInterface::class, $tree, Auth::user()) + ->first(static fn (ModuleChartInterface $module): bool => $module instanceof TimelineChartModule); - $url = $module->chartUrl($individual, $pids); + if ($module instanceof TimelineChartModule) { + $pids = Validator::queryParams($request)->array('pids'); + $xref = $pids[0] ?? ''; + $user = Auth::user(); + $individual = Registry::individualFactory()->make($xref, $tree) ?? $tree->significantIndividual($user); + $url = $module->chartUrl($individual, $pids); - return Registry::responseFactory() - ->redirectUrl($url, StatusCodeInterface::STATUS_MOVED_PERMANENTLY) - ->withHeader('Link', '<' . $url . '>; rel="canonical"'); + return Registry::responseFactory() + ->redirectUrl($url, StatusCodeInterface::STATUS_MOVED_PERMANENTLY) + ->withHeader('Link', '<' . $url . '>; rel="canonical"'); + } } throw new HttpGoneException(); diff --git a/app/Module/AbstractIndividualListModule.php b/app/Module/AbstractIndividualListModule.php new file mode 100644 index 0000000000..6a7078ab62 --- /dev/null +++ b/app/Module/AbstractIndividualListModule.php @@ -0,0 +1,762 @@ +<?php + +/** + * webtrees: online genealogy + * Copyright (C) 2023 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 + * (at your option) any later version. + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <https://www.gnu.org/licenses/>. + */ + +declare(strict_types=1); + +namespace Fisharebest\Webtrees\Module; + +use Fig\Http\Message\StatusCodeInterface; +use Fisharebest\Webtrees\Auth; +use Fisharebest\Webtrees\DB; +use Fisharebest\Webtrees\Family; +use Fisharebest\Webtrees\FlashMessages; +use Fisharebest\Webtrees\I18N; +use Fisharebest\Webtrees\Individual; +use Fisharebest\Webtrees\Registry; +use Fisharebest\Webtrees\Session; +use Fisharebest\Webtrees\Tree; +use Fisharebest\Webtrees\Validator; +use Illuminate\Database\Query\Builder; +use Illuminate\Database\Query\Expression; +use Illuminate\Database\Query\JoinClause; +use Illuminate\Support\Collection; +use Psr\Http\Message\ResponseInterface; +use Psr\Http\Message\ServerRequestInterface; +use Psr\Http\Server\RequestHandlerInterface; + +use function array_filter; +use function array_key_exists; +use function array_keys; +use function array_map; +use function array_merge; +use function array_sum; +use function array_values; +use function assert; +use function e; +use function implode; +use function ob_get_clean; +use function ob_start; +use function route; +use function uksort; +use function usort; +use function view; + +use const ARRAY_FILTER_USE_KEY; + +/** + * Common logic for individual and family lists. + */ +abstract class AbstractIndividualListModule extends AbstractModule implements ModuleListInterface, RequestHandlerInterface +{ + use ModuleListTrait; + + // The individual list and family list use the same code/logic. + // They just display different lists. + abstract protected function showFamilies(): bool; + + abstract protected function routeUrl(): string; + + /** + * Initialization. + */ + public function boot(): void + { + Registry::routeFactory()->routeMap()->get(static::class, $this->routeUrl(), $this); + } + + /** + * @param array<bool|int|string|array<string>|null> $parameters + */ + public function listUrl(Tree $tree, array $parameters = []): string + { + $request = Registry::container()->get(ServerRequestInterface::class); + $xref = Validator::attributes($request)->isXref()->string('xref', ''); + + if ($xref !== '') { + $individual = Registry::individualFactory()->make($xref, $tree); + + if ($individual instanceof Individual && $individual->canShow()) { + $primary_name = $individual->getPrimaryName(); + + $parameters['surname'] ??= $individual->getAllNames()[$primary_name]['surn'] ?? null; + } + } + + $parameters['tree'] = $tree->name(); + + return route(static::class, $parameters); + } + + /** + * @return array<string> + */ + public function listUrlAttributes(): array + { + return []; + } + + public function handle(ServerRequestInterface $request): ResponseInterface + { + $tree = Validator::attributes($request)->tree(); + $user = Validator::attributes($request)->user(); + + Auth::checkComponentAccess($this, ModuleListInterface::class, $tree, $user); + + // All individuals with this surname + $surname_param = Validator::queryParams($request)->string('surname', ''); + $surname = I18N::strtoupper(I18N::language()->normalize($surname_param)); + + // All surnames beginning with this letter, where "@" is unknown and "," is none + $alpha = Validator::queryParams($request)->string('alpha', ''); + + // All first names beginning with this letter where "@" is unknown + $falpha = Validator::queryParams($request)->string('falpha', ''); + + // What type of list to display, if any + $show = Validator::queryParams($request)->string('show', 'surn'); + + // All individuals + $show_all = Validator::queryParams($request)->string('show_all', ''); + + // Include/exclude married names + $show_marnm = Validator::queryParams($request)->string('show_marnm', ''); + + // Break long lists down by given name + $show_all_firstnames = Validator::queryParams($request)->string('show_all_firstnames', ''); + + $params = [ + 'alpha' => $alpha, + 'falpha' => $falpha, + 'show' => $show, + 'show_all' => $show_all, + 'show_all_firstnames' => $show_all_firstnames, + 'show_marnm' => $show_marnm, + 'surname' => $surname, + ]; + + if ($surname_param !== $surname) { + return Registry::responseFactory() + ->redirectUrl($this->listUrl($tree, $params), StatusCodeInterface::STATUS_MOVED_PERMANENTLY); + } + + // Make sure parameters are consistent with each other. + if ($show_all_firstnames === 'yes') { + $falpha = ''; + } + + if ($show_all === 'yes') { + $alpha = ''; + $surname = ''; + } + + if ($surname !== '') { + $alpha = I18N::language()->initialLetter($surname); + } + + $surname_data = $this->surnameData($tree, $show_marnm === 'yes', $this->showFamilies()); + $all_surns = $this->allSurns($surname_data); + $all_surnames = $this->allSurnames($surname_data); + $surname_initials = $this->surnameInitials($surname_data); + + // We've requested a surname that doesn't currently exist. + if ($surname !== '' && !array_key_exists($surname, $all_surns)) { + $message = I18N::translate('There are no individuals with the surname “%s”', e($surname)); + FlashMessages::addMessage($message); + + return Registry::responseFactory() + ->redirectUrl($this->listUrl($tree)); + } + + // Make sure selections are consistent. + // i.e. can’t specify show_all and surname at the same time. + if ($show_all === 'yes') { + if ($show_all_firstnames === 'yes') { + $legend = I18N::translate('All'); + $params = ['tree' => $tree->name(), 'show_all' => 'yes', 'show_marnm' => $show_marnm]; + $show = 'indi'; + } elseif ($falpha !== '') { + $legend = I18N::translate('All') . ', ' . e($falpha) . '…'; + $params = ['tree' => $tree->name(), 'show_all' => 'yes', 'show_marnm' => $show_marnm]; + $show = 'indi'; + } else { + $legend = I18N::translate('All'); + $params = ['tree' => $tree->name(), 'show_all' => 'yes', 'show_marnm' => $show_marnm]; + } + } elseif ($surname !== '') { + $show_all = 'no'; + $show = 'indi'; // The surname list makes no sense with only one surname. + $params = ['tree' => $tree->name(), 'surname' => $surname, 'falpha' => $falpha, 'show_marnm' => $show_marnm]; + + if ($surname === Individual::NOMEN_NESCIO) { + $legend = I18N::translateContext('Unknown surname', '…'); + } else { + // The surname parameter is a root/canonical form. Display the actual surnames found. + $variants = array_keys($all_surnames[$surname] ?? [$surname => $surname]); + usort($variants, I18N::comparator()); + $variants = array_map(static fn (string $x): string => $x === '' ? I18N::translate('No surname') : $x, $variants); + $legend = implode('/', $variants); + } + + switch ($falpha) { + case '': + break; + case '@': + $legend .= ', ' . I18N::translateContext('Unknown given name', '…'); + break; + default: + $legend .= ', ' . e($falpha) . '…'; + break; + } + } elseif ($alpha === '@') { + $show_all = 'no'; + $legend = I18N::translateContext('Unknown surname', '…'); + $params = ['alpha' => $alpha, 'tree' => $tree->name(), 'show_marnm' => $show_marnm]; + $surname = Individual::NOMEN_NESCIO; + $show = 'indi'; // SURN list makes no sense here + } elseif ($alpha === ',') { + $show_all = 'no'; + $legend = I18N::translate('No surname'); + $params = ['alpha' => $alpha, 'tree' => $tree->name(), 'show_marnm' => $show_marnm]; + $show = 'indi'; // SURN list makes no sense here + } elseif ($alpha !== '') { + $show_all = 'no'; + $legend = e($alpha) . '…'; + $params = ['alpha' => $alpha, 'tree' => $tree->name(), 'show_marnm' => $show_marnm]; + } else { + $show_all = 'no'; + $legend = '…'; + $params = ['tree' => $tree->name(), 'show_marnm' => $show_marnm]; + $show = 'none'; // Don't show lists until something is chosen + } + $legend = '<bdi>' . $legend . '</bdi>'; + + if ($this->showFamilies()) { + $title = I18N::translate('Families') . ' — ' . $legend; + } else { + $title = I18N::translate('Individuals') . ' — ' . $legend; + } + + ob_start(); ?> + <div class="d-flex flex-column wt-page-options wt-page-options-individual-list d-print-none"> + <ul class="d-flex flex-wrap list-unstyled justify-content-center wt-initials-list wt-initials-list-surname"> + + <?php foreach ($surname_initials as $letter => $count) : ?> + <li class="wt-initials-list-item d-flex"> + <?php if ($count > 0) : ?> + <a href="<?= e($this->listUrl($tree, ['alpha' => $letter, 'show_marnm' => $show_marnm, 'tree' => $tree->name()])) ?>" class="wt-initial px-1<?= $letter === $alpha ? ' active' : '' ?> '" title="<?= I18N::number($count) ?>"><?= $this->displaySurnameInitial((string) $letter) ?></a> + <?php else : ?> + <span class="wt-initial px-1 text-muted"><?= $this->displaySurnameInitial((string) $letter) ?></span> + + <?php endif ?> + </li> + <?php endforeach ?> + + <?php if (Session::has('initiated')) : ?> + <!-- Search spiders don't get the "show all" option as the other links give them everything. --> + <li class="wt-initials-list-item d-flex"> + <a class="wt-initial px-1<?= $show_all === 'yes' ? ' active' : '' ?>" href="<?= e($this->listUrl($tree, ['show_all' => 'yes'] + $params)) ?>"><?= I18N::translate('All') ?></a> + </li> + <?php endif ?> + </ul> + + <!-- Search spiders don't get an option to show/hide the surname sublists, nor does it make sense on the all/unknown/surname views --> + <?php if ($show !== 'none' && Session::has('initiated')) : ?> + <?php if ($show_marnm === 'yes') : ?> + <p> + <a href="<?= e($this->listUrl($tree, ['show' => $show, 'show_marnm' => 'no'] + $params)) ?>"> + <?= I18N::translate('Exclude individuals with “%s” as a married name', $legend) ?> + </a> + </p> + <?php else : ?> + <p> + <a href="<?= e($this->listUrl($tree, ['show' => $show, 'show_marnm' => 'yes'] + $params)) ?>"> + <?= I18N::translate('Include individuals with “%s” as a married name', $legend) ?> + </a> + </p> + <?php endif ?> + + <?php if ($alpha !== '@' && $alpha !== ',' && $surname === '') : ?> + <?php if ($show === 'surn') : ?> + <p> + <a href="<?= e($this->listUrl($tree, ['show' => 'indi'] + $params)) ?>"> + <?= I18N::translate('Show the list of individuals') ?> + </a> + </p> + <?php else : ?> + <p> + <a href="<?= e($this->listUrl($tree, ['show' => 'surn'] + $params)) ?>"> + <?= I18N::translate('Show the list of surnames') ?> + </a> + </p> + <?php endif ?> + <?php endif ?> + <?php endif ?> + </div> + + <div class="wt-page-content"> + <?php + if ($show === 'indi' || $show === 'surn') { + switch ($alpha) { + case '@': + $filter = static fn (string $x): bool => $x === Individual::NOMEN_NESCIO; + break; + case ',': + $filter = static fn (string $x): bool => $x === ''; + break; + case '': + if ($show_all === 'yes') { + $filter = static fn (string $x): bool => $x !== '' && $x !== Individual::NOMEN_NESCIO; + } else { + $filter = static fn (string $x): bool => $x === $surname; + } + break; + default: + if ($surname === '') { + $filter = static fn (string $x): bool => I18N::language()->initialLetter($x) === $alpha; + } else { + $filter = static fn (string $x): bool => $x === $surname; + } + break; + } + + $all_surnames = array_filter($all_surnames, $filter, ARRAY_FILTER_USE_KEY); + + if ($show === 'surn') { + // Show the surname list + switch ($tree->getPreference('SURNAME_LIST_STYLE')) { + case 'style1': + echo view('lists/surnames-column-list', [ + 'module' => $this, + 'params' => ['show' => 'indi', 'show_all' => null] + $params, + 'surnames' => $all_surnames, + 'totals' => true, + 'tree' => $tree, + ]); + break; + case 'style3': + echo view('lists/surnames-tag-cloud', [ + 'module' => $this, + 'params' => ['show' => 'indi', 'show_all' => null] + $params, + 'surnames' => $all_surnames, + 'totals' => true, + 'tree' => $tree, + ]); + break; + case 'style2': + default: + echo view('lists/surnames-table', [ + 'families' => $this->showFamilies(), + 'module' => $this, + 'order' => [[0, 'asc']], + 'params' => ['show' => 'indi', 'show_all' => null] + $params, + 'surnames' => $all_surnames, + 'tree' => $tree, + ]); + break; + } + } else { + // Show the list + $count = array_sum(array_map(static fn (array $x): int => array_sum($x), $all_surnames)); + + // Don't sublist short lists. + $sublist_threshold = (int) $tree->getPreference('SUBLIST_TRIGGER_I'); + if ($sublist_threshold === 0 || $count < $sublist_threshold) { + $falpha = ''; + } else { + // Break long lists by initial letter of given name + $all_surnames = array_values(array_map(static fn ($x): array => array_keys($x), $all_surnames)); + $all_surnames = array_merge(...$all_surnames); + $givn_initials = $this->givenNameInitials($tree, $all_surnames, $show_marnm === 'yes', $this->showFamilies()); + + if ($surname !== '' || $show_all === 'yes') { + if ($show_all !== 'yes') { + echo '<h2 class="wt-page-title">', I18N::translate('Individuals with surname %s', $legend), '</h2>'; + } + // Don't show the list until we have some filter criteria + $show = $falpha !== '' || $show_all_firstnames === 'yes' ? 'indi' : 'none'; + echo '<ul class="d-flex flex-wrap list-unstyled justify-content-center wt-initials-list wt-initials-list-given-names">'; + foreach ($givn_initials as $givn_initial => $given_count) { + echo '<li class="wt-initials-list-item d-flex">'; + if ($given_count > 0) { + if ($show === 'indi' && $givn_initial === $falpha && $show_all_firstnames !== 'yes') { + echo '<a class="wt-initial px-1 active" href="' . e($this->listUrl($tree, ['falpha' => $givn_initial] + $params)) . '" title="' . I18N::number($given_count) . '">' . $this->displayGivenNameInitial((string) $givn_initial) . '</a>'; + } else { + echo '<a class="wt-initial px-1" href="' . e($this->listUrl($tree, ['falpha' => $givn_initial] + $params)) . '" title="' . I18N::number($given_count) . '">' . $this->displayGivenNameInitial((string) $givn_initial) . '</a>'; + } + } else { + echo '<span class="wt-initial px-1 text-muted">' . $this->displayGivenNameInitial((string) $givn_initial) . '</span>'; + } + echo '</li>'; + } + // Search spiders don't get the "show all" option as the other links give them everything. + if (Session::has('initiated')) { + echo '<li class="wt-initials-list-item d-flex">'; + if ($show_all_firstnames === 'yes') { + echo '<span class="wt-initial px-1 active">' . I18N::translate('All') . '</span>'; + } else { + echo '<a class="wt-initial px-1" href="' . e($this->listUrl($tree, ['show_all_firstnames' => 'yes'] + $params)) . '" title="' . I18N::number($count) . '">' . I18N::translate('All') . '</a>'; + } + echo '</li>'; + } + echo '</ul>'; + } + } + if ($show === 'indi') { + if ($alpha === '@') { + $surns_to_show = ['@N.N.']; + } elseif ($alpha === ',') { + $surns_to_show = ['']; + } elseif ($surname !== '') { + $surns_to_show = $all_surns[$surname]; + } elseif ($alpha !== '') { + $tmp = array_filter( + $all_surns, + static fn (string $x): bool => I18N::language()->initialLetter($x) === $alpha, + ARRAY_FILTER_USE_KEY + ); + + $surns_to_show = array_merge(...array_values($tmp)); + } else { + $surns_to_show = []; + } + + if ($this->showFamilies()) { + echo view('lists/families-table', [ + 'families' => $this->families($tree, $surns_to_show, $falpha, $show_marnm === 'yes'), + 'tree' => $tree, + ]); + } else { + echo view('lists/individuals-table', [ + 'individuals' => $this->individuals($tree, $surns_to_show, $falpha, $show_marnm === 'yes', false), + 'sosa' => false, + 'tree' => $tree, + ]); + } + } + } + } ?> + </div> + <?php + + $html = ob_get_clean(); + + return $this->viewResponse('modules/individual-list/page', [ + 'content' => $html, + 'title' => $title, + 'tree' => $tree, + ]); + } + + /** + * Some initial letters have a special meaning + */ + protected function displayGivenNameInitial(string $initial): string + { + if ($initial === '@') { + return I18N::translateContext('Unknown given name', '…'); + } + + return e($initial); + } + + /** + * Some initial letters have a special meaning + */ + protected function displaySurnameInitial(string $initial): string + { + if ($initial === '@') { + return I18N::translateContext('Unknown surname', '…'); + } + + if ($initial === ',') { + return I18N::translate('No surname'); + } + + return e($initial); + } + + /** + * Restrict a query to individuals that are a spouse in a family record. + */ + protected function whereFamily(bool $fams, Builder $query): void + { + if ($fams) { + $query->join('link', static function (JoinClause $join): void { + $join + ->on('l_from', '=', 'n_id') + ->on('l_file', '=', 'n_file') + ->where('l_type', '=', 'FAMS'); + }); + } + } + + /** + * Restrict a query to include/exclude married names. + */ + protected function whereMarriedName(bool $marnm, Builder $query): void + { + if (!$marnm) { + $query->where('n_type', '<>', '_MARNM'); + } + } + + /** + * Get a count of individuals with each initial letter + * + * @param array<string> $surns if set, only consider people with this surname + * @param bool $marnm if set, include married names + * @param bool $fams if set, only consider individuals with FAMS records + * + * @return array<int> + */ + public function givenNameInitials(Tree $tree, array $surns, bool $marnm, bool $fams): array + { + $initials = []; + + // Ensure our own language comes before others. + foreach (I18N::language()->alphabet() as $initial) { + $initials[$initial] = 0; + } + + $query = DB::table('name') + ->where('n_file', '=', $tree->id()); + + $this->whereFamily($fams, $query); + $this->whereMarriedName($marnm, $query); + + if ($surns !== []) { + $query->whereIn('n_surn', $surns); + } + + $query + ->select([DB::binaryColumn('n_givn', 'n_givn'), new Expression('COUNT(*) AS count')]) + ->groupBy([DB::binaryColumn('n_givn')]); + + foreach ($query->get() as $row) { + $initial = I18N::strtoupper(I18N::language()->initialLetter($row->n_givn)); + $initials[$initial] ??= 0; + $initials[$initial] += (int) $row->count; + } + + $count_unknown = $initials['@'] ?? 0; + + if ($count_unknown > 0) { + unset($initials['@']); + $initials['@'] = $count_unknown; + } + + return $initials; + } + + /** + * @return array<object{n_surn:string,n_surname:string,total:int}> + */ + private function surnameData(Tree $tree, bool $marnm, bool $fams): array + { + $query = DB::table('name') + ->where('n_file', '=', $tree->id()) + ->whereNotNull('n_surn') // Filters old records for sources, repositories, etc. + ->whereNotNull('n_surname') + ->select([ + DB::binaryColumn('n_surn', 'n_surn'), + DB::binaryColumn('n_surname', 'n_surname'), + new Expression('COUNT(*) AS total'), + ]); + + $this->whereFamily($fams, $query); + $this->whereMarriedName($marnm, $query); + + $query->groupBy([ + DB::binaryColumn('n_surn'), + DB::binaryColumn('n_surname'), + ]); + + return $query + ->get() + ->map(static fn (object $x): object => (object) ['n_surn' => $x->n_surn, 'n_surname' => $x->n_surname, 'total' => (int) $x->total]) + ->all(); + } + + /** + * Group n_surn values, based on collation rules for the current language. + * We need them to find the individuals with this n_surn. + * + * @param array<object{n_surn:string,n_surname:string,total:int}> $surname_data + * + * @return array<array<int,string>> + */ + protected function allSurns(array $surname_data): array + { + $list = []; + + foreach ($surname_data as $row) { + $normalized = I18N::strtoupper(I18N::language()->normalize($row->n_surn)); + $list[$normalized][] = $row->n_surn; + } + + uksort($list, I18N::comparator()); + + return $list; + } + + /** + * Group n_surname values, based on collation rules for each n_surn. + * We need them to show counts of individuals with each surname. + * + * @param array<object{n_surn:string,n_surname:string,total:int}> $surname_data + * + * @return array<array<int>> + */ + protected function allSurnames(array $surname_data): array + { + $list = []; + + foreach ($surname_data as $row) { + $n_surn = $row->n_surn === '' ? $row->n_surname : $row->n_surn; + $n_surn = I18N::strtoupper(I18N::language()->normalize($n_surn)); + + $list[$n_surn][$row->n_surname] ??= 0; + $list[$n_surn][$row->n_surname] += $row->total; + } + + uksort($list, I18N::comparator()); + + return $list; + } + + /** + * Extract initial letters and counts for all surnames. + * + * @param array<object{n_surn:string,n_surname:string,total:int}> $surname_data + * + * @return array<int> + */ + protected function surnameInitials(array $surname_data): array + { + $initials = []; + + // Ensure our own language comes before others. + foreach (I18N::language()->alphabet() as $initial) { + $initials[$initial] = 0; + } + + foreach ($surname_data as $row) { + $initial = I18N::language()->initialLetter(I18N::strtoupper($row->n_surn)); + $initial = I18N::language()->normalize($initial); + + $initials[$initial] ??= 0; + $initials[$initial] += $row->total; + } + + // Move specials to the end + $count_none = $initials[''] ?? 0; + + if ($count_none > 0) { + unset($initials['']); + $initials[','] = $count_none; + } + + $count_unknown = $initials['@'] ?? 0; + + if ($count_unknown > 0) { + unset($initials['@']); + $initials['@'] = $count_unknown; + } + + return $initials; + } + + /** + * Fetch a list of individuals with specified names + * To search for unknown names, use $surn="@N.N.", $salpha="@" or $galpha="@" + * To search for names with no surnames, use $salpha="," + * + * @param array<string> $surns_to_show if set, only fetch people with this n_surn + * @param string $galpha if set, only fetch given names starting with this letter + * @param bool $marnm if set, include married names + * @param bool $fams if set, only fetch individuals with FAMS records + * + * @return Collection<int,Individual> + */ + protected function individuals(Tree $tree, array $surns_to_show, string $galpha, bool $marnm, bool $fams): Collection + { + $query = DB::table('individuals') + ->join('name', static function (JoinClause $join): void { + $join + ->on('n_id', '=', 'i_id') + ->on('n_file', '=', 'i_file'); + }) + ->where('i_file', '=', $tree->id()) + ->select(['i_id AS xref', 'i_gedcom AS gedcom', 'n_givn', 'n_surn']); + + $this->whereFamily($fams, $query); + $this->whereMarriedName($marnm, $query); + + if ($surns_to_show === []) { + $query->whereNotIn('n_surn', ['', '@N.N.']); + } else { + $query->whereIn(DB::binaryColumn('n_surn'), $surns_to_show); + } + + $individuals = new Collection(); + + foreach ($query->get() as $row) { + $individual = Registry::individualFactory()->make($row->xref, $tree, $row->gedcom); + assert($individual instanceof Individual); + + // The name from the database may be private - check the filtered list... + foreach ($individual->getAllNames() as $n => $name) { + if ($name['givn'] === $row->n_givn && $name['surn'] === $row->n_surn) { + if ($galpha === '' || I18N::strtoupper(I18N::language()->initialLetter($row->n_givn)) === $galpha) { + $individual->setPrimaryName($n); + // We need to clone $individual, as we may have multiple references to the + // same individual in this list, and the "primary name" would otherwise + // be shared amongst all of them. + $individuals->push(clone $individual); + break; + } + } + } + } + + return $individuals; + } + + /** + * Fetch a list of families with specified names + * To search for unknown names, use $surn="@N.N.", $salpha="@" or $galpha="@" + * To search for names with no surnames, use $salpha="," + * + * @param array<string> $surnames if set, only fetch people with this n_surname + * @param string $galpha if set, only fetch given names starting with this letter + * @param bool $marnm if set, include married names + * + * @return Collection<int,Family> + */ + protected function families(Tree $tree, array $surnames, string $galpha, bool $marnm): Collection + { + $families = new Collection(); + + foreach ($this->individuals($tree, $surnames, $galpha, $marnm, true) as $indi) { + foreach ($indi->spouseFamilies() as $family) { + $families->push($family); + } + } + + return $families->unique(); + } +} diff --git a/app/Module/FamilyListModule.php b/app/Module/FamilyListModule.php index f84c3e3363..89a397f2ef 100644 --- a/app/Module/FamilyListModule.php +++ b/app/Module/FamilyListModule.php @@ -19,54 +19,34 @@ declare(strict_types=1); namespace Fisharebest\Webtrees\Module; -use Fig\Http\Message\StatusCodeInterface; -use Fisharebest\Webtrees\Auth; use Fisharebest\Webtrees\I18N; -use Fisharebest\Webtrees\Registry; -use Fisharebest\Webtrees\Validator; -use Psr\Http\Message\ResponseInterface; -use Psr\Http\Message\ServerRequestInterface; -/** - * Class FamilyListModule - */ class FamilyListModule extends IndividualListModule { - protected const ROUTE_URL = '/tree/{tree}/family-list'; - - // The individual list and family list use the same code/logic. - // They just display different lists. - protected bool $families = true; - - /** - * How should this module be identified in the control panel, etc.? - * - * @return string - */ public function title(): string { /* I18N: Name of a module/list */ return I18N::translate('Families'); } - /** - * A sentence describing what this module does. - * - * @return string - */ public function description(): string { /* I18N: Description of the “Families” module */ return I18N::translate('A list of families.'); } - /** - * CSS class for the URL. - * - * @return string - */ public function listMenuClass(): string { return 'menu-list-fam'; } + + protected function showFamilies(): bool + { + return true; + } + + protected function routeUrl(): string + { + return '/tree/{tree}/family-list'; + } } diff --git a/app/Module/IndividualListModule.php b/app/Module/IndividualListModule.php index a32c25058a..6d274082ea 100644 --- a/app/Module/IndividualListModule.php +++ b/app/Module/IndividualListModule.php @@ -19,807 +19,34 @@ declare(strict_types=1); namespace Fisharebest\Webtrees\Module; -use Fig\Http\Message\StatusCodeInterface; -use Fisharebest\Webtrees\Auth; -use Fisharebest\Webtrees\DB; -use Fisharebest\Webtrees\Family; -use Fisharebest\Webtrees\FlashMessages; use Fisharebest\Webtrees\I18N; -use Fisharebest\Webtrees\Individual; -use Fisharebest\Webtrees\Registry; -use Fisharebest\Webtrees\Session; -use Fisharebest\Webtrees\Tree; -use Fisharebest\Webtrees\Validator; -use Illuminate\Database\Query\Builder; -use Illuminate\Database\Query\Expression; -use Illuminate\Database\Query\JoinClause; -use Illuminate\Support\Collection; -use Psr\Http\Message\ResponseInterface; -use Psr\Http\Message\ServerRequestInterface; -use Psr\Http\Server\RequestHandlerInterface; -use function array_filter; -use function array_key_exists; -use function array_keys; -use function array_map; -use function array_merge; -use function array_sum; -use function array_values; -use function assert; -use function e; -use function implode; -use function ob_get_clean; -use function ob_start; -use function route; -use function uksort; -use function usort; -use function view; - -use const ARRAY_FILTER_USE_KEY; - -/** - * Class IndividualListModule - */ -class IndividualListModule extends AbstractModule implements ModuleListInterface, RequestHandlerInterface +class IndividualListModule extends AbstractIndividualListModule { - use ModuleListTrait; - - protected const ROUTE_URL = '/tree/{tree}/individual-list'; - - // The individual list and family list use the same code/logic. - // They just display different lists. - protected bool $families = false; - - /** - * Initialization. - * - * @return void - */ - public function boot(): void - { - Registry::routeFactory()->routeMap() - ->get(static::class, static::ROUTE_URL, $this); - } - - /** - * How should this module be identified in the control panel, etc.? - * - * @return string - */ public function title(): string { /* I18N: Name of a module/list */ return I18N::translate('Individuals'); } - /** - * A sentence describing what this module does. - * - * @return string - */ public function description(): string { /* I18N: Description of the “Individuals” module */ return I18N::translate('A list of individuals.'); } - /** - * CSS class for the URL. - * - * @return string - */ public function listMenuClass(): string { return 'menu-list-indi'; } - /** - * @param Tree $tree - * @param array<bool|int|string|array<string>|null> $parameters - * - * @return string - */ - public function listUrl(Tree $tree, array $parameters = []): string - { - $request = Registry::container()->get(ServerRequestInterface::class); - $xref = Validator::attributes($request)->isXref()->string('xref', ''); - - if ($xref !== '') { - $individual = Registry::individualFactory()->make($xref, $tree); - - if ($individual instanceof Individual && $individual->canShow()) { - $primary_name = $individual->getPrimaryName(); - - $parameters['surname'] ??= $individual->getAllNames()[$primary_name]['surn'] ?? null; - } - } - - $parameters['tree'] = $tree->name(); - - return route(static::class, $parameters); - } - - /** - * @return array<string> - */ - public function listUrlAttributes(): array - { - return []; - } - - /** - * @param ServerRequestInterface $request - * - * @return ResponseInterface - */ - public function handle(ServerRequestInterface $request): ResponseInterface - { - $tree = Validator::attributes($request)->tree(); - $user = Validator::attributes($request)->user(); - - Auth::checkComponentAccess($this, ModuleListInterface::class, $tree, $user); - - // All individuals with this surname - $surname_param = Validator::queryParams($request)->string('surname', ''); - $surname = I18N::strtoupper(I18N::language()->normalize($surname_param)); - - // All surnames beginning with this letter, where "@" is unknown and "," is none - $alpha = Validator::queryParams($request)->string('alpha', ''); - - // All first names beginning with this letter where "@" is unknown - $falpha = Validator::queryParams($request)->string('falpha', ''); - - // What type of list to display, if any - $show = Validator::queryParams($request)->string('show', 'surn'); - - // All individuals - $show_all = Validator::queryParams($request)->string('show_all', ''); - - // Include/exclude married names - $show_marnm = Validator::queryParams($request)->string('show_marnm', ''); - - // Break long lists down by given name - $show_all_firstnames = Validator::queryParams($request)->string('show_all_firstnames', ''); - - $params = [ - 'alpha' => $alpha, - 'falpha' => $falpha, - 'show' => $show, - 'show_all' => $show_all, - 'show_all_firstnames' => $show_all_firstnames, - 'show_marnm' => $show_marnm, - 'surname' => $surname, - ]; - - if ($surname_param !== $surname) { - return Registry::responseFactory() - ->redirectUrl($this->listUrl($tree, $params), StatusCodeInterface::STATUS_MOVED_PERMANENTLY); - } - - // Make sure parameters are consistent with each other. - if ($show_all_firstnames === 'yes') { - $falpha = ''; - } - - if ($show_all === 'yes') { - $alpha = ''; - $surname = ''; - } - - if ($surname !== '') { - $alpha = I18N::language()->initialLetter($surname); - } - - $surname_data = $this->surnameData($tree, $show_marnm === 'yes', $this->families); - $all_surns = $this->allSurns($surname_data); - $all_surnames = $this->allSurnames($surname_data); - $surname_initials = $this->surnameInitials($surname_data); - - // We've requested a surname that doesn't currently exist. - if ($surname !== '' && !array_key_exists($surname, $all_surns)) { - $message = I18N::translate('There are no individuals with the surname “%s”', e($surname)); - FlashMessages::addMessage($message); - - return Registry::responseFactory() - ->redirectUrl($this->listUrl($tree)); - } - - // Make sure selections are consistent. - // i.e. can’t specify show_all and surname at the same time. - if ($show_all === 'yes') { - if ($show_all_firstnames === 'yes') { - $legend = I18N::translate('All'); - $params = ['tree' => $tree->name(), 'show_all' => 'yes', 'show_marnm' => $show_marnm]; - $show = 'indi'; - } elseif ($falpha !== '') { - $legend = I18N::translate('All') . ', ' . e($falpha) . '…'; - $params = ['tree' => $tree->name(), 'show_all' => 'yes', 'show_marnm' => $show_marnm]; - $show = 'indi'; - } else { - $legend = I18N::translate('All'); - $params = ['tree' => $tree->name(), 'show_all' => 'yes', 'show_marnm' => $show_marnm]; - } - } elseif ($surname !== '') { - $show_all = 'no'; - if ($surname === Individual::NOMEN_NESCIO) { - $legend = I18N::translateContext('Unknown surname', '…'); - $show = 'indi'; // The surname list makes no sense with only one surname. - } else { - // The surname parameter is a root/canonical form. Display the actual surnames found. - $variants = array_keys($all_surnames[$surname] ?? [$surname => $surname]); - usort($variants, I18N::comparator()); - $variants = array_map(static fn (string $x): string => $x === '' ? I18N::translate('No surname') : $x, $variants); - $legend = implode('/', $variants); - $show = 'indi'; // The surname list makes no sense with only one surname. - } - $params = ['tree' => $tree->name(), 'surname' => $surname, 'falpha' => $falpha, 'show_marnm' => $show_marnm]; - switch ($falpha) { - case '': - break; - case '@': - $legend .= ', ' . I18N::translateContext('Unknown given name', '…'); - break; - default: - $legend .= ', ' . e($falpha) . '…'; - break; - } - } elseif ($alpha === '@') { - $show_all = 'no'; - $legend = I18N::translateContext('Unknown surname', '…'); - $params = ['alpha' => $alpha, 'tree' => $tree->name(), 'show_marnm' => $show_marnm]; - $surname = Individual::NOMEN_NESCIO; - $show = 'indi'; // SURN list makes no sense here - } elseif ($alpha === ',') { - $show_all = 'no'; - $legend = I18N::translate('No surname'); - $params = ['alpha' => $alpha, 'tree' => $tree->name(), 'show_marnm' => $show_marnm]; - $show = 'indi'; // SURN list makes no sense here - } elseif ($alpha !== '') { - $show_all = 'no'; - $legend = e($alpha) . '…'; - $params = ['alpha' => $alpha, 'tree' => $tree->name(), 'show_marnm' => $show_marnm]; - } else { - $show_all = 'no'; - $legend = '…'; - $params = ['tree' => $tree->name(), 'show_marnm' => $show_marnm]; - $show = 'none'; // Don't show lists until something is chosen - } - $legend = '<bdi>' . $legend . '</bdi>'; - - if ($this->families) { - $title = I18N::translate('Families') . ' — ' . $legend; - } else { - $title = I18N::translate('Individuals') . ' — ' . $legend; - } - - ob_start(); ?> - <div class="d-flex flex-column wt-page-options wt-page-options-individual-list d-print-none"> - <ul class="d-flex flex-wrap list-unstyled justify-content-center wt-initials-list wt-initials-list-surname"> - - <?php foreach ($surname_initials as $letter => $count) : ?> - <li class="wt-initials-list-item d-flex"> - <?php if ($count > 0) : ?> - <a href="<?= e($this->listUrl($tree, ['alpha' => $letter, 'show_marnm' => $show_marnm, 'tree' => $tree->name()])) ?>" class="wt-initial px-1<?= $letter === $alpha ? ' active' : '' ?> '" title="<?= I18N::number($count) ?>"><?= $this->displaySurnameInitial((string) $letter) ?></a> - <?php else : ?> - <span class="wt-initial px-1 text-muted"><?= $this->displaySurnameInitial((string) $letter) ?></span> - - <?php endif ?> - </li> - <?php endforeach ?> - - <?php if (Session::has('initiated')) : ?> - <!-- Search spiders don't get the "show all" option as the other links give them everything. --> - <li class="wt-initials-list-item d-flex"> - <a class="wt-initial px-1<?= $show_all === 'yes' ? ' active' : '' ?>" href="<?= e($this->listUrl($tree, ['show_all' => 'yes'] + $params)) ?>"><?= I18N::translate('All') ?></a> - </li> - <?php endif ?> - </ul> - - <!-- Search spiders don't get an option to show/hide the surname sublists, nor does it make sense on the all/unknown/surname views --> - <?php if ($show !== 'none' && Session::has('initiated')) : ?> - <?php if ($show_marnm === 'yes') : ?> - <p> - <a href="<?= e($this->listUrl($tree, ['show' => $show, 'show_marnm' => 'no'] + $params)) ?>"> - <?= I18N::translate('Exclude individuals with “%s” as a married name', $legend) ?> - </a> - </p> - <?php else : ?> - <p> - <a href="<?= e($this->listUrl($tree, ['show' => $show, 'show_marnm' => 'yes'] + $params)) ?>"> - <?= I18N::translate('Include individuals with “%s” as a married name', $legend) ?> - </a> - </p> - <?php endif ?> - - <?php if ($alpha !== '@' && $alpha !== ',' && $surname === '') : ?> - <?php if ($show === 'surn') : ?> - <p> - <a href="<?= e($this->listUrl($tree, ['show' => 'indi'] + $params)) ?>"> - <?= I18N::translate('Show the list of individuals') ?> - </a> - </p> - <?php else : ?> - <p> - <a href="<?= e($this->listUrl($tree, ['show' => 'surn'] + $params)) ?>"> - <?= I18N::translate('Show the list of surnames') ?> - </a> - </p> - <?php endif ?> - <?php endif ?> - <?php endif ?> - </div> - - <div class="wt-page-content"> - <?php - if ($show === 'indi' || $show === 'surn') { - switch ($alpha) { - case '@': - $filter = static fn (string $x): bool => $x === Individual::NOMEN_NESCIO; - break; - case ',': - $filter = static fn (string $x): bool => $x === ''; - break; - case '': - if ($show_all === 'yes') { - $filter = static fn (string $x): bool => $x !== '' && $x !== Individual::NOMEN_NESCIO; - } else { - $filter = static fn (string $x): bool => $x === $surname; - } - break; - default: - if ($surname === '') { - $filter = static fn (string $x): bool => I18N::language()->initialLetter($x) === $alpha; - } else { - $filter = static fn (string $x): bool => $x === $surname; - } - break; - } - - $all_surnames = array_filter($all_surnames, $filter, ARRAY_FILTER_USE_KEY); - - if ($show === 'surn') { - // Show the surname list - switch ($tree->getPreference('SURNAME_LIST_STYLE')) { - case 'style1': - echo view('lists/surnames-column-list', [ - 'module' => $this, - 'params' => ['show' => 'indi', 'show_all' => null] + $params, - 'surnames' => $all_surnames, - 'totals' => true, - 'tree' => $tree, - ]); - break; - case 'style3': - echo view('lists/surnames-tag-cloud', [ - 'module' => $this, - 'params' => ['show' => 'indi', 'show_all' => null] + $params, - 'surnames' => $all_surnames, - 'totals' => true, - 'tree' => $tree, - ]); - break; - case 'style2': - default: - echo view('lists/surnames-table', [ - 'families' => $this->families, - 'module' => $this, - 'order' => [[0, 'asc']], - 'params' => ['show' => 'indi', 'show_all' => null] + $params, - 'surnames' => $all_surnames, - 'tree' => $tree, - ]); - break; - } - } else { - // Show the list - $count = array_sum(array_map(static fn (array $x): int => array_sum($x), $all_surnames)); - - // Don't sublist short lists. - $sublist_threshold = (int) $tree->getPreference('SUBLIST_TRIGGER_I'); - if ($sublist_threshold === 0 || $count < $sublist_threshold) { - $falpha = ''; - } else { - // Break long lists by initial letter of given name - $all_surnames = array_values(array_map(static fn ($x): array => array_keys($x), $all_surnames)); - $all_surnames = array_merge(...$all_surnames); - $givn_initials = $this->givenNameInitials($tree, $all_surnames, $show_marnm === 'yes', $this->families); - - if ($surname !== '' || $show_all === 'yes') { - if ($show_all !== 'yes') { - echo '<h2 class="wt-page-title">', I18N::translate('Individuals with surname %s', $legend), '</h2>'; - } - // Don't show the list until we have some filter criteria - $show = $falpha !== '' || $show_all_firstnames === 'yes' ? 'indi' : 'none'; - echo '<ul class="d-flex flex-wrap list-unstyled justify-content-center wt-initials-list wt-initials-list-given-names">'; - foreach ($givn_initials as $givn_initial => $given_count) { - echo '<li class="wt-initials-list-item d-flex">'; - if ($given_count > 0) { - if ($show === 'indi' && $givn_initial === $falpha && $show_all_firstnames !== 'yes') { - echo '<a class="wt-initial px-1 active" href="' . e($this->listUrl($tree, ['falpha' => $givn_initial] + $params)) . '" title="' . I18N::number($given_count) . '">' . $this->displayGivenNameInitial((string) $givn_initial) . '</a>'; - } else { - echo '<a class="wt-initial px-1" href="' . e($this->listUrl($tree, ['falpha' => $givn_initial] + $params)) . '" title="' . I18N::number($given_count) . '">' . $this->displayGivenNameInitial((string) $givn_initial) . '</a>'; - } - } else { - echo '<span class="wt-initial px-1 text-muted">' . $this->displayGivenNameInitial((string) $givn_initial) . '</span>'; - } - echo '</li>'; - } - // Search spiders don't get the "show all" option as the other links give them everything. - if (Session::has('initiated')) { - echo '<li class="wt-initials-list-item d-flex">'; - if ($show_all_firstnames === 'yes') { - echo '<span class="wt-initial px-1 active">' . I18N::translate('All') . '</span>'; - } else { - echo '<a class="wt-initial px-1" href="' . e($this->listUrl($tree, ['show_all_firstnames' => 'yes'] + $params)) . '" title="' . I18N::number($count) . '">' . I18N::translate('All') . '</a>'; - } - echo '</li>'; - } - echo '</ul>'; - } - } - if ($show === 'indi') { - if ($alpha === '@') { - $surns_to_show = ['@N.N.']; - } elseif ($alpha === ',') { - $surns_to_show = ['']; - } elseif ($surname !== '') { - $surns_to_show = $all_surns[$surname]; - } elseif ($alpha !== '') { - $tmp = array_filter( - $all_surns, - static fn (string $x): bool => I18N::language()->initialLetter($x) === $alpha, - ARRAY_FILTER_USE_KEY - ); - - $surns_to_show = array_merge(...array_values($tmp)); - } else { - $surns_to_show = []; - } - - if ($this->families) { - echo view('lists/families-table', [ - 'families' => $this->families($tree, $surns_to_show, $falpha, $show_marnm === 'yes'), - 'tree' => $tree, - ]); - } else { - echo view('lists/individuals-table', [ - 'individuals' => $this->individuals($tree, $surns_to_show, $falpha, $show_marnm === 'yes', false), - 'sosa' => false, - 'tree' => $tree, - ]); - } - } - } - } ?> - </div> - <?php - - $html = ob_get_clean(); - - return $this->viewResponse('modules/individual-list/page', [ - 'content' => $html, - 'title' => $title, - 'tree' => $tree, - ]); - } - - /** - * Some initial letters have a special meaning - * - * @param string $initial - * - * @return string - */ - protected function displayGivenNameInitial(string $initial): string - { - if ($initial === '@') { - return I18N::translateContext('Unknown given name', '…'); - } - - return e($initial); - } - - /** - * Some initial letters have a special meaning - * - * @param string $initial - * - * @return string - */ - protected function displaySurnameInitial(string $initial): string + protected function showFamilies(): bool { - if ($initial === '@') { - return I18N::translateContext('Unknown surname', '…'); - } - - if ($initial === ',') { - return I18N::translate('No surname'); - } - - return e($initial); - } - - /** - * Restrict a query to individuals that are a spouse in a family record. - * - * @param bool $fams - * @param Builder $query - */ - protected function whereFamily(bool $fams, Builder $query): void - { - if ($fams) { - $query->join('link', static function (JoinClause $join): void { - $join - ->on('l_from', '=', 'n_id') - ->on('l_file', '=', 'n_file') - ->where('l_type', '=', 'FAMS'); - }); - } - } - - /** - * Restrict a query to include/exclude married names. - * - * @param bool $marnm - * @param Builder $query - */ - protected function whereMarriedName(bool $marnm, Builder $query): void - { - if (!$marnm) { - $query->where('n_type', '<>', '_MARNM'); - } + return false; } - /** - * Get a count of individuals with each initial letter - * - * @param Tree $tree - * @param array<string> $surns if set, only consider people with this surname - * @param bool $marnm if set, include married names - * @param bool $fams if set, only consider individuals with FAMS records - * - * @return array<int> - */ - public function givenNameInitials(Tree $tree, array $surns, bool $marnm, bool $fams): array + protected function routeUrl(): string { - $initials = []; - - // Ensure our own language comes before others. - foreach (I18N::language()->alphabet() as $initial) { - $initials[$initial] = 0; - } - - $query = DB::table('name') - ->where('n_file', '=', $tree->id()); - - $this->whereFamily($fams, $query); - $this->whereMarriedName($marnm, $query); - - if ($surns !== []) { - $query->whereIn('n_surn', $surns); - } - - $query - ->select([DB::binaryColumn('n_givn', 'n_givn'), new Expression('COUNT(*) AS count')]) - ->groupBy([DB::binaryColumn('n_givn')]); - - foreach ($query->get() as $row) { - $initial = I18N::strtoupper(I18N::language()->initialLetter($row->n_givn)); - $initials[$initial] ??= 0; - $initials[$initial] += (int) $row->count; - } - - $count_unknown = $initials['@'] ?? 0; - - if ($count_unknown > 0) { - unset($initials['@']); - $initials['@'] = $count_unknown; - } - - return $initials; - } - - /** - * @param Tree $tree - * @param bool $marnm - * @param bool $fams - * - * @return array<object{n_surn:string,n_surname:string,total:int}> - */ - private function surnameData(Tree $tree, bool $marnm, bool $fams): array - { - $query = DB::table('name') - ->where('n_file', '=', $tree->id()) - ->whereNotNull('n_surn') // Filters old records for sources, repositories, etc. - ->whereNotNull('n_surname') - ->select([ - DB::binaryColumn('n_surn', 'n_surn'), - DB::binaryColumn('n_surname', 'n_surname'), - new Expression('COUNT(*) AS total'), - ]); - - $this->whereFamily($fams, $query); - $this->whereMarriedName($marnm, $query); - - $query->groupBy([ - DB::binaryColumn('n_surn'), - DB::binaryColumn('n_surname'), - ]); - - return $query - ->get() - ->map(static fn (object $x): object => (object) ['n_surn' => $x->n_surn, 'n_surname' => $x->n_surname, 'total' => (int) $x->total]) - ->all(); - } - - /** - * Group n_surn values, based on collation rules for the current language. - * We need them to find the individuals with this n_surn. - * - * @param array<object{n_surn:string,n_surname:string,total:int}> $surname_data - * - * @return array<array<int,string>> - */ - protected function allSurns(array $surname_data): array - { - $list = []; - - foreach ($surname_data as $row) { - $normalized = I18N::strtoupper(I18N::language()->normalize($row->n_surn)); - $list[$normalized][] = $row->n_surn; - } - - uksort($list, I18N::comparator()); - - return $list; - } - - /** - * Group n_surname values, based on collation rules for each n_surn. - * We need them to show counts of individuals with each surname. - * - * @param array<object{n_surn:string,n_surname:string,total:int}> $surname_data - * - * @return array<array<int>> - */ - protected function allSurnames(array $surname_data): array - { - $list = []; - - foreach ($surname_data as $row) { - $n_surn = $row->n_surn === '' ? $row->n_surname : $row->n_surn; - $n_surn = I18N::strtoupper(I18N::language()->normalize($n_surn)); - - $list[$n_surn][$row->n_surname] ??= 0; - $list[$n_surn][$row->n_surname] += $row->total; - } - - uksort($list, I18N::comparator()); - - return $list; - } - - /** - * Extract initial letters and counts for all surnames. - * - * @param array<object{n_surn:string,n_surname:string,total:int}> $surname_data - * - * @return array<int> - */ - protected function surnameInitials(array $surname_data): array - { - $initials = []; - - // Ensure our own language comes before others. - foreach (I18N::language()->alphabet() as $initial) { - $initials[$initial] = 0; - } - - foreach ($surname_data as $row) { - $initial = I18N::language()->initialLetter(I18N::strtoupper($row->n_surn)); - $initial = I18N::language()->normalize($initial); - - $initials[$initial] ??= 0; - $initials[$initial] += $row->total; - } - - // Move specials to the end - $count_none = $initials[''] ?? 0; - - if ($count_none > 0) { - unset($initials['']); - $initials[','] = $count_none; - } - - $count_unknown = $initials['@'] ?? 0; - - if ($count_unknown > 0) { - unset($initials['@']); - $initials['@'] = $count_unknown; - } - - return $initials; - } - - /** - * Fetch a list of individuals with specified names - * To search for unknown names, use $surn="@N.N.", $salpha="@" or $galpha="@" - * To search for names with no surnames, use $salpha="," - * - * @param Tree $tree - * @param array<string> $surns_to_show if set, only fetch people with this n_surn - * @param string $galpha if set, only fetch given names starting with this letter - * @param bool $marnm if set, include married names - * @param bool $fams if set, only fetch individuals with FAMS records - * - * @return Collection<int,Individual> - */ - protected function individuals(Tree $tree, array $surns_to_show, string $galpha, bool $marnm, bool $fams): Collection - { - $query = DB::table('individuals') - ->join('name', static function (JoinClause $join): void { - $join - ->on('n_id', '=', 'i_id') - ->on('n_file', '=', 'i_file'); - }) - ->where('i_file', '=', $tree->id()) - ->select(['i_id AS xref', 'i_gedcom AS gedcom', 'n_givn', 'n_surn']); - - $this->whereFamily($fams, $query); - $this->whereMarriedName($marnm, $query); - - if ($surns_to_show === []) { - $query->whereNotIn('n_surn', ['', '@N.N.']); - } else { - $query->whereIn(DB::binaryColumn('n_surn'), $surns_to_show); - } - - $individuals = new Collection(); - - foreach ($query->get() as $row) { - $individual = Registry::individualFactory()->make($row->xref, $tree, $row->gedcom); - assert($individual instanceof Individual); - - // The name from the database may be private - check the filtered list... - foreach ($individual->getAllNames() as $n => $name) { - if ($name['givn'] === $row->n_givn && $name['surn'] === $row->n_surn) { - if ($galpha === '' || I18N::strtoupper(I18N::language()->initialLetter($row->n_givn)) === $galpha) { - $individual->setPrimaryName($n); - // We need to clone $individual, as we may have multiple references to the - // same individual in this list, and the "primary name" would otherwise - // be shared amongst all of them. - $individuals->push(clone $individual); - break; - } - } - } - } - - return $individuals; - } - - /** - * Fetch a list of families with specified names - * To search for unknown names, use $surn="@N.N.", $salpha="@" or $galpha="@" - * To search for names with no surnames, use $salpha="," - * - * @param Tree $tree - * @param array<string> $surnames if set, only fetch people with this n_surname - * @param string $galpha if set, only fetch given names starting with this letter - * @param bool $marnm if set, include married names - * - * @return Collection<int,Family> - */ - protected function families(Tree $tree, array $surnames, string $galpha, bool $marnm): Collection - { - $families = new Collection(); - - foreach ($this->individuals($tree, $surnames, $galpha, $marnm, true) as $indi) { - foreach ($indi->spouseFamilies() as $family) { - $families->push($family); - } - } - - return $families->unique(); + return '/tree/{tree}/individual-list'; } } diff --git a/app/Module/TopSurnamesModule.php b/app/Module/TopSurnamesModule.php index cae6e04dcc..1b652b25ca 100644 --- a/app/Module/TopSurnamesModule.php +++ b/app/Module/TopSurnamesModule.php @@ -133,8 +133,7 @@ class TopSurnamesModule extends AbstractModule implements ModuleBlockInterface // Find a module providing individual lists. $module = $this->module_service ->findByComponent(ModuleListInterface::class, $tree, Auth::user()) - // The family list extends the individual list - ->first(static fn (ModuleInterface $module): bool => $module instanceof IndividualListModule && !$module instanceof FamilyListModule); + ->first(static fn (ModuleInterface $module): bool => $module instanceof IndividualListModule); switch ($info_style) { case 'tagcloud': diff --git a/phpstan-baseline.php b/phpstan-baseline.php index 32b83d83c9..e640831cef 100644 --- a/phpstan-baseline.php +++ b/phpstan-baseline.php @@ -1799,6 +1799,78 @@ $ignoreErrors[] = [ ]; $ignoreErrors[] = [ // identifier: property.notFound + 'message' => '#^Access to an undefined property object\\:\\:\\$n_surn\\.$#', + 'count' => 1, + 'path' => __DIR__ . '/app/Module/AbstractIndividualListModule.php', +]; +$ignoreErrors[] = [ + // identifier: property.notFound + 'message' => '#^Access to an undefined property object\\:\\:\\$n_surname\\.$#', + 'count' => 1, + 'path' => __DIR__ . '/app/Module/AbstractIndividualListModule.php', +]; +$ignoreErrors[] = [ + // identifier: property.notFound + 'message' => '#^Access to an undefined property object\\:\\:\\$total\\.$#', + 'count' => 1, + 'path' => __DIR__ . '/app/Module/AbstractIndividualListModule.php', +]; +$ignoreErrors[] = [ + // identifier: property.nonObject + 'message' => '#^Cannot access property \\$count on mixed\\.$#', + 'count' => 1, + 'path' => __DIR__ . '/app/Module/AbstractIndividualListModule.php', +]; +$ignoreErrors[] = [ + // identifier: property.nonObject + 'message' => '#^Cannot access property \\$gedcom on mixed\\.$#', + 'count' => 1, + 'path' => __DIR__ . '/app/Module/AbstractIndividualListModule.php', +]; +$ignoreErrors[] = [ + // identifier: property.nonObject + 'message' => '#^Cannot access property \\$n_givn on mixed\\.$#', + 'count' => 3, + 'path' => __DIR__ . '/app/Module/AbstractIndividualListModule.php', +]; +$ignoreErrors[] = [ + // identifier: property.nonObject + 'message' => '#^Cannot access property \\$n_surn on mixed\\.$#', + 'count' => 1, + 'path' => __DIR__ . '/app/Module/AbstractIndividualListModule.php', +]; +$ignoreErrors[] = [ + // identifier: property.nonObject + 'message' => '#^Cannot access property \\$xref on mixed\\.$#', + 'count' => 1, + 'path' => __DIR__ . '/app/Module/AbstractIndividualListModule.php', +]; +$ignoreErrors[] = [ + // identifier: argument.type + 'message' => '#^Parameter \\#1 \\$callback of method Illuminate\\\\Support\\\\Collection\\<\\(int\\|string\\),mixed\\>\\:\\:map\\(\\) expects callable\\(mixed, int\\|string\\)\\: \\(object\\{n_surn\\: mixed, n_surname\\: mixed, total\\: int\\}&stdClass\\), Closure\\(object\\)\\: \\(object\\{n_surn\\: mixed, n_surname\\: mixed, total\\: int\\}&stdClass\\) given\\.$#', + 'count' => 1, + 'path' => __DIR__ . '/app/Module/AbstractIndividualListModule.php', +]; +$ignoreErrors[] = [ + // identifier: argument.type + 'message' => '#^Parameter \\#1 \\$request of static method Fisharebest\\\\Webtrees\\\\Validator\\:\\:attributes\\(\\) expects Psr\\\\Http\\\\Message\\\\ServerRequestInterface, mixed given\\.$#', + 'count' => 1, + 'path' => __DIR__ . '/app/Module/AbstractIndividualListModule.php', +]; +$ignoreErrors[] = [ + // identifier: method.unresolvableReturnType + 'message' => '#^Return type of call to method Illuminate\\\\Support\\\\Collection\\<\\(int\\|string\\),mixed\\>\\:\\:map\\(\\) contains unresolvable type\\.$#', + 'count' => 1, + 'path' => __DIR__ . '/app/Module/AbstractIndividualListModule.php', +]; +$ignoreErrors[] = [ + // identifier: method.unresolvableReturnType + 'message' => '#^Return type of call to method Illuminate\\\\Support\\\\Collection\\<\\(int\\|string\\),object\\{n_surn\\: mixed, n_surname\\: mixed, total\\: int\\}&stdClass\\>\\:\\:all\\(\\) contains unresolvable type\\.$#', + 'count' => 1, + 'path' => __DIR__ . '/app/Module/AbstractIndividualListModule.php', +]; +$ignoreErrors[] = [ + // identifier: property.notFound 'message' => '#^Access to an undefined property object\\:\\:\\$interface\\.$#', 'count' => 1, 'path' => __DIR__ . '/app/Module/AbstractModule.php', @@ -2428,78 +2500,6 @@ $ignoreErrors[] = [ 'path' => __DIR__ . '/app/Module/IndividualFactsTabModule.php', ]; $ignoreErrors[] = [ - // identifier: property.notFound - 'message' => '#^Access to an undefined property object\\:\\:\\$n_surn\\.$#', - 'count' => 1, - 'path' => __DIR__ . '/app/Module/IndividualListModule.php', -]; -$ignoreErrors[] = [ - // identifier: property.notFound - 'message' => '#^Access to an undefined property object\\:\\:\\$n_surname\\.$#', - 'count' => 1, - 'path' => __DIR__ . '/app/Module/IndividualListModule.php', -]; -$ignoreErrors[] = [ - // identifier: property.notFound - 'message' => '#^Access to an undefined property object\\:\\:\\$total\\.$#', - 'count' => 1, - 'path' => __DIR__ . '/app/Module/IndividualListModule.php', -]; -$ignoreErrors[] = [ - // identifier: property.nonObject - 'message' => '#^Cannot access property \\$count on mixed\\.$#', - 'count' => 1, - 'path' => __DIR__ . '/app/Module/IndividualListModule.php', -]; -$ignoreErrors[] = [ - // identifier: property.nonObject - 'message' => '#^Cannot access property \\$gedcom on mixed\\.$#', - 'count' => 1, - 'path' => __DIR__ . '/app/Module/IndividualListModule.php', -]; -$ignoreErrors[] = [ - // identifier: property.nonObject - 'message' => '#^Cannot access property \\$n_givn on mixed\\.$#', - 'count' => 3, - 'path' => __DIR__ . '/app/Module/IndividualListModule.php', -]; -$ignoreErrors[] = [ - // identifier: property.nonObject - 'message' => '#^Cannot access property \\$n_surn on mixed\\.$#', - 'count' => 1, - 'path' => __DIR__ . '/app/Module/IndividualListModule.php', -]; -$ignoreErrors[] = [ - // identifier: property.nonObject - 'message' => '#^Cannot access property \\$xref on mixed\\.$#', - 'count' => 1, - 'path' => __DIR__ . '/app/Module/IndividualListModule.php', -]; -$ignoreErrors[] = [ - // identifier: argument.type - 'message' => '#^Parameter \\#1 \\$callback of method Illuminate\\\\Support\\\\Collection\\<\\(int\\|string\\),mixed\\>\\:\\:map\\(\\) expects callable\\(mixed, int\\|string\\)\\: \\(object\\{n_surn\\: mixed, n_surname\\: mixed, total\\: int\\}&stdClass\\), Closure\\(object\\)\\: \\(object\\{n_surn\\: mixed, n_surname\\: mixed, total\\: int\\}&stdClass\\) given\\.$#', - 'count' => 1, - 'path' => __DIR__ . '/app/Module/IndividualListModule.php', -]; -$ignoreErrors[] = [ - // identifier: argument.type - 'message' => '#^Parameter \\#1 \\$request of static method Fisharebest\\\\Webtrees\\\\Validator\\:\\:attributes\\(\\) expects Psr\\\\Http\\\\Message\\\\ServerRequestInterface, mixed given\\.$#', - 'count' => 1, - 'path' => __DIR__ . '/app/Module/IndividualListModule.php', -]; -$ignoreErrors[] = [ - // identifier: method.unresolvableReturnType - 'message' => '#^Return type of call to method Illuminate\\\\Support\\\\Collection\\<\\(int\\|string\\),mixed\\>\\:\\:map\\(\\) contains unresolvable type\\.$#', - 'count' => 1, - 'path' => __DIR__ . '/app/Module/IndividualListModule.php', -]; -$ignoreErrors[] = [ - // identifier: method.unresolvableReturnType - 'message' => '#^Return type of call to method Illuminate\\\\Support\\\\Collection\\<\\(int\\|string\\),object\\{n_surn\\: mixed, n_surname\\: mixed, total\\: int\\}&stdClass\\>\\:\\:all\\(\\) contains unresolvable type\\.$#', - 'count' => 1, - 'path' => __DIR__ . '/app/Module/IndividualListModule.php', -]; -$ignoreErrors[] = [ // identifier: method.nonObject 'message' => '#^Cannot call method xref\\(\\) on Fisharebest\\\\Webtrees\\\\Family\\|null\\.$#', 'count' => 1, diff --git a/tests/app/Census/CensusColumnConditionCanadaMarriedSingleTest.php b/tests/app/Census/CensusColumnConditionCanadaMarriedSingleTest.php index bf09de27a4..691081438b 100644 --- a/tests/app/Census/CensusColumnConditionCanadaMarriedSingleTest.php +++ b/tests/app/Census/CensusColumnConditionCanadaMarriedSingleTest.php @@ -107,7 +107,7 @@ class CensusColumnConditionCanadaMarriedSingleTest extends TestCase $spouse->method('getDeathDate')->willReturn(new Date('1820')); $family = $this->createMock(Family::class); - $family->expects(self::once())->method('getMarriageDate')->willReturn(new Date('')); + $family->expects($this->once())->method('getMarriageDate')->willReturn(new Date('')); $family->expects(self::exactly(2)) ->method('facts') ->with(self::withConsecutive([['MARR'], ['DIV']])) @@ -115,7 +115,7 @@ class CensusColumnConditionCanadaMarriedSingleTest extends TestCase new Collection([$fact]), new Collection() ); - $family->expects(self::once())->method('spouse')->willReturn($spouse); + $family->expects($this->once())->method('spouse')->willReturn($spouse); $individual = $this->createMock(Individual::class); $individual->method('sex')->willReturn('M'); @@ -137,7 +137,7 @@ class CensusColumnConditionCanadaMarriedSingleTest extends TestCase $spouse->method('getDeathDate')->willReturn(new Date('1820')); $family = $this->createMock(Family::class); - $family->expects(self::once())->method('getMarriageDate')->willReturn(new Date('')); + $family->expects($this->once())->method('getMarriageDate')->willReturn(new Date('')); $family ->expects(self::exactly(2)) ->method('facts') @@ -146,7 +146,7 @@ class CensusColumnConditionCanadaMarriedSingleTest extends TestCase new Collection([$fact]), new Collection() ); - $family->expects(self::once())->method('spouse')->willReturn($spouse); + $family->expects($this->once())->method('spouse')->willReturn($spouse); $individual = $this->createMock(Individual::class); $individual->method('sex')->willReturn('F'); @@ -241,7 +241,7 @@ class CensusColumnConditionCanadaMarriedSingleTest extends TestCase $fact = $this->createMock(Fact::class); $family = $this->createMock(Family::class); - $family->expects(self::once())->method('getMarriageDate')->willReturn(new Date('')); + $family->expects($this->once())->method('getMarriageDate')->willReturn(new Date('')); $family ->expects(self::exactly(2)) ->method('facts') @@ -268,7 +268,7 @@ class CensusColumnConditionCanadaMarriedSingleTest extends TestCase $fact = $this->createMock(Fact::class); $family = $this->createMock(Family::class); - $family->expects(self::once())->method('getMarriageDate')->willReturn(new Date('')); + $family->expects($this->once())->method('getMarriageDate')->willReturn(new Date('')); $family ->expects(self::exactly(2)) ->method('facts') @@ -295,7 +295,7 @@ class CensusColumnConditionCanadaMarriedSingleTest extends TestCase $fact = $this->createMock(Fact::class); $family = $this->createMock(Family::class); - $family->expects(self::once())->method('getMarriageDate')->willReturn(new Date('')); + $family->expects($this->once())->method('getMarriageDate')->willReturn(new Date('')); $family ->expects(self::exactly(2)) ->method('facts') @@ -322,7 +322,7 @@ class CensusColumnConditionCanadaMarriedSingleTest extends TestCase $fact = $this->createMock(Fact::class); $family = $this->createMock(Family::class); - $family->expects(self::once())->method('getMarriageDate')->willReturn(new Date('')); + $family->expects($this->once())->method('getMarriageDate')->willReturn(new Date('')); $family ->expects(self::exactly(2)) ->method('facts') diff --git a/tests/app/Census/CensusColumnConditionCanadaMarriedWidowedTest.php b/tests/app/Census/CensusColumnConditionCanadaMarriedWidowedTest.php index 2954d51ad7..fa82a68276 100644 --- a/tests/app/Census/CensusColumnConditionCanadaMarriedWidowedTest.php +++ b/tests/app/Census/CensusColumnConditionCanadaMarriedWidowedTest.php @@ -107,7 +107,7 @@ class CensusColumnConditionCanadaMarriedWidowedTest extends TestCase $spouse->method('getDeathDate')->willReturn(new Date('1820')); $family = $this->createMock(Family::class); - $family->expects(self::once())->method('getMarriageDate')->willReturn(new Date('')); + $family->expects($this->once())->method('getMarriageDate')->willReturn(new Date('')); $family->expects(self::exactly(2)) ->method('facts') ->with(self::withConsecutive([['MARR'], ['DIV']])) @@ -115,7 +115,7 @@ class CensusColumnConditionCanadaMarriedWidowedTest extends TestCase new Collection([$fact]), new Collection() ); - $family->expects(self::once())->method('spouse')->willReturn($spouse); + $family->expects($this->once())->method('spouse')->willReturn($spouse); $individual = $this->createMock(Individual::class); $individual->method('sex')->willReturn('M'); @@ -137,7 +137,7 @@ class CensusColumnConditionCanadaMarriedWidowedTest extends TestCase $spouse->method('getDeathDate')->willReturn(new Date('1820')); $family = $this->createMock(Family::class); - $family->expects(self::once())->method('getMarriageDate')->willReturn(new Date('')); + $family->expects($this->once())->method('getMarriageDate')->willReturn(new Date('')); $family ->expects(self::exactly(2)) ->method('facts') @@ -146,7 +146,7 @@ class CensusColumnConditionCanadaMarriedWidowedTest extends TestCase new Collection([$fact]), new Collection() ); - $family->expects(self::once())->method('spouse')->willReturn($spouse); + $family->expects($this->once())->method('spouse')->willReturn($spouse); $individual = $this->createMock(Individual::class); $individual->method('sex')->willReturn('F'); @@ -241,7 +241,7 @@ class CensusColumnConditionCanadaMarriedWidowedTest extends TestCase $fact = $this->createMock(Fact::class); $family = $this->createMock(Family::class); - $family->expects(self::once())->method('getMarriageDate')->willReturn(new Date('')); + $family->expects($this->once())->method('getMarriageDate')->willReturn(new Date('')); $family ->expects(self::exactly(2)) ->method('facts') @@ -268,7 +268,7 @@ class CensusColumnConditionCanadaMarriedWidowedTest extends TestCase $fact = $this->createMock(Fact::class); $family = $this->createMock(Family::class); - $family->expects(self::once())->method('getMarriageDate')->willReturn(new Date('')); + $family->expects($this->once())->method('getMarriageDate')->willReturn(new Date('')); $family ->expects(self::exactly(2)) ->method('facts') @@ -295,7 +295,7 @@ class CensusColumnConditionCanadaMarriedWidowedTest extends TestCase $fact = $this->createMock(Fact::class); $family = $this->createMock(Family::class); - $family->expects(self::once())->method('getMarriageDate')->willReturn(new Date('')); + $family->expects($this->once())->method('getMarriageDate')->willReturn(new Date('')); $family ->expects(self::exactly(2)) ->method('facts') @@ -322,7 +322,7 @@ class CensusColumnConditionCanadaMarriedWidowedTest extends TestCase $fact = $this->createMock(Fact::class); $family = $this->createMock(Family::class); - $family->expects(self::once())->method('getMarriageDate')->willReturn(new Date('')); + $family->expects($this->once())->method('getMarriageDate')->willReturn(new Date('')); $family ->expects(self::exactly(2)) ->method('facts') diff --git a/tests/app/Census/CensusColumnConditionCanadaTest.php b/tests/app/Census/CensusColumnConditionCanadaTest.php index 74493771f9..f62e67b740 100644 --- a/tests/app/Census/CensusColumnConditionCanadaTest.php +++ b/tests/app/Census/CensusColumnConditionCanadaTest.php @@ -107,7 +107,7 @@ class CensusColumnConditionCanadaTest extends TestCase $spouse->method('getDeathDate')->willReturn(new Date('1820')); $family = $this->createMock(Family::class); - $family->expects(self::once())->method('getMarriageDate')->willReturn(new Date('')); + $family->expects($this->once())->method('getMarriageDate')->willReturn(new Date('')); $family->expects(self::exactly(2)) ->method('facts') ->with(self::withConsecutive([['MARR'], ['DIV']])) @@ -115,7 +115,7 @@ class CensusColumnConditionCanadaTest extends TestCase new Collection([$fact]), new Collection() ); - $family->expects(self::once())->method('spouse')->willReturn($spouse); + $family->expects($this->once())->method('spouse')->willReturn($spouse); $individual = $this->createMock(Individual::class); $individual->method('sex')->willReturn('M'); @@ -137,7 +137,7 @@ class CensusColumnConditionCanadaTest extends TestCase $spouse->method('getDeathDate')->willReturn(new Date('1820')); $family = $this->createMock(Family::class); - $family->expects(self::once())->method('getMarriageDate')->willReturn(new Date('')); + $family->expects($this->once())->method('getMarriageDate')->willReturn(new Date('')); $family ->expects(self::exactly(2)) ->method('facts') @@ -146,7 +146,7 @@ class CensusColumnConditionCanadaTest extends TestCase new Collection([$fact]), new Collection() ); - $family->expects(self::once())->method('spouse')->willReturn($spouse); + $family->expects($this->once())->method('spouse')->willReturn($spouse); $individual = $this->createMock(Individual::class); $individual->method('sex')->willReturn('F'); @@ -241,7 +241,7 @@ class CensusColumnConditionCanadaTest extends TestCase $fact = $this->createMock(Fact::class); $family = $this->createMock(Family::class); - $family->expects(self::once())->method('getMarriageDate')->willReturn(new Date('')); + $family->expects($this->once())->method('getMarriageDate')->willReturn(new Date('')); $family ->expects(self::exactly(2)) ->method('facts') @@ -268,7 +268,7 @@ class CensusColumnConditionCanadaTest extends TestCase $fact = $this->createMock(Fact::class); $family = $this->createMock(Family::class); - $family->expects(self::once())->method('getMarriageDate')->willReturn(new Date('')); + $family->expects($this->once())->method('getMarriageDate')->willReturn(new Date('')); $family ->expects(self::exactly(2)) ->method('facts') @@ -295,7 +295,7 @@ class CensusColumnConditionCanadaTest extends TestCase $fact = $this->createMock(Fact::class); $family = $this->createMock(Family::class); - $family->expects(self::once())->method('getMarriageDate')->willReturn(new Date('')); + $family->expects($this->once())->method('getMarriageDate')->willReturn(new Date('')); $family ->expects(self::exactly(2)) ->method('facts') @@ -322,7 +322,7 @@ class CensusColumnConditionCanadaTest extends TestCase $fact = $this->createMock(Fact::class); $family = $this->createMock(Family::class); - $family->expects(self::once())->method('getMarriageDate')->willReturn(new Date('')); + $family->expects($this->once())->method('getMarriageDate')->willReturn(new Date('')); $family ->expects(self::exactly(2)) ->method('facts') diff --git a/tests/app/Census/CensusColumnConditionCanadaWidowedFemaleTest.php b/tests/app/Census/CensusColumnConditionCanadaWidowedFemaleTest.php index d677025ee6..691a8ef7e4 100644 --- a/tests/app/Census/CensusColumnConditionCanadaWidowedFemaleTest.php +++ b/tests/app/Census/CensusColumnConditionCanadaWidowedFemaleTest.php @@ -107,7 +107,7 @@ class CensusColumnConditionCanadaWidowedFemaleTest extends TestCase $spouse->method('getDeathDate')->willReturn(new Date('1820')); $family = $this->createMock(Family::class); - $family->expects(self::once())->method('getMarriageDate')->willReturn(new Date('')); + $family->expects($this->once())->method('getMarriageDate')->willReturn(new Date('')); $family->expects(self::exactly(2)) ->method('facts') ->with(self::withConsecutive([['MARR'], ['DIV']])) @@ -115,7 +115,7 @@ class CensusColumnConditionCanadaWidowedFemaleTest extends TestCase new Collection([$fact]), new Collection() ); - $family->expects(self::once())->method('spouse')->willReturn($spouse); + $family->expects($this->once())->method('spouse')->willReturn($spouse); $individual = $this->createMock(Individual::class); $individual->method('sex')->willReturn('M'); @@ -137,7 +137,7 @@ class CensusColumnConditionCanadaWidowedFemaleTest extends TestCase $spouse->method('getDeathDate')->willReturn(new Date('1820')); $family = $this->createMock(Family::class); - $family->expects(self::once())->method('getMarriageDate')->willReturn(new Date('')); + $family->expects($this->once())->method('getMarriageDate')->willReturn(new Date('')); $family ->expects(self::exactly(2)) ->method('facts') @@ -146,7 +146,7 @@ class CensusColumnConditionCanadaWidowedFemaleTest extends TestCase new Collection([$fact]), new Collection() ); - $family->expects(self::once())->method('spouse')->willReturn($spouse); + $family->expects($this->once())->method('spouse')->willReturn($spouse); $individual = $this->createMock(Individual::class); $individual->method('sex')->willReturn('F'); @@ -241,7 +241,7 @@ class CensusColumnConditionCanadaWidowedFemaleTest extends TestCase $fact = $this->createMock(Fact::class); $family = $this->createMock(Family::class); - $family->expects(self::once())->method('getMarriageDate')->willReturn(new Date('')); + $family->expects($this->once())->method('getMarriageDate')->willReturn(new Date('')); $family ->expects(self::exactly(2)) ->method('facts') @@ -268,7 +268,7 @@ class CensusColumnConditionCanadaWidowedFemaleTest extends TestCase $fact = $this->createMock(Fact::class); $family = $this->createMock(Family::class); - $family->expects(self::once())->method('getMarriageDate')->willReturn(new Date('')); + $family->expects($this->once())->method('getMarriageDate')->willReturn(new Date('')); $family ->expects(self::exactly(2)) ->method('facts') @@ -295,7 +295,7 @@ class CensusColumnConditionCanadaWidowedFemaleTest extends TestCase $fact = $this->createMock(Fact::class); $family = $this->createMock(Family::class); - $family->expects(self::once())->method('getMarriageDate')->willReturn(new Date('')); + $family->expects($this->once())->method('getMarriageDate')->willReturn(new Date('')); $family ->expects(self::exactly(2)) ->method('facts') @@ -322,7 +322,7 @@ class CensusColumnConditionCanadaWidowedFemaleTest extends TestCase $fact = $this->createMock(Fact::class); $family = $this->createMock(Family::class); - $family->expects(self::once())->method('getMarriageDate')->willReturn(new Date('')); + $family->expects($this->once())->method('getMarriageDate')->willReturn(new Date('')); $family ->expects(self::exactly(2)) ->method('facts') diff --git a/tests/app/Census/CensusColumnConditionCanadaWidowedMaleTest.php b/tests/app/Census/CensusColumnConditionCanadaWidowedMaleTest.php index 6653b0726d..8a0b330447 100644 --- a/tests/app/Census/CensusColumnConditionCanadaWidowedMaleTest.php +++ b/tests/app/Census/CensusColumnConditionCanadaWidowedMaleTest.php @@ -107,7 +107,7 @@ class CensusColumnConditionCanadaWidowedMaleTest extends TestCase $spouse->method('getDeathDate')->willReturn(new Date('1820')); $family = $this->createMock(Family::class); - $family->expects(self::once())->method('getMarriageDate')->willReturn(new Date('')); + $family->expects($this->once())->method('getMarriageDate')->willReturn(new Date('')); $family->expects(self::exactly(2)) ->method('facts') ->with(self::withConsecutive([['MARR'], ['DIV']])) @@ -115,7 +115,7 @@ class CensusColumnConditionCanadaWidowedMaleTest extends TestCase new Collection([$fact]), new Collection() ); - $family->expects(self::once())->method('spouse')->willReturn($spouse); + $family->expects($this->once())->method('spouse')->willReturn($spouse); $individual = $this->createMock(Individual::class); $individual->method('sex')->willReturn('M'); @@ -137,7 +137,7 @@ class CensusColumnConditionCanadaWidowedMaleTest extends TestCase $spouse->method('getDeathDate')->willReturn(new Date('1820')); $family = $this->createMock(Family::class); - $family->expects(self::once())->method('getMarriageDate')->willReturn(new Date('')); + $family->expects($this->once())->method('getMarriageDate')->willReturn(new Date('')); $family ->expects(self::exactly(2)) ->method('facts') @@ -146,7 +146,7 @@ class CensusColumnConditionCanadaWidowedMaleTest extends TestCase new Collection([$fact]), new Collection() ); - $family->expects(self::once())->method('spouse')->willReturn($spouse); + $family->expects($this->once())->method('spouse')->willReturn($spouse); $individual = $this->createMock(Individual::class); $individual->method('sex')->willReturn('F'); @@ -241,7 +241,7 @@ class CensusColumnConditionCanadaWidowedMaleTest extends TestCase $fact = $this->createMock(Fact::class); $family = $this->createMock(Family::class); - $family->expects(self::once())->method('getMarriageDate')->willReturn(new Date('')); + $family->expects($this->once())->method('getMarriageDate')->willReturn(new Date('')); $family ->expects(self::exactly(2)) ->method('facts') @@ -268,7 +268,7 @@ class CensusColumnConditionCanadaWidowedMaleTest extends TestCase $fact = $this->createMock(Fact::class); $family = $this->createMock(Family::class); - $family->expects(self::once())->method('getMarriageDate')->willReturn(new Date('')); + $family->expects($this->once())->method('getMarriageDate')->willReturn(new Date('')); $family ->expects(self::exactly(2)) ->method('facts') @@ -295,7 +295,7 @@ class CensusColumnConditionCanadaWidowedMaleTest extends TestCase $fact = $this->createMock(Fact::class); $family = $this->createMock(Family::class); - $family->expects(self::once())->method('getMarriageDate')->willReturn(new Date('')); + $family->expects($this->once())->method('getMarriageDate')->willReturn(new Date('')); $family ->expects(self::exactly(2)) ->method('facts') @@ -322,7 +322,7 @@ class CensusColumnConditionCanadaWidowedMaleTest extends TestCase $fact = $this->createMock(Fact::class); $family = $this->createMock(Family::class); - $family->expects(self::once())->method('getMarriageDate')->willReturn(new Date('')); + $family->expects($this->once())->method('getMarriageDate')->willReturn(new Date('')); $family ->expects(self::exactly(2)) ->method('facts') diff --git a/tests/app/Census/CensusColumnConditionCanadaWidowedTest.php b/tests/app/Census/CensusColumnConditionCanadaWidowedTest.php index d762c51174..08e0c5fdd2 100644 --- a/tests/app/Census/CensusColumnConditionCanadaWidowedTest.php +++ b/tests/app/Census/CensusColumnConditionCanadaWidowedTest.php @@ -107,7 +107,7 @@ class CensusColumnConditionCanadaWidowedTest extends TestCase $spouse->method('getDeathDate')->willReturn(new Date('1820')); $family = $this->createMock(Family::class); - $family->expects(self::once())->method('getMarriageDate')->willReturn(new Date('')); + $family->expects($this->once())->method('getMarriageDate')->willReturn(new Date('')); $family->expects(self::exactly(2)) ->method('facts') ->with(self::withConsecutive([['MARR'], ['DIV']])) @@ -115,7 +115,7 @@ class CensusColumnConditionCanadaWidowedTest extends TestCase new Collection([$fact]), new Collection() ); - $family->expects(self::once())->method('spouse')->willReturn($spouse); + $family->expects($this->once())->method('spouse')->willReturn($spouse); $individual = $this->createMock(Individual::class); $individual->method('sex')->willReturn('M'); @@ -137,7 +137,7 @@ class CensusColumnConditionCanadaWidowedTest extends TestCase $spouse->method('getDeathDate')->willReturn(new Date('1820')); $family = $this->createMock(Family::class); - $family->expects(self::once())->method('getMarriageDate')->willReturn(new Date('')); + $family->expects($this->once())->method('getMarriageDate')->willReturn(new Date('')); $family ->expects(self::exactly(2)) ->method('facts') @@ -146,7 +146,7 @@ class CensusColumnConditionCanadaWidowedTest extends TestCase new Collection([$fact]), new Collection() ); - $family->expects(self::once())->method('spouse')->willReturn($spouse); + $family->expects($this->once())->method('spouse')->willReturn($spouse); $individual = $this->createMock(Individual::class); $individual->method('sex')->willReturn('F'); @@ -241,7 +241,7 @@ class CensusColumnConditionCanadaWidowedTest extends TestCase $fact = $this->createMock(Fact::class); $family = $this->createMock(Family::class); - $family->expects(self::once())->method('getMarriageDate')->willReturn(new Date('')); + $family->expects($this->once())->method('getMarriageDate')->willReturn(new Date('')); $family ->expects(self::exactly(2)) ->method('facts') @@ -268,7 +268,7 @@ class CensusColumnConditionCanadaWidowedTest extends TestCase $fact = $this->createMock(Fact::class); $family = $this->createMock(Family::class); - $family->expects(self::once())->method('getMarriageDate')->willReturn(new Date('')); + $family->expects($this->once())->method('getMarriageDate')->willReturn(new Date('')); $family ->expects(self::exactly(2)) ->method('facts') @@ -295,7 +295,7 @@ class CensusColumnConditionCanadaWidowedTest extends TestCase $fact = $this->createMock(Fact::class); $family = $this->createMock(Family::class); - $family->expects(self::once())->method('getMarriageDate')->willReturn(new Date('')); + $family->expects($this->once())->method('getMarriageDate')->willReturn(new Date('')); $family ->expects(self::exactly(2)) ->method('facts') @@ -322,7 +322,7 @@ class CensusColumnConditionCanadaWidowedTest extends TestCase $fact = $this->createMock(Fact::class); $family = $this->createMock(Family::class); - $family->expects(self::once())->method('getMarriageDate')->willReturn(new Date('')); + $family->expects($this->once())->method('getMarriageDate')->willReturn(new Date('')); $family ->expects(self::exactly(2)) ->method('facts') diff --git a/tests/app/Census/CensusColumnConditionDanishTest.php b/tests/app/Census/CensusColumnConditionDanishTest.php index 4473486056..c21077e4cd 100644 --- a/tests/app/Census/CensusColumnConditionDanishTest.php +++ b/tests/app/Census/CensusColumnConditionDanishTest.php @@ -115,7 +115,7 @@ class CensusColumnConditionDanishTest extends TestCase new Collection([$fact]), new Collection() ); - $family->expects(self::once())->method('spouse')->willReturn($spouse); + $family->expects($this->once())->method('spouse')->willReturn($spouse); $individual = $this->createMock(Individual::class); $individual->method('sex')->willReturn('M'); @@ -145,7 +145,7 @@ class CensusColumnConditionDanishTest extends TestCase new Collection([$fact]), new Collection() ); - $family->expects(self::once())->method('spouse')->willReturn($spouse); + $family->expects($this->once())->method('spouse')->willReturn($spouse); $individual = $this->createMock(Individual::class); $individual->method('sex')->willReturn('F'); diff --git a/tests/app/Census/CensusColumnConditionEnglishTest.php b/tests/app/Census/CensusColumnConditionEnglishTest.php index 1eec84135d..c73516ba8a 100644 --- a/tests/app/Census/CensusColumnConditionEnglishTest.php +++ b/tests/app/Census/CensusColumnConditionEnglishTest.php @@ -115,7 +115,7 @@ class CensusColumnConditionEnglishTest extends TestCase new Collection([$fact]), new Collection() ); - $family->expects(self::once())->method('spouse')->willReturn($spouse); + $family->expects($this->once())->method('spouse')->willReturn($spouse); $individual = $this->createMock(Individual::class); $individual->method('sex')->willReturn('M'); @@ -145,7 +145,7 @@ class CensusColumnConditionEnglishTest extends TestCase new Collection([$fact]), new Collection() ); - $family->expects(self::once())->method('spouse')->willReturn($spouse); + $family->expects($this->once())->method('spouse')->willReturn($spouse); $individual = $this->createMock(Individual::class); $individual->method('sex')->willReturn('F'); diff --git a/tests/app/Census/CensusColumnConditionFrenchFemmeTest.php b/tests/app/Census/CensusColumnConditionFrenchFemmeTest.php index 95809b546e..66742dc911 100644 --- a/tests/app/Census/CensusColumnConditionFrenchFemmeTest.php +++ b/tests/app/Census/CensusColumnConditionFrenchFemmeTest.php @@ -115,7 +115,7 @@ class CensusColumnConditionFrenchFemmeTest extends TestCase new Collection([$fact]), new Collection() ); - $family->expects(self::once())->method('spouse')->willReturn($spouse); + $family->expects($this->once())->method('spouse')->willReturn($spouse); $individual = $this->createMock(Individual::class); $individual->method('sex')->willReturn('M'); @@ -145,7 +145,7 @@ class CensusColumnConditionFrenchFemmeTest extends TestCase new Collection([$fact]), new Collection() ); - $family->expects(self::once())->method('spouse')->willReturn($spouse); + $family->expects($this->once())->method('spouse')->willReturn($spouse); $individual = $this->createMock(Individual::class); $individual->method('sex')->willReturn('F'); diff --git a/tests/app/Census/CensusColumnConditionFrenchFilleTest.php b/tests/app/Census/CensusColumnConditionFrenchFilleTest.php index c7a2b1c025..f8ac0cee75 100644 --- a/tests/app/Census/CensusColumnConditionFrenchFilleTest.php +++ b/tests/app/Census/CensusColumnConditionFrenchFilleTest.php @@ -115,7 +115,7 @@ class CensusColumnConditionFrenchFilleTest extends TestCase new Collection([$fact]), new Collection() ); - $family->expects(self::once())->method('spouse')->willReturn($spouse); + $family->expects($this->once())->method('spouse')->willReturn($spouse); $individual = $this->createMock(Individual::class); $individual->method('sex')->willReturn('M'); @@ -145,7 +145,7 @@ class CensusColumnConditionFrenchFilleTest extends TestCase new Collection([$fact]), new Collection() ); - $family->expects(self::once())->method('spouse')->willReturn($spouse); + $family->expects($this->once())->method('spouse')->willReturn($spouse); $individual = $this->createMock(Individual::class); $individual->method('sex')->willReturn('F'); diff --git a/tests/app/Census/CensusColumnConditionFrenchGarconTest.php b/tests/app/Census/CensusColumnConditionFrenchGarconTest.php index 2509ec3fc1..80d40e8b5d 100644 --- a/tests/app/Census/CensusColumnConditionFrenchGarconTest.php +++ b/tests/app/Census/CensusColumnConditionFrenchGarconTest.php @@ -115,7 +115,7 @@ class CensusColumnConditionFrenchGarconTest extends TestCase new Collection([$fact]), new Collection() ); - $family->expects(self::once())->method('spouse')->willReturn($spouse); + $family->expects($this->once())->method('spouse')->willReturn($spouse); $individual = $this->createMock(Individual::class); $individual->method('sex')->willReturn('M'); @@ -145,7 +145,7 @@ class CensusColumnConditionFrenchGarconTest extends TestCase new Collection([$fact]), new Collection() ); - $family->expects(self::once())->method('spouse')->willReturn($spouse); + $family->expects($this->once())->method('spouse')->willReturn($spouse); $individual = $this->createMock(Individual::class); $individual->method('sex')->willReturn('F'); diff --git a/tests/app/Census/CensusColumnConditionFrenchHommeTest.php b/tests/app/Census/CensusColumnConditionFrenchHommeTest.php index 3b625b90d3..4e31bd3f49 100644 --- a/tests/app/Census/CensusColumnConditionFrenchHommeTest.php +++ b/tests/app/Census/CensusColumnConditionFrenchHommeTest.php @@ -115,7 +115,7 @@ class CensusColumnConditionFrenchHommeTest extends TestCase new Collection([$fact]), new Collection() ); - $family->expects(self::once())->method('spouse')->willReturn($spouse); + $family->expects($this->once())->method('spouse')->willReturn($spouse); $individual = $this->createMock(Individual::class); $individual->method('sex')->willReturn('M'); @@ -145,7 +145,7 @@ class CensusColumnConditionFrenchHommeTest extends TestCase new Collection([$fact]), new Collection() ); - $family->expects(self::once())->method('spouse')->willReturn($spouse); + $family->expects($this->once())->method('spouse')->willReturn($spouse); $individual = $this->createMock(Individual::class); $individual->method('sex')->willReturn('F'); diff --git a/tests/app/Census/CensusColumnConditionFrenchVeufTest.php b/tests/app/Census/CensusColumnConditionFrenchVeufTest.php index 7cc3f8aa5d..c017102409 100644 --- a/tests/app/Census/CensusColumnConditionFrenchVeufTest.php +++ b/tests/app/Census/CensusColumnConditionFrenchVeufTest.php @@ -115,7 +115,7 @@ class CensusColumnConditionFrenchVeufTest extends TestCase new Collection([$fact]), new Collection() ); - $family->expects(self::once())->method('spouse')->willReturn($spouse); + $family->expects($this->once())->method('spouse')->willReturn($spouse); $individual = $this->createMock(Individual::class); $individual->method('sex')->willReturn('M'); @@ -145,7 +145,7 @@ class CensusColumnConditionFrenchVeufTest extends TestCase new Collection([$fact]), new Collection() ); - $family->expects(self::once())->method('spouse')->willReturn($spouse); + $family->expects($this->once())->method('spouse')->willReturn($spouse); $individual = $this->createMock(Individual::class); $individual->method('sex')->willReturn('F'); diff --git a/tests/app/Census/CensusColumnConditionFrenchVeuveTest.php b/tests/app/Census/CensusColumnConditionFrenchVeuveTest.php index 414fb1788a..6c061acdd0 100644 --- a/tests/app/Census/CensusColumnConditionFrenchVeuveTest.php +++ b/tests/app/Census/CensusColumnConditionFrenchVeuveTest.php @@ -107,7 +107,7 @@ class CensusColumnConditionFrenchVeuveTest extends TestCase $spouse->method('getDeathDate')->willReturn(new Date('1820')); $family = $this->createMock(Family::class); - $family->expects(self::once())->method('getMarriageDate')->willReturn(new Date('')); + $family->expects($this->once())->method('getMarriageDate')->willReturn(new Date('')); $family ->expects(self::exactly(2)) ->method('facts') @@ -116,7 +116,7 @@ class CensusColumnConditionFrenchVeuveTest extends TestCase new Collection([$fact]), new Collection() ); - $family->expects(self::once())->method('spouse')->willReturn($spouse); + $family->expects($this->once())->method('spouse')->willReturn($spouse); $individual = $this->createMock(Individual::class); $individual->method('sex')->willReturn('M'); @@ -138,7 +138,7 @@ class CensusColumnConditionFrenchVeuveTest extends TestCase $spouse->method('getDeathDate')->willReturn(new Date('1820')); $family = $this->createMock(Family::class); - $family->expects(self::once())->method('getMarriageDate')->willReturn(new Date('')); + $family->expects($this->once())->method('getMarriageDate')->willReturn(new Date('')); $family ->expects(self::exactly(2)) ->method('facts') @@ -147,7 +147,7 @@ class CensusColumnConditionFrenchVeuveTest extends TestCase new Collection([$fact]), new Collection() ); - $family->expects(self::once())->method('spouse')->willReturn($spouse); + $family->expects($this->once())->method('spouse')->willReturn($spouse); $individual = $this->createMock(Individual::class); $individual->method('sex')->willReturn('F'); @@ -242,7 +242,7 @@ class CensusColumnConditionFrenchVeuveTest extends TestCase $fact = $this->createMock(Fact::class); $family = $this->createMock(Family::class); - $family->expects(self::once())->method('getMarriageDate')->willReturn(new Date('')); + $family->expects($this->once())->method('getMarriageDate')->willReturn(new Date('')); $family ->expects(self::exactly(2)) ->method('facts') @@ -269,7 +269,7 @@ class CensusColumnConditionFrenchVeuveTest extends TestCase $fact = $this->createMock(Fact::class); $family = $this->createMock(Family::class); - $family->expects(self::once())->method('getMarriageDate')->willReturn(new Date('')); + $family->expects($this->once())->method('getMarriageDate')->willReturn(new Date('')); $family ->expects(self::exactly(2)) ->method('facts') diff --git a/tests/app/Census/CensusColumnConditionUsTest.php b/tests/app/Census/CensusColumnConditionUsTest.php index 8ae13447f9..fa4dc25285 100644 --- a/tests/app/Census/CensusColumnConditionUsTest.php +++ b/tests/app/Census/CensusColumnConditionUsTest.php @@ -107,7 +107,7 @@ class CensusColumnConditionUsTest extends TestCase $spouse->method('getDeathDate')->willReturn(new Date('1820')); $family = $this->createMock(Family::class); - $family->expects(self::once())->method('getMarriageDate')->willReturn(new Date('')); + $family->expects($this->once())->method('getMarriageDate')->willReturn(new Date('')); $family->expects(self::exactly(2)) ->method('facts') ->with(self::withConsecutive([['MARR'], ['DIV']])) @@ -115,7 +115,7 @@ class CensusColumnConditionUsTest extends TestCase new Collection([$fact]), new Collection() ); - $family->expects(self::once())->method('spouse')->willReturn($spouse); + $family->expects($this->once())->method('spouse')->willReturn($spouse); $individual = $this->createMock(Individual::class); $individual->method('sex')->willReturn('M'); @@ -137,7 +137,7 @@ class CensusColumnConditionUsTest extends TestCase $spouse->method('getDeathDate')->willReturn(new Date('1820')); $family = $this->createMock(Family::class); - $family->expects(self::once())->method('getMarriageDate')->willReturn(new Date('')); + $family->expects($this->once())->method('getMarriageDate')->willReturn(new Date('')); $family ->expects(self::exactly(2)) ->method('facts') @@ -146,7 +146,7 @@ class CensusColumnConditionUsTest extends TestCase new Collection([$fact]), new Collection() ); - $family->expects(self::once())->method('spouse')->willReturn($spouse); + $family->expects($this->once())->method('spouse')->willReturn($spouse); $individual = $this->createMock(Individual::class); $individual->method('sex')->willReturn('F'); @@ -241,7 +241,7 @@ class CensusColumnConditionUsTest extends TestCase $fact = $this->createMock(Fact::class); $family = $this->createMock(Family::class); - $family->expects(self::once())->method('getMarriageDate')->willReturn(new Date('')); + $family->expects($this->once())->method('getMarriageDate')->willReturn(new Date('')); $family ->expects(self::exactly(2)) ->method('facts') @@ -268,7 +268,7 @@ class CensusColumnConditionUsTest extends TestCase $fact = $this->createMock(Fact::class); $family = $this->createMock(Family::class); - $family->expects(self::once())->method('getMarriageDate')->willReturn(new Date('')); + $family->expects($this->once())->method('getMarriageDate')->willReturn(new Date('')); $family ->expects(self::exactly(2)) ->method('facts') @@ -295,7 +295,7 @@ class CensusColumnConditionUsTest extends TestCase $fact = $this->createMock(Fact::class); $family = $this->createMock(Family::class); - $family->expects(self::once())->method('getMarriageDate')->willReturn(new Date('')); + $family->expects($this->once())->method('getMarriageDate')->willReturn(new Date('')); $family ->expects(self::exactly(2)) ->method('facts') @@ -322,7 +322,7 @@ class CensusColumnConditionUsTest extends TestCase $fact = $this->createMock(Fact::class); $family = $this->createMock(Family::class); - $family->expects(self::once())->method('getMarriageDate')->willReturn(new Date('')); + $family->expects($this->once())->method('getMarriageDate')->willReturn(new Date('')); $family ->expects(self::exactly(2)) ->method('facts') diff --git a/tests/app/Elements/XrefFamilyTest.php b/tests/app/Elements/XrefFamilyTest.php index 172d3bd202..80486adf18 100644 --- a/tests/app/Elements/XrefFamilyTest.php +++ b/tests/app/Elements/XrefFamilyTest.php @@ -41,7 +41,7 @@ class XrefFamilyTest extends TestCase $factory = $this->createMock(FamilyFactory::class); - $factory->expects(self::once()) + $factory->expects($this->once()) ->method('make') ->willReturn(null); @@ -75,11 +75,11 @@ class XrefFamilyTest extends TestCase $record = $this->createMock(Family::class); - $record->expects(self::once()) + $record->expects($this->once()) ->method('fullName') ->willReturn('Full Name'); - $record->expects(self::once()) + $record->expects($this->once()) ->method('url') ->willReturn('https://url'); @@ -87,7 +87,7 @@ class XrefFamilyTest extends TestCase $factory = $this->createMock(FamilyFactory::class); - $factory->expects(self::once()) + $factory->expects($this->once()) ->method('make') ->willReturn($record); @@ -113,7 +113,7 @@ class XrefFamilyTest extends TestCase $factory = $this->createMock(FamilyFactory::class); - $factory->expects(self::once()) + $factory->expects($this->once()) ->method('make') ->willReturn(null); diff --git a/tests/app/Elements/XrefIndividualTest.php b/tests/app/Elements/XrefIndividualTest.php index 2d55ea8243..96e2f26eba 100644 --- a/tests/app/Elements/XrefIndividualTest.php +++ b/tests/app/Elements/XrefIndividualTest.php @@ -41,7 +41,7 @@ class XrefIndividualTest extends TestCase $factory = $this->createMock(IndividualFactory::class); - $factory->expects(self::once()) + $factory->expects($this->once()) ->method('make') ->willReturn(null); @@ -75,11 +75,11 @@ class XrefIndividualTest extends TestCase $record = $this->createMock(Individual::class); - $record->expects(self::once()) + $record->expects($this->once()) ->method('fullName') ->willReturn('Full Name'); - $record->expects(self::once()) + $record->expects($this->once()) ->method('url') ->willReturn('https://url'); @@ -87,7 +87,7 @@ class XrefIndividualTest extends TestCase $factory = $this->createMock(IndividualFactory::class); - $factory->expects(self::once()) + $factory->expects($this->once()) ->method('make') ->willReturn($record); @@ -113,7 +113,7 @@ class XrefIndividualTest extends TestCase $factory = $this->createMock(IndividualFactory::class); - $factory->expects(self::once()) + $factory->expects($this->once()) ->method('make') ->willReturn(null); diff --git a/tests/app/Elements/XrefLocationTest.php b/tests/app/Elements/XrefLocationTest.php index ba4df12b5f..2d351a774b 100644 --- a/tests/app/Elements/XrefLocationTest.php +++ b/tests/app/Elements/XrefLocationTest.php @@ -41,7 +41,7 @@ class XrefLocationTest extends TestCase $factory = $this->createMock(LocationFactory::class); - $factory->expects(self::once()) + $factory->expects($this->once()) ->method('make') ->willReturn(null); @@ -75,11 +75,11 @@ class XrefLocationTest extends TestCase $record = $this->createMock(Location::class); - $record->expects(self::once()) + $record->expects($this->once()) ->method('fullName') ->willReturn('Full Name'); - $record->expects(self::once()) + $record->expects($this->once()) ->method('url') ->willReturn('https://url'); @@ -87,7 +87,7 @@ class XrefLocationTest extends TestCase $factory = $this->createMock(LocationFactory::class); - $factory->expects(self::once()) + $factory->expects($this->once()) ->method('make') ->willReturn($record); @@ -113,7 +113,7 @@ class XrefLocationTest extends TestCase $factory = $this->createMock(LocationFactory::class); - $factory->expects(self::once()) + $factory->expects($this->once()) ->method('make') ->willReturn(null); diff --git a/tests/app/Elements/XrefMediaTest.php b/tests/app/Elements/XrefMediaTest.php index 49c0eb9f60..0c424d34db 100644 --- a/tests/app/Elements/XrefMediaTest.php +++ b/tests/app/Elements/XrefMediaTest.php @@ -41,7 +41,7 @@ class XrefMediaTest extends TestCase $factory = $this->createMock(MediaFactory::class); - $factory->expects(self::once()) + $factory->expects($this->once()) ->method('make') ->willReturn(null); @@ -74,11 +74,11 @@ class XrefMediaTest extends TestCase $record = $this->createMock(Media::class); - $record->expects(self::once()) + $record->expects($this->once()) ->method('fullName') ->willReturn('Full Name'); - $record->expects(self::once()) + $record->expects($this->once()) ->method('url') ->willReturn('https://url'); @@ -86,7 +86,7 @@ class XrefMediaTest extends TestCase $factory = $this->createMock(MediaFactory::class); - $factory->expects(self::once()) + $factory->expects($this->once()) ->method('make') ->willReturn($record); @@ -112,7 +112,7 @@ class XrefMediaTest extends TestCase $factory = $this->createMock(MediaFactory::class); - $factory->expects(self::once()) + $factory->expects($this->once()) ->method('make') ->willReturn(null); diff --git a/tests/app/Elements/XrefNoteTest.php b/tests/app/Elements/XrefNoteTest.php index 13b1407255..15d0aadb95 100644 --- a/tests/app/Elements/XrefNoteTest.php +++ b/tests/app/Elements/XrefNoteTest.php @@ -40,7 +40,7 @@ class XrefNoteTest extends TestCase $factory = $this->createMock(NoteFactory::class); - $factory->expects(self::once()) + $factory->expects($this->once()) ->method('make') ->willReturn(null); @@ -69,11 +69,11 @@ class XrefNoteTest extends TestCase $record = $this->createMock(Note::class); - $record->expects(self::once()) + $record->expects($this->once()) ->method('fullName') ->willReturn('Full Name'); - $record->expects(self::once()) + $record->expects($this->once()) ->method('url') ->willReturn('https://url'); @@ -81,7 +81,7 @@ class XrefNoteTest extends TestCase $factory = $this->createMock(NoteFactory::class); - $factory->expects(self::once()) + $factory->expects($this->once()) ->method('make') ->willReturn($record); @@ -107,7 +107,7 @@ class XrefNoteTest extends TestCase $factory = $this->createMock(NoteFactory::class); - $factory->expects(self::once()) + $factory->expects($this->once()) ->method('make') ->willReturn(null); diff --git a/tests/app/Elements/XrefRepositoryTest.php b/tests/app/Elements/XrefRepositoryTest.php index e4c5ce4ccb..36469aaea3 100644 --- a/tests/app/Elements/XrefRepositoryTest.php +++ b/tests/app/Elements/XrefRepositoryTest.php @@ -41,7 +41,7 @@ class XrefRepositoryTest extends TestCase $factory = $this->createMock(RepositoryFactory::class); - $factory->expects(self::once()) + $factory->expects($this->once()) ->method('make') ->willReturn(null); @@ -74,11 +74,11 @@ class XrefRepositoryTest extends TestCase $record = $this->createMock(Repository::class); - $record->expects(self::once()) + $record->expects($this->once()) ->method('fullName') ->willReturn('Full Name'); - $record->expects(self::once()) + $record->expects($this->once()) ->method('url') ->willReturn('https://url'); @@ -86,7 +86,7 @@ class XrefRepositoryTest extends TestCase $factory = $this->createMock(RepositoryFactory::class); - $factory->expects(self::once()) + $factory->expects($this->once()) ->method('make') ->willReturn($record); @@ -112,7 +112,7 @@ class XrefRepositoryTest extends TestCase $factory = $this->createMock(RepositoryFactory::class); - $factory->expects(self::once()) + $factory->expects($this->once()) ->method('make') ->willReturn(null); diff --git a/tests/app/Elements/XrefSharedNoteTest.php b/tests/app/Elements/XrefSharedNoteTest.php index 336822293a..ab83ed16e0 100644 --- a/tests/app/Elements/XrefSharedNoteTest.php +++ b/tests/app/Elements/XrefSharedNoteTest.php @@ -40,7 +40,7 @@ class XrefSharedNoteTest extends TestCase $factory = $this->createMock(SharedNoteFactory::class); - $factory->expects(self::once()) + $factory->expects($this->once()) ->method('make') ->willReturn(null); @@ -69,11 +69,11 @@ class XrefSharedNoteTest extends TestCase $record = $this->createMock(SharedNote::class); - $record->expects(self::once()) + $record->expects($this->once()) ->method('fullName') ->willReturn('Full Name'); - $record->expects(self::once()) + $record->expects($this->once()) ->method('url') ->willReturn('https://url'); @@ -81,7 +81,7 @@ class XrefSharedNoteTest extends TestCase $factory = $this->createMock(SharedNoteFactory::class); - $factory->expects(self::once()) + $factory->expects($this->once()) ->method('make') ->willReturn($record); @@ -107,7 +107,7 @@ class XrefSharedNoteTest extends TestCase $factory = $this->createMock(SharedNoteFactory::class); - $factory->expects(self::once()) + $factory->expects($this->once()) ->method('make') ->willReturn(null); diff --git a/tests/app/Elements/XrefSourceTest.php b/tests/app/Elements/XrefSourceTest.php index 8bb4b04144..794a9b4c7a 100644 --- a/tests/app/Elements/XrefSourceTest.php +++ b/tests/app/Elements/XrefSourceTest.php @@ -43,7 +43,7 @@ class XrefSourceTest extends TestCase $factory = $this->createMock(SourceFactory::class); - $factory->expects(self::once()) + $factory->expects($this->once()) ->method('make') ->willReturn(null); @@ -95,11 +95,11 @@ class XrefSourceTest extends TestCase $record = $this->createMock(Source::class); - $record->expects(self::once()) + $record->expects($this->once()) ->method('fullName') ->willReturn('Full Name'); - $record->expects(self::once()) + $record->expects($this->once()) ->method('url') ->willReturn('https://url'); @@ -107,7 +107,7 @@ class XrefSourceTest extends TestCase $factory = $this->createMock(SourceFactory::class); - $factory->expects(self::once()) + $factory->expects($this->once()) ->method('make') ->willReturn($record); @@ -142,7 +142,7 @@ class XrefSourceTest extends TestCase $factory = $this->createMock(SourceFactory::class); - $factory->expects(self::once()) + $factory->expects($this->once()) ->method('make') ->willReturn(null); diff --git a/tests/app/Elements/XrefSubmissionTest.php b/tests/app/Elements/XrefSubmissionTest.php index e642c4c800..d81b3199dd 100644 --- a/tests/app/Elements/XrefSubmissionTest.php +++ b/tests/app/Elements/XrefSubmissionTest.php @@ -41,7 +41,7 @@ class XrefSubmissionTest extends TestCase $factory = $this->createMock(SubmissionFactory::class); - $factory->expects(self::once()) + $factory->expects($this->once()) ->method('make') ->willReturn(null); @@ -74,11 +74,11 @@ class XrefSubmissionTest extends TestCase $record = $this->createMock(Submission::class); - $record->expects(self::once()) + $record->expects($this->once()) ->method('fullName') ->willReturn('Full Name'); - $record->expects(self::once()) + $record->expects($this->once()) ->method('url') ->willReturn('https://url'); @@ -86,7 +86,7 @@ class XrefSubmissionTest extends TestCase $factory = $this->createMock(SubmissionFactory::class); - $factory->expects(self::once()) + $factory->expects($this->once()) ->method('make') ->willReturn($record); @@ -112,7 +112,7 @@ class XrefSubmissionTest extends TestCase $factory = $this->createMock(SubmissionFactory::class); - $factory->expects(self::once()) + $factory->expects($this->once()) ->method('make') ->willReturn(null); diff --git a/tests/app/Elements/XrefSubmitterTest.php b/tests/app/Elements/XrefSubmitterTest.php index 7ac2cdb776..097740652b 100644 --- a/tests/app/Elements/XrefSubmitterTest.php +++ b/tests/app/Elements/XrefSubmitterTest.php @@ -41,7 +41,7 @@ class XrefSubmitterTest extends TestCase $factory = $this->createMock(SubmitterFactory::class); - $factory->expects(self::once()) + $factory->expects($this->once()) ->method('make') ->willReturn(null); @@ -74,11 +74,11 @@ class XrefSubmitterTest extends TestCase $record = $this->createMock(Submitter::class); - $record->expects(self::once()) + $record->expects($this->once()) ->method('fullName') ->willReturn('Full Name'); - $record->expects(self::once()) + $record->expects($this->once()) ->method('url') ->willReturn('https://url'); @@ -86,7 +86,7 @@ class XrefSubmitterTest extends TestCase $factory = $this->createMock(SubmitterFactory::class); - $factory->expects(self::once()) + $factory->expects($this->once()) ->method('make') ->willReturn($record); @@ -112,7 +112,7 @@ class XrefSubmitterTest extends TestCase $factory = $this->createMock(SubmitterFactory::class); - $factory->expects(self::once()) + $factory->expects($this->once()) ->method('make') ->willReturn(null); diff --git a/tests/app/Http/Middleware/BootModulesTest.php b/tests/app/Http/Middleware/BootModulesTest.php index 290927be61..89b4d55b87 100644 --- a/tests/app/Http/Middleware/BootModulesTest.php +++ b/tests/app/Http/Middleware/BootModulesTest.php @@ -40,7 +40,7 @@ class BootModulesTest extends TestCase $module_service = $this->createMock(ModuleService::class); $module_service - ->expects(self::once()) + ->expects($this->once()) ->method('bootModules') ->with($theme); diff --git a/tests/app/Http/RequestHandlers/AccountUpdateTest.php b/tests/app/Http/RequestHandlers/AccountUpdateTest.php index 785f6e9d6f..dc5d65b21c 100644 --- a/tests/app/Http/RequestHandlers/AccountUpdateTest.php +++ b/tests/app/Http/RequestHandlers/AccountUpdateTest.php @@ -35,10 +35,10 @@ class AccountUpdateTest extends TestCase $user_service = $this->createMock(UserService::class); $user = $this->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($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(self::exactly(4)) ->method('setPreference') ->with( @@ -47,7 +47,7 @@ class AccountUpdateTest extends TestCase ); $tree = $this->createMock(Tree::class); - $tree->expects(self::once())->method('setUserPreference')->with($user, UserInterface::PREF_TREE_DEFAULT_XREF, 'f'); + $tree->expects($this->once())->method('setUserPreference')->with($user, UserInterface::PREF_TREE_DEFAULT_XREF, 'f'); $handler = new AccountUpdate($user_service); $request = self::createRequest() diff --git a/tests/app/Http/RequestHandlers/DeleteUserTest.php b/tests/app/Http/RequestHandlers/DeleteUserTest.php index da79a6798b..a1f9d1ce95 100644 --- a/tests/app/Http/RequestHandlers/DeleteUserTest.php +++ b/tests/app/Http/RequestHandlers/DeleteUserTest.php @@ -39,7 +39,7 @@ class DeleteUserTest extends TestCase $user->method('id')->willReturn(1); $user_service = $this->createMock(UserService::class); - $user_service->expects(self::once())->method('find')->willReturn($user); + $user_service->expects($this->once())->method('find')->willReturn($user); $request = self::createRequest() ->withAttribute('user_id', $user->id()); @@ -55,7 +55,7 @@ class DeleteUserTest extends TestCase $this->expectExceptionMessage('User ID 98765 not found'); $user_service = $this->createMock(UserService::class); - $user_service->expects(self::once())->method('find')->willReturn(null); + $user_service->expects($this->once())->method('find')->willReturn(null); $request = self::createRequest() ->withAttribute('user_id', 98765); @@ -70,10 +70,10 @@ class DeleteUserTest extends TestCase $user = $this->createMock(User::class); $user->method('id')->willReturn(1); - $user->expects(self::once())->method('getPreference')->with(UserInterface::PREF_IS_ADMINISTRATOR)->willReturn('1'); + $user->expects($this->once())->method('getPreference')->with(UserInterface::PREF_IS_ADMINISTRATOR)->willReturn('1'); $user_service = $this->createMock(UserService::class); - $user_service->expects(self::once())->method('find')->willReturn($user); + $user_service->expects($this->once())->method('find')->willReturn($user); $request = self::createRequest() ->withAttribute('user_id', $user->id()); diff --git a/tests/app/Http/RequestHandlers/MasqueradeTest.php b/tests/app/Http/RequestHandlers/MasqueradeTest.php index 30b5ea0fc9..5ee0ac8960 100644 --- a/tests/app/Http/RequestHandlers/MasqueradeTest.php +++ b/tests/app/Http/RequestHandlers/MasqueradeTest.php @@ -42,7 +42,7 @@ class MasqueradeTest extends TestCase $user2->method('id')->willReturn(2); $user_service = $this->createMock(UserService::class); - $user_service->expects(self::once())->method('find')->willReturn($user2); + $user_service->expects($this->once())->method('find')->willReturn($user2); $request = self::createRequest() ->withAttribute('user', $user1) @@ -62,7 +62,7 @@ class MasqueradeTest extends TestCase $user->method('id')->willReturn(1); $user_service = $this->createMock(UserService::class); - $user_service->expects(self::once())->method('find')->willReturn($user); + $user_service->expects($this->once())->method('find')->willReturn($user); $request = self::createRequest() ->withAttribute('user', $user) @@ -84,7 +84,7 @@ class MasqueradeTest extends TestCase $user->method('id')->willReturn(1); $user_service = $this->createMock(UserService::class); - $user_service->expects(self::once())->method('find')->willReturn(null); + $user_service->expects($this->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 9477f96211..9b4502373f 100644 --- a/tests/app/Http/RequestHandlers/ModuleActionTest.php +++ b/tests/app/Http/RequestHandlers/ModuleActionTest.php @@ -39,7 +39,7 @@ class ModuleActionTest extends TestCase { $module_service = $this->createMock(ModuleService::class); $module_service - ->expects(self::once()) + ->expects($this->once()) ->method('findByName') ->with('test') ->willReturn($this->fooModule()); @@ -63,7 +63,7 @@ class ModuleActionTest extends TestCase $module_service = $this->createMock(ModuleService::class); $module_service - ->expects(self::once()) + ->expects($this->once()) ->method('findByName') ->with('test') ->willReturn($this->fooModule()); @@ -84,7 +84,7 @@ class ModuleActionTest extends TestCase $module_service = $this->createMock(ModuleService::class); $module_service - ->expects(self::once()) + ->expects($this->once()) ->method('findByName') ->with('test') ->willReturn(null); @@ -105,7 +105,7 @@ class ModuleActionTest extends TestCase $module_service = $this->createMock(ModuleService::class); $module_service - ->expects(self::once()) + ->expects($this->once()) ->method('findByName') ->with('test') ->willReturn($this->fooModule()); diff --git a/tests/app/Http/RequestHandlers/PasswordResetPageTest.php b/tests/app/Http/RequestHandlers/PasswordResetPageTest.php index 0519a5a00b..73898b5997 100644 --- a/tests/app/Http/RequestHandlers/PasswordResetPageTest.php +++ b/tests/app/Http/RequestHandlers/PasswordResetPageTest.php @@ -37,7 +37,7 @@ class PasswordResetPageTest extends TestCase $user_service = $this->createMock(UserService::class); $user_service - ->expects(self::once()) + ->expects($this->once()) ->method('findByToken') ->with('1234') ->willReturn($user); @@ -54,7 +54,7 @@ class PasswordResetPageTest extends TestCase { $user_service = $this->createMock(UserService::class); $user_service - ->expects(self::once()) + ->expects($this->once()) ->method('findByToken') ->with('4321') ->willReturn(null); diff --git a/tests/app/Http/RequestHandlers/PingTest.php b/tests/app/Http/RequestHandlers/PingTest.php index 57c5317d4a..9f68ffb2df 100644 --- a/tests/app/Http/RequestHandlers/PingTest.php +++ b/tests/app/Http/RequestHandlers/PingTest.php @@ -31,8 +31,8 @@ class PingTest extends TestCase public function testPingOK(): void { $server_check_service = $this->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()); + $server_check_service->expects($this->once())->method('serverErrors')->willReturn(new Collection()); + $server_check_service->expects($this->once())->method('serverWarnings')->willReturn(new Collection()); $request = self::createRequest(); $handler = new Ping($server_check_service); @@ -45,8 +45,8 @@ class PingTest extends TestCase public function testPingWarnings(): void { $server_check_service = $this->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')); + $server_check_service->expects($this->once())->method('serverErrors')->willReturn(new Collection()); + $server_check_service->expects($this->once())->method('serverWarnings')->willReturn(new Collection('warning')); $request = self::createRequest(); $handler = new Ping($server_check_service); @@ -59,7 +59,7 @@ class PingTest extends TestCase public function testPingErrors(): void { $server_check_service = $this->createMock(ServerCheckService::class); - $server_check_service->expects(self::once())->method('serverErrors')->willReturn(new Collection('error')); + $server_check_service->expects($this->once())->method('serverErrors')->willReturn(new Collection('error')); $request = self::createRequest(); $handler = new Ping($server_check_service); diff --git a/tests/app/Http/RequestHandlers/RedirectAncestryPhpTest.php b/tests/app/Http/RequestHandlers/RedirectAncestryPhpTest.php index 084f0f9340..1f4a531a6b 100644 --- a/tests/app/Http/RequestHandlers/RedirectAncestryPhpTest.php +++ b/tests/app/Http/RequestHandlers/RedirectAncestryPhpTest.php @@ -25,6 +25,7 @@ use Fisharebest\Webtrees\Factories\IndividualFactory; use Fisharebest\Webtrees\Http\Exceptions\HttpGoneException; use Fisharebest\Webtrees\Individual; use Fisharebest\Webtrees\Module\AncestorsChartModule; +use Fisharebest\Webtrees\Module\ModuleChartInterface; use Fisharebest\Webtrees\Registry; use Fisharebest\Webtrees\Services\ModuleService; use Fisharebest\Webtrees\Services\TreeService; @@ -47,7 +48,7 @@ class RedirectAncestryPhpTest extends TestCase $tree_service = $this->createMock(TreeService::class); $tree_service - ->expects(self::once()) + ->expects($this->once()) ->method('all') ->willReturn(new Collection(['tree1' => $tree])); @@ -55,7 +56,7 @@ class RedirectAncestryPhpTest extends TestCase $individual_factory = $this->createMock(IndividualFactory::class); $individual_factory - ->expects(self::once()) + ->expects($this->once()) ->method('make') ->with('X123', $tree) ->willReturn($individual); @@ -64,23 +65,20 @@ class RedirectAncestryPhpTest extends TestCase $module = $this->createMock(AncestorsChartModule::class); $module - ->expects(self::once()) + ->expects($this->once()) ->method('chartUrl') ->willReturn('https://www.example.com'); $module_service = $this->createMock(ModuleService::class); $module_service - ->expects(self::once()) - ->method('findByInterface') - ->with(AncestorsChartModule::class) + ->expects($this->once()) + ->method('findByComponent') + ->with(ModuleChartInterface::class) ->willReturn(new Collection([$module])); $handler = new RedirectAncestryPhp($module_service, $tree_service); - $request = self::createRequest( - RequestMethodInterface::METHOD_GET, - ['ged' => 'tree1', 'rootid' => 'X123'] - ); + $request = self::createRequest(RequestMethodInterface::METHOD_GET, ['ged' => 'tree1', 'rootid' => 'X123']); $response = $handler->handle($request); @@ -90,26 +88,26 @@ class RedirectAncestryPhpTest extends TestCase public function testModuleDisabled(): void { - $module_service = $this->createMock(ModuleService::class); - $module_service - ->expects(self::once())->method('findByInterface') - ->with(AncestorsChartModule::class) - ->willReturn(new Collection()); - $tree = $this->createMock(Tree::class); + $tree + ->method('name') + ->willReturn('tree1'); $tree_service = $this->createMock(TreeService::class); $tree_service - ->expects(self::once()) + ->expects($this->once()) ->method('all') - ->willReturn(new Collection([$tree])); + ->willReturn(new Collection(['tree1' => $tree])); + + $module_service = $this->createMock(ModuleService::class); + $module_service + ->expects($this->once())->method('findByComponent') + ->with(ModuleChartInterface::class) + ->willReturn(new Collection()); $handler = new RedirectAncestryPhp($module_service, $tree_service); - $request = self::createRequest( - RequestMethodInterface::METHOD_GET, - ['ged' => 'tree1', 'rootid' => 'X123'] - ); + $request = self::createRequest(RequestMethodInterface::METHOD_GET, ['ged' => 'tree1', 'rootid' => 'X123']); $this->expectException(HttpGoneException::class); @@ -118,27 +116,17 @@ class RedirectAncestryPhpTest extends TestCase public function testNoSuchTree(): void { - $module = $this->createMock(AncestorsChartModule::class); - - $module_service = $this->createMock(ModuleService::class); - $module_service - ->expects(self::once()) - ->method('findByInterface') - ->with(AncestorsChartModule::class) - ->willReturn(new Collection([$module])); - $tree_service = $this->createMock(TreeService::class); $tree_service - ->expects(self::once()) + ->expects($this->once()) ->method('all') ->willReturn(new Collection([])); + $module_service = $this->createMock(ModuleService::class); + $handler = new RedirectAncestryPhp($module_service, $tree_service); - $request = self::createRequest( - RequestMethodInterface::METHOD_GET, - ['ged' => 'tree1', 'rootid' => 'X123'] - ); + $request = self::createRequest(RequestMethodInterface::METHOD_GET, ['ged' => 'tree1', 'rootid' => 'X123']); $this->expectException(HttpGoneException::class); diff --git a/tests/app/Http/RequestHandlers/RedirectBranchesPhpTest.php b/tests/app/Http/RequestHandlers/RedirectBranchesPhpTest.php index 521041ea7c..de084eaa6e 100644 --- a/tests/app/Http/RequestHandlers/RedirectBranchesPhpTest.php +++ b/tests/app/Http/RequestHandlers/RedirectBranchesPhpTest.php @@ -23,6 +23,7 @@ use Fig\Http\Message\RequestMethodInterface; use Fig\Http\Message\StatusCodeInterface; use Fisharebest\Webtrees\Http\Exceptions\HttpGoneException; use Fisharebest\Webtrees\Module\BranchesListModule; +use Fisharebest\Webtrees\Module\ModuleListInterface; use Fisharebest\Webtrees\Services\ModuleService; use Fisharebest\Webtrees\Services\TreeService; use Fisharebest\Webtrees\TestCase; @@ -44,7 +45,7 @@ class RedirectBranchesPhpTest extends TestCase $tree_service = $this->createMock(TreeService::class); $tree_service - ->expects(self::once()) + ->expects($this->once()) ->method('all') ->willReturn(new Collection(['tree1' => $tree])); @@ -52,9 +53,9 @@ class RedirectBranchesPhpTest extends TestCase $module_service = $this->createMock(ModuleService::class); $module_service - ->expects(self::once()) - ->method('findByInterface') - ->with(BranchesListModule::class) + ->expects($this->once()) + ->method('findByComponent') + ->with(ModuleListInterface::class) ->willReturn(new Collection([$module])); $handler = new RedirectBranchesPhp($module_service, $tree_service); @@ -78,19 +79,19 @@ class RedirectBranchesPhpTest extends TestCase public function testModuleDisabled(): void { - $module_service = $this->createMock(ModuleService::class); - $module_service - ->expects(self::once())->method('findByInterface') - ->with(BranchesListModule::class) - ->willReturn(new Collection()); - $tree = $this->createMock(Tree::class); $tree_service = $this->createMock(TreeService::class); $tree_service - ->expects(self::once()) + ->expects($this->once()) ->method('all') - ->willReturn(new Collection([$tree])); + ->willReturn(new Collection(['tree1' => $tree])); + + $module_service = $this->createMock(ModuleService::class); + $module_service + ->method('findByComponent') + ->with(ModuleListInterface::class) + ->willReturn(new Collection()); $handler = new RedirectBranchesPhp($module_service, $tree_service); @@ -106,21 +107,14 @@ class RedirectBranchesPhpTest extends TestCase public function testNoSuchTree(): void { - $module = $this->createMock(BranchesListModule::class); - - $module_service = $this->createMock(ModuleService::class); - $module_service - ->expects(self::once()) - ->method('findByInterface') - ->with(BranchesListModule::class) - ->willReturn(new Collection([$module])); - $tree_service = $this->createMock(TreeService::class); $tree_service - ->expects(self::once()) + ->expects($this->once()) ->method('all') ->willReturn(new Collection([])); + $module_service = $this->createMock(ModuleService::class); + $handler = new RedirectBranchesPhp($module_service, $tree_service); $request = self::createRequest( diff --git a/tests/app/Http/RequestHandlers/RedirectCalendarPhpTest.php b/tests/app/Http/RequestHandlers/RedirectCalendarPhpTest.php index 0d54371d33..9995b9c8d0 100644 --- a/tests/app/Http/RequestHandlers/RedirectCalendarPhpTest.php +++ b/tests/app/Http/RequestHandlers/RedirectCalendarPhpTest.php @@ -42,7 +42,7 @@ class RedirectCalendarPhpTest extends TestCase $tree_service = $this->createMock(TreeService::class); $tree_service - ->expects(self::once()) + ->expects($this->once()) ->method('all') ->willReturn(new Collection(['tree1' => $tree])); @@ -69,7 +69,7 @@ class RedirectCalendarPhpTest extends TestCase { $tree_service = $this->createMock(TreeService::class); $tree_service - ->expects(self::once()) + ->expects($this->once()) ->method('all') ->willReturn(new Collection([])); diff --git a/tests/app/Http/RequestHandlers/RedirectCompactPhpTest.php b/tests/app/Http/RequestHandlers/RedirectCompactPhpTest.php index 5988355585..2ad875c10e 100644 --- a/tests/app/Http/RequestHandlers/RedirectCompactPhpTest.php +++ b/tests/app/Http/RequestHandlers/RedirectCompactPhpTest.php @@ -25,6 +25,8 @@ use Fisharebest\Webtrees\Factories\IndividualFactory; use Fisharebest\Webtrees\Http\Exceptions\HttpGoneException; use Fisharebest\Webtrees\Individual; use Fisharebest\Webtrees\Module\CompactTreeChartModule; +use Fisharebest\Webtrees\Module\ModuleChartInterface; +use Fisharebest\Webtrees\Module\ModuleListInterface; use Fisharebest\Webtrees\Registry; use Fisharebest\Webtrees\Services\ModuleService; use Fisharebest\Webtrees\Services\TreeService; @@ -47,7 +49,7 @@ class RedirectCompactPhpTest extends TestCase $tree_service = $this->createMock(TreeService::class); $tree_service - ->expects(self::once()) + ->expects($this->once()) ->method('all') ->willReturn(new Collection(['tree1' => $tree])); @@ -55,7 +57,7 @@ class RedirectCompactPhpTest extends TestCase $individual_factory = $this->createMock(IndividualFactory::class); $individual_factory - ->expects(self::once()) + ->expects($this->once()) ->method('make') ->with('X123', $tree) ->willReturn($individual); @@ -64,23 +66,20 @@ class RedirectCompactPhpTest extends TestCase $module = $this->createMock(CompactTreeChartModule::class); $module - ->expects(self::once()) + ->expects($this->once()) ->method('chartUrl') ->willReturn('https://www.example.com'); $module_service = $this->createMock(ModuleService::class); $module_service - ->expects(self::once()) - ->method('findByInterface') - ->with(CompactTreeChartModule::class) + ->expects($this->once()) + ->method('findByComponent') + ->with(ModuleChartInterface::class) ->willReturn(new Collection([$module])); $handler = new RedirectCompactPhp($module_service, $tree_service); - $request = self::createRequest( - RequestMethodInterface::METHOD_GET, - ['ged' => 'tree1', 'rootid' => 'X123'] - ); + $request = self::createRequest(RequestMethodInterface::METHOD_GET, ['ged' => 'tree1', 'rootid' => 'X123']); $response = $handler->handle($request); @@ -92,24 +91,21 @@ class RedirectCompactPhpTest extends TestCase { $module_service = $this->createMock(ModuleService::class); $module_service - ->expects(self::once())->method('findByInterface') - ->with(CompactTreeChartModule::class) + ->expects($this->once())->method('findByComponent') + ->with(ModuleChartInterface::class) ->willReturn(new Collection()); $tree = $this->createMock(Tree::class); $tree_service = $this->createMock(TreeService::class); $tree_service - ->expects(self::once()) + ->expects($this->once()) ->method('all') - ->willReturn(new Collection([$tree])); + ->willReturn(new Collection(['tree1' => $tree])); $handler = new RedirectCompactPhp($module_service, $tree_service); - $request = self::createRequest( - RequestMethodInterface::METHOD_GET, - ['ged' => 'tree1', 'rootid' => 'X123'] - ); + $request = self::createRequest(RequestMethodInterface::METHOD_GET, ['ged' => 'tree1', 'rootid' => 'X123']); $this->expectException(HttpGoneException::class); @@ -118,27 +114,17 @@ class RedirectCompactPhpTest extends TestCase public function testNoSuchTree(): void { - $module = $this->createMock(CompactTreeChartModule::class); - - $module_service = $this->createMock(ModuleService::class); - $module_service - ->expects(self::once()) - ->method('findByInterface') - ->with(CompactTreeChartModule::class) - ->willReturn(new Collection([$module])); - $tree_service = $this->createMock(TreeService::class); $tree_service - ->expects(self::once()) + ->expects($this->once()) ->method('all') ->willReturn(new Collection([])); + $module_service = $this->createMock(ModuleService::class); + $handler = new RedirectCompactPhp($module_service, $tree_service); - $request = self::createRequest( - RequestMethodInterface::METHOD_GET, - ['ged' => 'tree1', 'rootid' => 'X123'] - ); + $request = self::createRequest(RequestMethodInterface::METHOD_GET, ['ged' => 'tree1', 'rootid' => 'X123']); $this->expectException(HttpGoneException::class); diff --git a/tests/app/Http/RequestHandlers/RedirectDescendancyPhpTest.php b/tests/app/Http/RequestHandlers/RedirectDescendancyPhpTest.php index ef4a652794..da10c84f5a 100644 --- a/tests/app/Http/RequestHandlers/RedirectDescendancyPhpTest.php +++ b/tests/app/Http/RequestHandlers/RedirectDescendancyPhpTest.php @@ -25,6 +25,8 @@ use Fisharebest\Webtrees\Factories\IndividualFactory; use Fisharebest\Webtrees\Http\Exceptions\HttpGoneException; use Fisharebest\Webtrees\Individual; use Fisharebest\Webtrees\Module\DescendancyChartModule; +use Fisharebest\Webtrees\Module\ModuleChartInterface; +use Fisharebest\Webtrees\Module\ModuleListInterface; use Fisharebest\Webtrees\Registry; use Fisharebest\Webtrees\Services\ModuleService; use Fisharebest\Webtrees\Services\TreeService; @@ -47,7 +49,7 @@ class RedirectDescendancyPhpTest extends TestCase $tree_service = $this->createMock(TreeService::class); $tree_service - ->expects(self::once()) + ->expects($this->once()) ->method('all') ->willReturn(new Collection(['tree1' => $tree])); @@ -55,7 +57,7 @@ class RedirectDescendancyPhpTest extends TestCase $individual_factory = $this->createMock(IndividualFactory::class); $individual_factory - ->expects(self::once()) + ->expects($this->once()) ->method('make') ->with('X123', $tree) ->willReturn($individual); @@ -64,15 +66,15 @@ class RedirectDescendancyPhpTest extends TestCase $descendancy_chart = $this->createMock(DescendancyChartModule::class); $descendancy_chart - ->expects(self::once()) + ->expects($this->once()) ->method('chartUrl') ->willReturn('https://www.example.com'); $module_service = $this->createMock(ModuleService::class); $module_service - ->expects(self::once()) - ->method('findByInterface') - ->with(DescendancyChartModule::class) + ->expects($this->once()) + ->method('findByComponent') + ->with(ModuleChartInterface::class) ->willReturn(new Collection([$descendancy_chart])); $handler = new RedirectDescendencyPhp($module_service, $tree_service); @@ -88,24 +90,21 @@ class RedirectDescendancyPhpTest extends TestCase { $module_service = $this->createMock(ModuleService::class); $module_service - ->expects(self::once())->method('findByInterface') - ->with(DescendancyChartModule::class) + ->method('findByComponent') + ->with(ModuleChartInterface::class) ->willReturn(new Collection()); $tree = $this->createMock(Tree::class); $tree_service = $this->createMock(TreeService::class); $tree_service - ->expects(self::once()) + ->expects($this->once()) ->method('all') - ->willReturn(new Collection([$tree])); + ->willReturn(new Collection(['tree1' => $tree])); $handler = new RedirectDescendencyPhp($module_service, $tree_service); - $request = self::createRequest( - RequestMethodInterface::METHOD_GET, - ['ged' => 'tree1', 'rootid' => 'X123'] - ); + $request = self::createRequest(RequestMethodInterface::METHOD_GET, ['ged' => 'tree1', 'rootid' => 'X123']); $this->expectException(HttpGoneException::class); @@ -114,27 +113,17 @@ class RedirectDescendancyPhpTest extends TestCase public function testNoSuchTree(): void { - $module = $this->createMock(DescendancyChartModule::class); - $module_service = $this->createMock(ModuleService::class); - $module_service - ->expects(self::once()) - ->method('findByInterface') - ->with(DescendancyChartModule::class) - ->willReturn(new Collection([$module])); $tree_service = $this->createMock(TreeService::class); $tree_service - ->expects(self::once()) + ->expects($this->once()) ->method('all') ->willReturn(new Collection([])); $handler = new RedirectDescendencyPhp($module_service, $tree_service); - $request = self::createRequest( - RequestMethodInterface::METHOD_GET, - ['ged' => 'tree1', 'rootid' => 'X123'] - ); + $request = self::createRequest(RequestMethodInterface::METHOD_GET, ['ged' => 'tree1', 'rootid' => 'X123']); $this->expectException(HttpGoneException::class); diff --git a/tests/app/Http/RequestHandlers/RedirectFamListPhpTest.php b/tests/app/Http/RequestHandlers/RedirectFamListPhpTest.php index 7344a5f829..dd13e2080f 100644 --- a/tests/app/Http/RequestHandlers/RedirectFamListPhpTest.php +++ b/tests/app/Http/RequestHandlers/RedirectFamListPhpTest.php @@ -21,8 +21,10 @@ namespace Fisharebest\Webtrees\Http\RequestHandlers; use Fig\Http\Message\RequestMethodInterface; use Fig\Http\Message\StatusCodeInterface; +use Fisharebest\Webtrees\GuestUser; use Fisharebest\Webtrees\Http\Exceptions\HttpGoneException; use Fisharebest\Webtrees\Module\FamilyListModule; +use Fisharebest\Webtrees\Module\ModuleListInterface; use Fisharebest\Webtrees\Services\ModuleService; use Fisharebest\Webtrees\Services\TreeService; use Fisharebest\Webtrees\TestCase; @@ -44,21 +46,21 @@ class RedirectFamListPhpTest extends TestCase $tree_service = $this->createMock(TreeService::class); $tree_service - ->expects(self::once()) + ->expects($this->once()) ->method('all') ->willReturn(new Collection(['tree1' => $tree])); $module = $this->createMock(FamilyListModule::class); $module - ->expects(self::once()) + ->expects($this->once()) ->method('listUrl') ->willReturn('https://www.example.com'); $module_service = $this->createMock(ModuleService::class); $module_service - ->expects(self::once()) - ->method('findByInterface') - ->with(FamilyListModule::class) + ->expects($this->once()) + ->method('findByComponent') + ->with(ModuleListInterface::class, $tree, new GuestUser()) ->willReturn(new Collection([$module])); $handler = new RedirectFamListPhp($module_service, $tree_service); @@ -73,19 +75,22 @@ class RedirectFamListPhpTest extends TestCase public function testModuleDisabled(): void { - $module_service = $this->createMock(ModuleService::class); - $module_service - ->expects(self::once())->method('findByInterface') - ->with(FamilyListModule::class) - ->willReturn(new Collection()); - $tree = $this->createMock(Tree::class); + $tree + ->method('name') + ->willReturn('tree1'); $tree_service = $this->createMock(TreeService::class); $tree_service - ->expects(self::once()) + ->expects($this->once()) ->method('all') - ->willReturn(new Collection([$tree])); + ->willReturn(new Collection(['tree1' => $tree])); + + $module_service = $this->createMock(ModuleService::class); + $module_service + ->expects($this->once())->method('findByComponent') + ->with(ModuleListInterface::class, $tree, new GuestUser()) + ->willReturn(new Collection()); $handler = new RedirectFamListPhp($module_service, $tree_service); @@ -98,18 +103,11 @@ class RedirectFamListPhpTest extends TestCase public function testNoSuchTree(): void { - $module = $this->createMock(FamilyListModule::class); - $module_service = $this->createMock(ModuleService::class); - $module_service - ->expects(self::once()) - ->method('findByInterface') - ->with(FamilyListModule::class) - ->willReturn(new Collection([$module])); $tree_service = $this->createMock(TreeService::class); $tree_service - ->expects(self::once()) + ->expects($this->once()) ->method('all') ->willReturn(new Collection([])); diff --git a/tests/app/Http/RequestHandlers/RedirectFamilyBookPhpTest.php b/tests/app/Http/RequestHandlers/RedirectFamilyBookPhpTest.php index d53df5b3da..0ba77e5f2e 100644 --- a/tests/app/Http/RequestHandlers/RedirectFamilyBookPhpTest.php +++ b/tests/app/Http/RequestHandlers/RedirectFamilyBookPhpTest.php @@ -25,6 +25,8 @@ use Fisharebest\Webtrees\Factories\IndividualFactory; use Fisharebest\Webtrees\Http\Exceptions\HttpGoneException; use Fisharebest\Webtrees\Individual; use Fisharebest\Webtrees\Module\FamilyBookChartModule; +use Fisharebest\Webtrees\Module\ModuleChartInterface; +use Fisharebest\Webtrees\Module\ModuleListInterface; use Fisharebest\Webtrees\Registry; use Fisharebest\Webtrees\Services\ModuleService; use Fisharebest\Webtrees\Services\TreeService; @@ -47,7 +49,7 @@ class RedirectFamilyBookPhpTest extends TestCase $tree_service = $this->createMock(TreeService::class); $tree_service - ->expects(self::once()) + ->expects($this->once()) ->method('all') ->willReturn(new Collection(['tree1' => $tree])); @@ -55,7 +57,7 @@ class RedirectFamilyBookPhpTest extends TestCase $individual_factory = $this->createMock(IndividualFactory::class); $individual_factory - ->expects(self::once()) + ->expects($this->once()) ->method('make') ->with('X123', $tree) ->willReturn($individual); @@ -64,15 +66,15 @@ class RedirectFamilyBookPhpTest extends TestCase $Compact_chart = $this->createMock(FamilyBookChartModule::class); $Compact_chart - ->expects(self::once()) + ->expects($this->once()) ->method('chartUrl') ->willReturn('https://www.example.com'); $module_service = $this->createMock(ModuleService::class); $module_service - ->expects(self::once()) - ->method('findByInterface') - ->with(FamilyBookChartModule::class) + ->expects($this->once()) + ->method('findByComponent') + ->with(ModuleChartInterface::class) ->willReturn(new Collection([$Compact_chart])); $handler = new RedirectFamilyBookPhp($module_service, $tree_service); @@ -88,23 +90,21 @@ class RedirectFamilyBookPhpTest extends TestCase { $module_service = $this->createMock(ModuleService::class); $module_service - ->expects(self::once())->method('findByInterface') - ->with(FamilyBookChartModule::class) + ->method('findByComponent') + ->with(ModuleChartInterface::class) ->willReturn(new Collection()); $tree = $this->createMock(Tree::class); $tree_service = $this->createMock(TreeService::class); $tree_service - ->expects(self::once()) + ->expects($this->once()) ->method('all') - ->willReturn(new Collection([$tree])); + ->willReturn(new Collection(['tree1' => $tree])); + $handler = new RedirectFamilyBookPhp($module_service, $tree_service); - $request = self::createRequest( - RequestMethodInterface::METHOD_GET, - ['ged' => 'tree1', 'rootid' => 'X123'] - ); + $request = self::createRequest(RequestMethodInterface::METHOD_GET, ['ged' => 'tree1', 'rootid' => 'X123']); $this->expectException(HttpGoneException::class); @@ -113,27 +113,17 @@ class RedirectFamilyBookPhpTest extends TestCase public function testNoSuchTree(): void { - $module = $this->createMock(FamilyBookChartModule::class); - $module_service = $this->createMock(ModuleService::class); - $module_service - ->expects(self::once()) - ->method('findByInterface') - ->with(FamilyBookChartModule::class) - ->willReturn(new Collection([$module])); $tree_service = $this->createMock(TreeService::class); $tree_service - ->expects(self::once()) + ->expects($this->once()) ->method('all') ->willReturn(new Collection([])); $handler = new RedirectFamilyBookPhp($module_service, $tree_service); - $request = self::createRequest( - RequestMethodInterface::METHOD_GET, - ['ged' => 'tree1', 'rootid' => 'X123'] - ); + $request = self::createRequest(RequestMethodInterface::METHOD_GET, ['ged' => 'tree1', 'rootid' => 'X123']); $this->expectException(HttpGoneException::class); diff --git a/tests/app/Http/RequestHandlers/RedirectFamilyPhpTest.php b/tests/app/Http/RequestHandlers/RedirectFamilyPhpTest.php index a45ae0c374..e84d51ffd2 100644 --- a/tests/app/Http/RequestHandlers/RedirectFamilyPhpTest.php +++ b/tests/app/Http/RequestHandlers/RedirectFamilyPhpTest.php @@ -46,7 +46,7 @@ class RedirectFamilyPhpTest extends TestCase $tree_service = $this->createMock(TreeService::class); $tree_service - ->expects(self::once()) + ->expects($this->once()) ->method('all') ->willReturn(new Collection(['tree1' => $tree])); @@ -57,7 +57,7 @@ class RedirectFamilyPhpTest extends TestCase $family_factory = $this->createMock(FamilyFactory::class); $family_factory - ->expects(self::once()) + ->expects($this->once()) ->method('make') ->with('X123', $tree) ->willReturn($family); @@ -66,10 +66,7 @@ class RedirectFamilyPhpTest extends TestCase $handler = new RedirectFamilyPhp($tree_service); - $request = self::createRequest( - RequestMethodInterface::METHOD_GET, - ['ged' => 'tree1', 'famid' => 'X123'] - ); + $request = self::createRequest(RequestMethodInterface::METHOD_GET, ['ged' => 'tree1', 'famid' => 'X123']); $response = $handler->handle($request); @@ -83,16 +80,13 @@ class RedirectFamilyPhpTest extends TestCase $tree_service = $this->createMock(TreeService::class); $tree_service - ->expects(self::once()) + ->expects($this->once()) ->method('all') - ->willReturn(new Collection([$tree])); + ->willReturn(new Collection(['tree1' => $tree])); $handler = new RedirectFamilyPhp($tree_service); - $request = self::createRequest( - RequestMethodInterface::METHOD_GET, - ['ged' => 'tree1', 'famid' => 'X123'] - ); + $request = self::createRequest(RequestMethodInterface::METHOD_GET, ['ged' => 'tree1', 'famid' => 'X123']); $this->expectException(HttpGoneException::class); diff --git a/tests/app/Http/RequestHandlers/RedirectFanChartPhpTest.php b/tests/app/Http/RequestHandlers/RedirectFanChartPhpTest.php index 6cf2de364f..d9f3984f86 100644 --- a/tests/app/Http/RequestHandlers/RedirectFanChartPhpTest.php +++ b/tests/app/Http/RequestHandlers/RedirectFanChartPhpTest.php @@ -25,6 +25,7 @@ use Fisharebest\Webtrees\Factories\IndividualFactory; use Fisharebest\Webtrees\Http\Exceptions\HttpGoneException; use Fisharebest\Webtrees\Individual; use Fisharebest\Webtrees\Module\FanChartModule; +use Fisharebest\Webtrees\Module\ModuleChartInterface; use Fisharebest\Webtrees\Registry; use Fisharebest\Webtrees\Services\ModuleService; use Fisharebest\Webtrees\Services\TreeService; @@ -47,7 +48,7 @@ class RedirectFanChartPhpTest extends TestCase $tree_service = $this->createMock(TreeService::class); $tree_service - ->expects(self::once()) + ->expects($this->once()) ->method('all') ->willReturn(new Collection(['tree1' => $tree])); @@ -55,7 +56,7 @@ class RedirectFanChartPhpTest extends TestCase $individual_factory = $this->createMock(IndividualFactory::class); $individual_factory - ->expects(self::once()) + ->expects($this->once()) ->method('make') ->with('X123', $tree) ->willReturn($individual); @@ -64,23 +65,20 @@ class RedirectFanChartPhpTest extends TestCase $module = $this->createMock(FanChartModule::class); $module - ->expects(self::once()) + ->expects($this->once()) ->method('chartUrl') ->willReturn('https://www.example.com'); $module_service = $this->createMock(ModuleService::class); $module_service - ->expects(self::once()) - ->method('findByInterface') - ->with(FanChartModule::class) + ->expects($this->once()) + ->method('findByComponent') + ->with(ModuleChartInterface::class) ->willReturn(new Collection([$module])); $handler = new RedirectFanChartPhp($module_service, $tree_service); - $request = self::createRequest( - RequestMethodInterface::METHOD_GET, - ['ged' => 'tree1', 'rootid' => 'X123'] - ); + $request = self::createRequest(RequestMethodInterface::METHOD_GET, ['ged' => 'tree1', 'rootid' => 'X123']); $response = $handler->handle($request); @@ -90,26 +88,26 @@ class RedirectFanChartPhpTest extends TestCase public function testModuleDisabled(): void { - $module_service = $this->createMock(ModuleService::class); - $module_service - ->expects(self::once())->method('findByInterface') - ->with(FanChartModule::class) - ->willReturn(new Collection()); - $tree = $this->createMock(Tree::class); + $tree + ->method('name') + ->willReturn('tree1'); $tree_service = $this->createMock(TreeService::class); $tree_service - ->expects(self::once()) + ->expects($this->once()) ->method('all') - ->willReturn(new Collection([$tree])); + ->willReturn(new Collection(['tree1' => $tree])); + + $module_service = $this->createMock(ModuleService::class); + $module_service + ->expects($this->once())->method('findByComponent') + ->with(ModuleChartInterface::class) + ->willReturn(new Collection()); $handler = new RedirectFanChartPhp($module_service, $tree_service); - $request = self::createRequest( - RequestMethodInterface::METHOD_GET, - ['ged' => 'tree1', 'rootid' => 'X123'] - ); + $request = self::createRequest(RequestMethodInterface::METHOD_GET, ['ged' => 'tree1', 'rootid' => 'X123']); $this->expectException(HttpGoneException::class); @@ -118,27 +116,17 @@ class RedirectFanChartPhpTest extends TestCase public function testNoSuchTree(): void { - $module = $this->createMock(FanChartModule::class); - - $module_service = $this->createMock(ModuleService::class); - $module_service - ->expects(self::once()) - ->method('findByInterface') - ->with(FanChartModule::class) - ->willReturn(new Collection([$module])); - $tree_service = $this->createMock(TreeService::class); $tree_service - ->expects(self::once()) + ->expects($this->once()) ->method('all') ->willReturn(new Collection([])); + $module_service = $this->createMock(ModuleService::class); + $handler = new RedirectFanChartPhp($module_service, $tree_service); - $request = self::createRequest( - RequestMethodInterface::METHOD_GET, - ['ged' => 'tree1', 'rootid' => 'X123'] - ); + $request = self::createRequest(RequestMethodInterface::METHOD_GET, ['ged' => 'tree1', 'rootid' => 'X123']); $this->expectException(HttpGoneException::class); diff --git a/tests/app/Http/RequestHandlers/RedirectGedRecordPhpTest.php b/tests/app/Http/RequestHandlers/RedirectGedRecordPhpTest.php index f96446b85b..e99d793f64 100644 --- a/tests/app/Http/RequestHandlers/RedirectGedRecordPhpTest.php +++ b/tests/app/Http/RequestHandlers/RedirectGedRecordPhpTest.php @@ -46,7 +46,7 @@ class RedirectGedRecordPhpTest extends TestCase $tree_service = $this->createMock(TreeService::class); $tree_service - ->expects(self::once()) + ->expects($this->once()) ->method('all') ->willReturn(new Collection(['tree1' => $tree])); @@ -57,7 +57,7 @@ class RedirectGedRecordPhpTest extends TestCase $gedcom_record_factory = $this->createMock(GedcomRecordFactory::class); $gedcom_record_factory - ->expects(self::once()) + ->expects($this->once()) ->method('make') ->with('X123', $tree) ->willReturn($gedcom_record); @@ -83,9 +83,9 @@ class RedirectGedRecordPhpTest extends TestCase $tree_service = $this->createMock(TreeService::class); $tree_service - ->expects(self::once()) + ->expects($this->once()) ->method('all') - ->willReturn(new Collection([$tree])); + ->willReturn(new Collection(['tree1' => $tree])); $handler = new RedirectGedRecordPhp($tree_service); diff --git a/tests/app/Http/RequestHandlers/RedirectHourGlassPhpTest.php b/tests/app/Http/RequestHandlers/RedirectHourGlassPhpTest.php index 896f1ce824..216846d153 100644 --- a/tests/app/Http/RequestHandlers/RedirectHourGlassPhpTest.php +++ b/tests/app/Http/RequestHandlers/RedirectHourGlassPhpTest.php @@ -25,6 +25,7 @@ use Fisharebest\Webtrees\Factories\IndividualFactory; use Fisharebest\Webtrees\Http\Exceptions\HttpGoneException; use Fisharebest\Webtrees\Individual; use Fisharebest\Webtrees\Module\HourglassChartModule; +use Fisharebest\Webtrees\Module\ModuleChartInterface; use Fisharebest\Webtrees\Registry; use Fisharebest\Webtrees\Services\ModuleService; use Fisharebest\Webtrees\Services\TreeService; @@ -47,7 +48,7 @@ class RedirectHourGlassPhpTest extends TestCase $tree_service = $this->createMock(TreeService::class); $tree_service - ->expects(self::once()) + ->expects($this->once()) ->method('all') ->willReturn(new Collection(['tree1' => $tree])); @@ -55,7 +56,7 @@ class RedirectHourGlassPhpTest extends TestCase $individual_factory = $this->createMock(IndividualFactory::class); $individual_factory - ->expects(self::once()) + ->expects($this->once()) ->method('make') ->with('X123', $tree) ->willReturn($individual); @@ -64,23 +65,20 @@ class RedirectHourGlassPhpTest extends TestCase $module = $this->createMock(HourglassChartModule::class); $module - ->expects(self::once()) + ->expects($this->once()) ->method('chartUrl') ->willReturn('https://www.example.com'); $module_service = $this->createMock(ModuleService::class); $module_service - ->expects(self::once()) - ->method('findByInterface') - ->with(HourglassChartModule::class) + ->expects($this->once()) + ->method('findByComponent') + ->with(ModuleChartInterface::class) ->willReturn(new Collection([$module])); $handler = new RedirectHourGlassPhp($module_service, $tree_service); - $request = self::createRequest( - RequestMethodInterface::METHOD_GET, - ['ged' => 'tree1', 'rootid' => 'X123'] - ); + $request = self::createRequest(RequestMethodInterface::METHOD_GET, ['ged' => 'tree1', 'rootid' => 'X123']); $response = $handler->handle($request); @@ -92,24 +90,21 @@ class RedirectHourGlassPhpTest extends TestCase { $module_service = $this->createMock(ModuleService::class); $module_service - ->expects(self::once())->method('findByInterface') - ->with(HourglassChartModule::class) + ->expects($this->once())->method('findByComponent') + ->with(ModuleChartInterface::class) ->willReturn(new Collection()); $tree = $this->createMock(Tree::class); $tree_service = $this->createMock(TreeService::class); $tree_service - ->expects(self::once()) + ->expects($this->once()) ->method('all') - ->willReturn(new Collection([$tree])); + ->willReturn(new Collection(['tree1' => $tree])); $handler = new RedirectHourGlassPhp($module_service, $tree_service); - $request = self::createRequest( - RequestMethodInterface::METHOD_GET, - ['ged' => 'tree1', 'rootid' => 'X123'] - ); + $request = self::createRequest(RequestMethodInterface::METHOD_GET, ['ged' => 'tree1', 'rootid' => 'X123']); $this->expectException(HttpGoneException::class); @@ -118,27 +113,17 @@ class RedirectHourGlassPhpTest extends TestCase public function testNoSuchTree(): void { - $module = $this->createMock(HourglassChartModule::class); - - $module_service = $this->createMock(ModuleService::class); - $module_service - ->expects(self::once()) - ->method('findByInterface') - ->with(HourglassChartModule::class) - ->willReturn(new Collection([$module])); + $module_service = $this->createMock(ModuleService::class); $tree_service = $this->createMock(TreeService::class); $tree_service - ->expects(self::once()) + ->expects($this->once()) ->method('all') ->willReturn(new Collection([])); $handler = new RedirectHourGlassPhp($module_service, $tree_service); - $request = self::createRequest( - RequestMethodInterface::METHOD_GET, - ['ged' => 'tree1', 'rootid' => 'X123'] - ); + $request = self::createRequest(RequestMethodInterface::METHOD_GET, ['ged' => 'tree1', 'rootid' => 'X123']); $this->expectException(HttpGoneException::class); diff --git a/tests/app/Http/RequestHandlers/RedirectIndiListPhpTest.php b/tests/app/Http/RequestHandlers/RedirectIndiListPhpTest.php index db56286e7c..c1b09d1d59 100644 --- a/tests/app/Http/RequestHandlers/RedirectIndiListPhpTest.php +++ b/tests/app/Http/RequestHandlers/RedirectIndiListPhpTest.php @@ -21,8 +21,10 @@ namespace Fisharebest\Webtrees\Http\RequestHandlers; use Fig\Http\Message\RequestMethodInterface; use Fig\Http\Message\StatusCodeInterface; +use Fisharebest\Webtrees\GuestUser; use Fisharebest\Webtrees\Http\Exceptions\HttpGoneException; use Fisharebest\Webtrees\Module\IndividualListModule; +use Fisharebest\Webtrees\Module\ModuleListInterface; use Fisharebest\Webtrees\Services\ModuleService; use Fisharebest\Webtrees\Services\TreeService; use Fisharebest\Webtrees\TestCase; @@ -44,21 +46,21 @@ class RedirectIndiListPhpTest extends TestCase $tree_service = $this->createMock(TreeService::class); $tree_service - ->expects(self::once()) + ->expects($this->once()) ->method('all') ->willReturn(new Collection(['tree1' => $tree])); $module = $this->createMock(IndividualListModule::class); $module - ->expects(self::once()) + ->expects($this->once()) ->method('listUrl') ->willReturn('https://www.example.com'); $module_service = $this->createMock(ModuleService::class); $module_service - ->expects(self::once()) - ->method('findByInterface') - ->with(IndividualListModule::class) + ->expects($this->once()) + ->method('findByComponent') + ->with(ModuleListInterface::class, $tree, new GuestUser()) ->willReturn(new Collection([$module])); $handler = new RedirectIndiListPhp($module_service, $tree_service); @@ -73,19 +75,22 @@ class RedirectIndiListPhpTest extends TestCase public function testModuleDisabled(): void { - $module_service = $this->createMock(ModuleService::class); - $module_service - ->expects(self::once())->method('findByInterface') - ->with(IndividualListModule::class) - ->willReturn(new Collection()); - $tree = $this->createMock(Tree::class); + $tree + ->method('name') + ->willReturn('tree1'); $tree_service = $this->createMock(TreeService::class); $tree_service - ->expects(self::once()) + ->expects($this->once()) ->method('all') - ->willReturn(new Collection([$tree])); + ->willReturn(new Collection(['tree1' => $tree])); + + $module_service = $this->createMock(ModuleService::class); + $module_service + ->method('findByComponent') + ->with(ModuleListInterface::class, $tree, new GuestUser()) + ->willReturn(new Collection()); $handler = new RedirectIndiListPhp($module_service, $tree_service); @@ -98,18 +103,11 @@ class RedirectIndiListPhpTest extends TestCase public function testNoSuchTree(): void { - $module = $this->createMock(IndividualListModule::class); - $module_service = $this->createMock(ModuleService::class); - $module_service - ->expects(self::once()) - ->method('findByInterface') - ->with(IndividualListModule::class) - ->willReturn(new Collection([$module])); $tree_service = $this->createMock(TreeService::class); $tree_service - ->expects(self::once()) + ->expects($this->once()) ->method('all') ->willReturn(new Collection([])); diff --git a/tests/app/Http/RequestHandlers/RedirectIndividualPhpTest.php b/tests/app/Http/RequestHandlers/RedirectIndividualPhpTest.php index eb205f50a5..1128850edc 100644 --- a/tests/app/Http/RequestHandlers/RedirectIndividualPhpTest.php +++ b/tests/app/Http/RequestHandlers/RedirectIndividualPhpTest.php @@ -46,7 +46,7 @@ class RedirectIndividualPhpTest extends TestCase $tree_service = $this->createMock(TreeService::class); $tree_service - ->expects(self::once()) + ->expects($this->once()) ->method('all') ->willReturn(new Collection(['tree1' => $tree])); @@ -57,7 +57,7 @@ class RedirectIndividualPhpTest extends TestCase $individual_factory = $this->createMock(IndividualFactory::class); $individual_factory - ->expects(self::once()) + ->expects($this->once()) ->method('make') ->with('X123', $tree) ->willReturn($individual); @@ -66,10 +66,7 @@ class RedirectIndividualPhpTest extends TestCase $handler = new RedirectIndividualPhp($tree_service); - $request = self::createRequest( - RequestMethodInterface::METHOD_GET, - ['ged' => 'tree1', 'pid' => 'X123'] - ); + $request = self::createRequest(RequestMethodInterface::METHOD_GET, ['ged' => 'tree1', 'pid' => 'X123']); $response = $handler->handle($request); @@ -83,16 +80,13 @@ class RedirectIndividualPhpTest extends TestCase $tree_service = $this->createMock(TreeService::class); $tree_service - ->expects(self::once()) + ->expects($this->once()) ->method('all') - ->willReturn(new Collection([$tree])); + ->willReturn(new Collection(['tree1' => $tree])); $handler = new RedirectIndividualPhp($tree_service); - $request = self::createRequest( - RequestMethodInterface::METHOD_GET, - ['ged' => 'tree1', 'pid' => 'X123'] - ); + $request = self::createRequest(RequestMethodInterface::METHOD_GET, ['ged' => 'tree1', 'pid' => 'X123']); $this->expectException(HttpGoneException::class); @@ -103,16 +97,13 @@ class RedirectIndividualPhpTest extends TestCase { $tree_service = $this->createMock(TreeService::class); $tree_service - ->expects(self::once()) + ->expects($this->once()) ->method('all') ->willReturn(new Collection([])); $handler = new RedirectIndividualPhp($tree_service); - $request = self::createRequest( - RequestMethodInterface::METHOD_GET, - ['ged' => 'tree1', 'pid' => 'X123'] - ); + $request = self::createRequest(RequestMethodInterface::METHOD_GET, ['ged' => 'tree1', 'pid' => 'X123']); $this->expectException(HttpGoneException::class); diff --git a/tests/app/Http/RequestHandlers/RedirectLifeSpanPhpTest.php b/tests/app/Http/RequestHandlers/RedirectLifeSpanPhpTest.php index a5371e4224..9d7b506c43 100644 --- a/tests/app/Http/RequestHandlers/RedirectLifeSpanPhpTest.php +++ b/tests/app/Http/RequestHandlers/RedirectLifeSpanPhpTest.php @@ -23,6 +23,7 @@ use Fig\Http\Message\RequestMethodInterface; use Fig\Http\Message\StatusCodeInterface; use Fisharebest\Webtrees\Http\Exceptions\HttpGoneException; use Fisharebest\Webtrees\Module\LifespansChartModule; +use Fisharebest\Webtrees\Module\ModuleChartInterface; use Fisharebest\Webtrees\Services\ModuleService; use Fisharebest\Webtrees\Services\TreeService; use Fisharebest\Webtrees\TestCase; @@ -44,29 +45,26 @@ class RedirectLifeSpanPhpTest extends TestCase $tree_service = $this->createMock(TreeService::class); $tree_service - ->expects(self::once()) + ->expects($this->once()) ->method('all') ->willReturn(new Collection(['tree1' => $tree])); $module = $this->createMock(LifespansChartModule::class); $module - ->expects(self::once()) + ->expects($this->once()) ->method('chartUrl') ->willReturn('https://www.example.com'); $module_service = $this->createMock(ModuleService::class); $module_service - ->expects(self::once()) - ->method('findByInterface') - ->with(LifespansChartModule::class) + ->expects($this->once()) + ->method('findByComponent') + ->with(ModuleChartInterface::class) ->willReturn(new Collection([$module])); $handler = new RedirectLifeSpanPhp($module_service, $tree_service); - $request = self::createRequest( - RequestMethodInterface::METHOD_GET, - ['ged' => 'tree1', 'rootid' => 'X123'] - ); + $request = self::createRequest(RequestMethodInterface::METHOD_GET, ['ged' => 'tree1', 'rootid' => 'X123']); $response = $handler->handle($request); @@ -78,24 +76,21 @@ class RedirectLifeSpanPhpTest extends TestCase { $module_service = $this->createMock(ModuleService::class); $module_service - ->expects(self::once())->method('findByInterface') - ->with(LifespansChartModule::class) + ->expects($this->once())->method('findByComponent') + ->with(ModuleChartInterface::class) ->willReturn(new Collection()); $tree = $this->createMock(Tree::class); $tree_service = $this->createMock(TreeService::class); $tree_service - ->expects(self::once()) + ->expects($this->once()) ->method('all') - ->willReturn(new Collection([$tree])); + ->willReturn(new Collection(['tree1' => $tree])); $handler = new RedirectLifeSpanPhp($module_service, $tree_service); - $request = self::createRequest( - RequestMethodInterface::METHOD_GET, - ['ged' => 'tree1', 'rootid' => 'X123'] - ); + $request = self::createRequest(RequestMethodInterface::METHOD_GET, ['ged' => 'tree1', 'rootid' => 'X123']); $this->expectException(HttpGoneException::class); @@ -104,27 +99,17 @@ class RedirectLifeSpanPhpTest extends TestCase public function testNoSuchTree(): void { - $module = $this->createMock(LifespansChartModule::class); - - $module_service = $this->createMock(ModuleService::class); - $module_service - ->expects(self::once()) - ->method('findByInterface') - ->with(LifespansChartModule::class) - ->willReturn(new Collection([$module])); + $module_service = $this->createMock(ModuleService::class); $tree_service = $this->createMock(TreeService::class); $tree_service - ->expects(self::once()) + ->expects($this->once()) ->method('all') ->willReturn(new Collection([])); $handler = new RedirectLifeSpanPhp($module_service, $tree_service); - $request = self::createRequest( - RequestMethodInterface::METHOD_GET, - ['ged' => 'tree1', 'rootid' => 'X123'] - ); + $request = self::createRequest(RequestMethodInterface::METHOD_GET, ['ged' => 'tree1', 'rootid' => 'X123']); $this->expectException(HttpGoneException::class); diff --git a/tests/app/Http/RequestHandlers/RedirectMediaListPhpTest.php b/tests/app/Http/RequestHandlers/RedirectMediaListPhpTest.php index ec6f0b0b34..bc4e4a1efe 100644 --- a/tests/app/Http/RequestHandlers/RedirectMediaListPhpTest.php +++ b/tests/app/Http/RequestHandlers/RedirectMediaListPhpTest.php @@ -21,8 +21,10 @@ namespace Fisharebest\Webtrees\Http\RequestHandlers; use Fig\Http\Message\RequestMethodInterface; use Fig\Http\Message\StatusCodeInterface; +use Fisharebest\Webtrees\GuestUser; use Fisharebest\Webtrees\Http\Exceptions\HttpGoneException; use Fisharebest\Webtrees\Module\MediaListModule; +use Fisharebest\Webtrees\Module\ModuleListInterface; use Fisharebest\Webtrees\Services\ModuleService; use Fisharebest\Webtrees\Services\TreeService; use Fisharebest\Webtrees\TestCase; @@ -44,21 +46,21 @@ class RedirectMediaListPhpTest extends TestCase $tree_service = $this->createMock(TreeService::class); $tree_service - ->expects(self::once()) + ->expects($this->once()) ->method('all') ->willReturn(new Collection(['tree1' => $tree])); $module = $this->createMock(MediaListModule::class); $module - ->expects(self::once()) + ->expects($this->once()) ->method('listUrl') ->willReturn('https://www.example.com'); $module_service = $this->createMock(ModuleService::class); $module_service - ->expects(self::once()) - ->method('findByInterface') - ->with(MediaListModule::class) + ->expects($this->once()) + ->method('findByComponent') + ->with(ModuleListInterface::class) ->willReturn(new Collection([$module])); $handler = new RedirectMediaListPhp($module_service, $tree_service); @@ -73,19 +75,22 @@ class RedirectMediaListPhpTest extends TestCase public function testModuleDisabled(): void { - $module_service = $this->createMock(ModuleService::class); - $module_service - ->expects(self::once())->method('findByInterface') - ->with(MediaListModule::class) - ->willReturn(new Collection()); - $tree = $this->createMock(Tree::class); + $tree + ->method('name') + ->willReturn('tree1'); $tree_service = $this->createMock(TreeService::class); $tree_service - ->expects(self::once()) + ->expects($this->once()) ->method('all') - ->willReturn(new Collection([$tree])); + ->willReturn(new Collection(['tree1' => $tree])); + + $module_service = $this->createMock(ModuleService::class); + $module_service + ->method('findByComponent') + ->with(ModuleListInterface::class, $tree, new GuestUser()) + ->willReturn(new Collection()); $handler = new RedirectMediaListPhp($module_service, $tree_service); @@ -98,18 +103,11 @@ class RedirectMediaListPhpTest extends TestCase public function testNoSuchTree(): void { - $module = $this->createMock(MediaListModule::class); - $module_service = $this->createMock(ModuleService::class); - $module_service - ->expects(self::once()) - ->method('findByInterface') - ->with(MediaListModule::class) - ->willReturn(new Collection([$module])); $tree_service = $this->createMock(TreeService::class); $tree_service - ->expects(self::once()) + ->expects($this->once()) ->method('all') ->willReturn(new Collection([])); diff --git a/tests/app/Http/RequestHandlers/RedirectMediaViewerPhpTest.php b/tests/app/Http/RequestHandlers/RedirectMediaViewerPhpTest.php index 269e361d66..6f9d79dafa 100644 --- a/tests/app/Http/RequestHandlers/RedirectMediaViewerPhpTest.php +++ b/tests/app/Http/RequestHandlers/RedirectMediaViewerPhpTest.php @@ -46,7 +46,7 @@ class RedirectMediaViewerPhpTest extends TestCase $tree_service = $this->createMock(TreeService::class); $tree_service - ->expects(self::once()) + ->expects($this->once()) ->method('all') ->willReturn(new Collection(['tree1' => $tree])); @@ -57,7 +57,7 @@ class RedirectMediaViewerPhpTest extends TestCase $media_factory = $this->createMock(MediaFactory::class); $media_factory - ->expects(self::once()) + ->expects($this->once()) ->method('make') ->with('X123', $tree) ->willReturn($media); @@ -66,10 +66,7 @@ class RedirectMediaViewerPhpTest extends TestCase $handler = new RedirectMediaViewerPhp($tree_service); - $request = self::createRequest( - RequestMethodInterface::METHOD_GET, - ['ged' => 'tree1', 'mid' => 'X123'] - ); + $request = self::createRequest(RequestMethodInterface::METHOD_GET, ['ged' => 'tree1', 'mid' => 'X123']); $response = $handler->handle($request); @@ -83,16 +80,13 @@ class RedirectMediaViewerPhpTest extends TestCase $tree_service = $this->createMock(TreeService::class); $tree_service - ->expects(self::once()) + ->expects($this->once()) ->method('all') - ->willReturn(new Collection([$tree])); + ->willReturn(new Collection(['tree1' => $tree])); $handler = new RedirectMediaViewerPhp($tree_service); - $request = self::createRequest( - RequestMethodInterface::METHOD_GET, - ['ged' => 'tree1', 'mid' => 'X123'] - ); + $request = self::createRequest(RequestMethodInterface::METHOD_GET, ['ged' => 'tree1', 'mid' => 'X123']); $this->expectException(HttpGoneException::class); @@ -103,16 +97,13 @@ class RedirectMediaViewerPhpTest extends TestCase { $tree_service = $this->createMock(TreeService::class); $tree_service - ->expects(self::once()) + ->expects($this->once()) ->method('all') ->willReturn(new Collection([])); $handler = new RedirectMediaViewerPhp($tree_service); - $request = self::createRequest( - RequestMethodInterface::METHOD_GET, - ['ged' => 'tree1', 'mid' => 'X123'] - ); + $request = self::createRequest(RequestMethodInterface::METHOD_GET, ['ged' => 'tree1', 'mid' => 'X123']); $this->expectException(HttpGoneException::class); diff --git a/tests/app/Http/RequestHandlers/RedirectModulePhpTest.php b/tests/app/Http/RequestHandlers/RedirectModulePhpTest.php index 9f508bd6ee..6b20c2abf7 100644 --- a/tests/app/Http/RequestHandlers/RedirectModulePhpTest.php +++ b/tests/app/Http/RequestHandlers/RedirectModulePhpTest.php @@ -25,6 +25,7 @@ use Fisharebest\Webtrees\Factories\IndividualFactory; use Fisharebest\Webtrees\Http\Exceptions\HttpGoneException; use Fisharebest\Webtrees\Individual; use Fisharebest\Webtrees\Module\InteractiveTreeModule; +use Fisharebest\Webtrees\Module\ModuleListInterface; use Fisharebest\Webtrees\Module\PedigreeMapModule; use Fisharebest\Webtrees\Registry; use Fisharebest\Webtrees\Services\ModuleService; @@ -48,7 +49,7 @@ class RedirectModulePhpTest extends TestCase $tree_service = $this->createMock(TreeService::class); $tree_service - ->expects(self::once()) + ->expects($this->once()) ->method('all') ->willReturn(new Collection(['tree1' => $tree])); @@ -56,7 +57,7 @@ class RedirectModulePhpTest extends TestCase $individual_factory = $this->createMock(IndividualFactory::class); $individual_factory - ->expects(self::once()) + ->expects($this->once()) ->method('make') ->with('X123', $tree) ->willReturn($individual); @@ -65,14 +66,14 @@ class RedirectModulePhpTest extends TestCase $module = $this->createMock(PedigreeMapModule::class); $module - ->expects(self::once()) + ->expects($this->once()) ->method('chartUrl') ->willReturn('https://www.example.com'); $module_service = $this->createMock(ModuleService::class); $module_service - ->expects(self::once()) - ->method('findByInterface') + ->expects($this->once()) + ->method('findByinterface') ->with(PedigreeMapModule::class) ->willReturn(new Collection([$module])); @@ -98,7 +99,7 @@ class RedirectModulePhpTest extends TestCase $tree_service = $this->createMock(TreeService::class); $tree_service - ->expects(self::once()) + ->expects($this->once()) ->method('all') ->willReturn(new Collection(['tree1' => $tree])); @@ -106,7 +107,7 @@ class RedirectModulePhpTest extends TestCase $individual_factory = $this->createMock(IndividualFactory::class); $individual_factory - ->expects(self::once()) + ->expects($this->once()) ->method('make') ->with('X123', $tree) ->willReturn($individual); @@ -115,13 +116,13 @@ class RedirectModulePhpTest extends TestCase $module = $this->createMock(InteractiveTreeModule::class); $module - ->expects(self::once()) + ->expects($this->once()) ->method('chartUrl') ->willReturn('https://www.example.com'); $module_service = $this->createMock(ModuleService::class); $module_service - ->expects(self::once()) + ->expects($this->once()) ->method('findByInterface') ->with(InteractiveTreeModule::class) ->willReturn(new Collection([$module])); @@ -144,7 +145,7 @@ class RedirectModulePhpTest extends TestCase $module_service = $this->createMock(ModuleService::class); $tree_service = $this->createMock(TreeService::class); $tree_service - ->expects(self::once()) + ->expects($this->once()) ->method('all') ->willReturn(new Collection([])); @@ -169,7 +170,7 @@ class RedirectModulePhpTest extends TestCase $individual_factory = $this->createMock(IndividualFactory::class); $individual_factory - ->expects(self::once()) + ->expects($this->once()) ->method('make') ->with('X123', $tree) ->willReturn(null); @@ -178,7 +179,7 @@ class RedirectModulePhpTest extends TestCase $module_service = $this->createMock(ModuleService::class); $tree_service = $this->createMock(TreeService::class); $tree_service - ->expects(self::once()) + ->expects($this->once()) ->method('all') ->willReturn(new Collection(['tree1' => $tree])); @@ -203,7 +204,7 @@ class RedirectModulePhpTest extends TestCase $tree_service = $this->createMock(TreeService::class); $tree_service - ->expects(self::once()) + ->expects($this->once()) ->method('all') ->willReturn(new Collection(['tree1' => $tree])); @@ -211,7 +212,7 @@ class RedirectModulePhpTest extends TestCase $individual_factory = $this->createMock(IndividualFactory::class); $individual_factory - ->expects(self::once()) + ->expects($this->once()) ->method('make') ->with('X123', $tree) ->willReturn($individual); @@ -220,7 +221,7 @@ class RedirectModulePhpTest extends TestCase $module_service = $this->createMock(ModuleService::class); $module_service - ->expects(self::once()) + ->expects($this->once()) ->method('findByInterface') ->with(PedigreeMapModule::class) ->willReturn(new Collection([])); @@ -246,7 +247,7 @@ class RedirectModulePhpTest extends TestCase $tree_service = $this->createMock(TreeService::class); $tree_service - ->expects(self::once()) + ->expects($this->once()) ->method('all') ->willReturn(new Collection(['tree1' => $tree])); @@ -254,7 +255,7 @@ class RedirectModulePhpTest extends TestCase $individual_factory = $this->createMock(IndividualFactory::class); $individual_factory - ->expects(self::once()) + ->expects($this->once()) ->method('make') ->with('X123', $tree) ->willReturn($individual); @@ -263,7 +264,7 @@ class RedirectModulePhpTest extends TestCase $module_service = $this->createMock(ModuleService::class); $module_service - ->expects(self::once()) + ->expects($this->once()) ->method('findByInterface') ->with(InteractiveTreeModule::class) ->willReturn(new Collection([])); diff --git a/tests/app/Http/RequestHandlers/RedirectNoteListPhpTest.php b/tests/app/Http/RequestHandlers/RedirectNoteListPhpTest.php index a550135eb9..1ed405d25b 100644 --- a/tests/app/Http/RequestHandlers/RedirectNoteListPhpTest.php +++ b/tests/app/Http/RequestHandlers/RedirectNoteListPhpTest.php @@ -21,7 +21,9 @@ namespace Fisharebest\Webtrees\Http\RequestHandlers; use Fig\Http\Message\RequestMethodInterface; use Fig\Http\Message\StatusCodeInterface; +use Fisharebest\Webtrees\GuestUser; use Fisharebest\Webtrees\Http\Exceptions\HttpGoneException; +use Fisharebest\Webtrees\Module\ModuleListInterface; use Fisharebest\Webtrees\Module\NoteListModule; use Fisharebest\Webtrees\Services\ModuleService; use Fisharebest\Webtrees\Services\TreeService; @@ -44,21 +46,21 @@ class RedirectNoteListPhpTest extends TestCase $tree_service = $this->createMock(TreeService::class); $tree_service - ->expects(self::once()) + ->expects($this->once()) ->method('all') ->willReturn(new Collection(['tree1' => $tree])); $module = $this->createMock(NoteListModule::class); $module - ->expects(self::once()) + ->expects($this->once()) ->method('listUrl') ->willReturn('https://www.example.com'); $module_service = $this->createMock(ModuleService::class); $module_service - ->expects(self::once()) - ->method('findByInterface') - ->with(NoteListModule::class) + ->expects($this->once()) + ->method('findByComponent') + ->with(ModuleListInterface::class) ->willReturn(new Collection([$module])); $handler = new RedirectNoteListPhp($module_service, $tree_service); @@ -73,19 +75,22 @@ class RedirectNoteListPhpTest extends TestCase public function testModuleDisabled(): void { - $module_service = $this->createMock(ModuleService::class); - $module_service - ->expects(self::once())->method('findByInterface') - ->with(NoteListModule::class) - ->willReturn(new Collection()); - $tree = $this->createMock(Tree::class); + $tree + ->method('name') + ->willReturn('tree1'); $tree_service = $this->createMock(TreeService::class); $tree_service - ->expects(self::once()) + ->expects($this->once()) ->method('all') - ->willReturn(new Collection([$tree])); + ->willReturn(new Collection(['tree1' => $tree])); + + $module_service = $this->createMock(ModuleService::class); + $module_service + ->method('findByComponent') + ->with(ModuleListInterface::class, $tree, new GuestUser()) + ->willReturn(new Collection()); $handler = new RedirectNoteListPhp($module_service, $tree_service); @@ -98,18 +103,11 @@ class RedirectNoteListPhpTest extends TestCase public function testNoSuchTree(): void { - $module = $this->createMock(NoteListModule::class); - $module_service = $this->createMock(ModuleService::class); - $module_service - ->expects(self::once()) - ->method('findByInterface') - ->with(NoteListModule::class) - ->willReturn(new Collection([$module])); $tree_service = $this->createMock(TreeService::class); $tree_service - ->expects(self::once()) + ->expects($this->once()) ->method('all') ->willReturn(new Collection([])); diff --git a/tests/app/Http/RequestHandlers/RedirectNotePhpTest.php b/tests/app/Http/RequestHandlers/RedirectNotePhpTest.php index 3e4b3ad582..fbf637e521 100644 --- a/tests/app/Http/RequestHandlers/RedirectNotePhpTest.php +++ b/tests/app/Http/RequestHandlers/RedirectNotePhpTest.php @@ -46,7 +46,7 @@ class RedirectNotePhpTest extends TestCase $tree_service = $this->createMock(TreeService::class); $tree_service - ->expects(self::once()) + ->expects($this->once()) ->method('all') ->willReturn(new Collection(['tree1' => $tree])); @@ -57,7 +57,7 @@ class RedirectNotePhpTest extends TestCase $note_factory = $this->createMock(NoteFactory::class); $note_factory - ->expects(self::once()) + ->expects($this->once()) ->method('make') ->with('X123', $tree) ->willReturn($note); @@ -66,10 +66,7 @@ class RedirectNotePhpTest extends TestCase $handler = new RedirectNotePhp($tree_service); - $request = self::createRequest( - RequestMethodInterface::METHOD_GET, - ['ged' => 'tree1', 'nid' => 'X123'] - ); + $request = self::createRequest(RequestMethodInterface::METHOD_GET, ['ged' => 'tree1', 'nid' => 'X123']); $response = $handler->handle($request); @@ -83,16 +80,13 @@ class RedirectNotePhpTest extends TestCase $tree_service = $this->createMock(TreeService::class); $tree_service - ->expects(self::once()) + ->expects($this->once()) ->method('all') - ->willReturn(new Collection([$tree])); + ->willReturn(new Collection(['tree1' => $tree])); $handler = new RedirectNotePhp($tree_service); - $request = self::createRequest( - RequestMethodInterface::METHOD_GET, - ['ged' => 'tree1', 'nid' => 'X123'] - ); + $request = self::createRequest(RequestMethodInterface::METHOD_GET, ['ged' => 'tree1', 'nid' => 'X123']); $this->expectException(HttpGoneException::class); diff --git a/tests/app/Http/RequestHandlers/RedirectPedigreePhpTest.php b/tests/app/Http/RequestHandlers/RedirectPedigreePhpTest.php index 356fd787cd..bca8b0268f 100644 --- a/tests/app/Http/RequestHandlers/RedirectPedigreePhpTest.php +++ b/tests/app/Http/RequestHandlers/RedirectPedigreePhpTest.php @@ -22,8 +22,10 @@ namespace Fisharebest\Webtrees\Http\RequestHandlers; use Fig\Http\Message\RequestMethodInterface; use Fig\Http\Message\StatusCodeInterface; use Fisharebest\Webtrees\Factories\IndividualFactory; +use Fisharebest\Webtrees\GuestUser; use Fisharebest\Webtrees\Http\Exceptions\HttpGoneException; use Fisharebest\Webtrees\Individual; +use Fisharebest\Webtrees\Module\ModuleChartInterface; use Fisharebest\Webtrees\Module\PedigreeChartModule; use Fisharebest\Webtrees\Registry; use Fisharebest\Webtrees\Services\ModuleService; @@ -47,7 +49,7 @@ class RedirectPedigreePhpTest extends TestCase $tree_service = $this->createMock(TreeService::class); $tree_service - ->expects(self::once()) + ->expects($this->once()) ->method('all') ->willReturn(new Collection(['tree1' => $tree])); @@ -55,7 +57,7 @@ class RedirectPedigreePhpTest extends TestCase $individual_factory = $this->createMock(IndividualFactory::class); $individual_factory - ->expects(self::once()) + ->expects($this->once()) ->method('make') ->with('X123', $tree) ->willReturn($individual); @@ -64,23 +66,20 @@ class RedirectPedigreePhpTest extends TestCase $module = $this->createMock(PedigreeChartModule::class); $module - ->expects(self::once()) + ->expects($this->once()) ->method('chartUrl') ->willReturn('https://www.example.com'); $module_service = $this->createMock(ModuleService::class); $module_service - ->expects(self::once()) - ->method('findByInterface') - ->with(PedigreeChartModule::class) + ->expects($this->once()) + ->method('findByComponent') + ->with(ModuleChartInterface::class) ->willReturn(new Collection([$module])); $handler = new RedirectPedigreePhp($module_service, $tree_service); - $request = self::createRequest( - RequestMethodInterface::METHOD_GET, - ['ged' => 'tree1', 'rootid' => 'X123'] - ); + $request = self::createRequest(RequestMethodInterface::METHOD_GET, ['ged' => 'tree1', 'rootid' => 'X123']); $response = $handler->handle($request); @@ -90,26 +89,26 @@ class RedirectPedigreePhpTest extends TestCase public function testModuleDisabled(): void { - $module_service = $this->createMock(ModuleService::class); - $module_service - ->expects(self::once())->method('findByInterface') - ->with(PedigreeChartModule::class) - ->willReturn(new Collection()); - $tree = $this->createMock(Tree::class); + $tree + ->method('name') + ->willReturn('tree1'); $tree_service = $this->createMock(TreeService::class); $tree_service - ->expects(self::once()) + ->expects($this->once()) ->method('all') - ->willReturn(new Collection([$tree])); + ->willReturn(new Collection(['tree1' => $tree])); + + $module_service = $this->createMock(ModuleService::class); + $module_service + ->method('findByComponent') + ->with(ModuleChartInterface::class, $tree, new GuestUser()) + ->willReturn(new Collection()); $handler = new RedirectPedigreePhp($module_service, $tree_service); - $request = self::createRequest( - RequestMethodInterface::METHOD_GET, - ['ged' => 'tree1', 'rootid' => 'X123'] - ); + $request = self::createRequest(RequestMethodInterface::METHOD_GET, ['ged' => 'tree1', 'rootid' => 'X123']); $this->expectException(HttpGoneException::class); @@ -118,27 +117,17 @@ class RedirectPedigreePhpTest extends TestCase public function testNoSuchTree(): void { - $module = $this->createMock(PedigreeChartModule::class); - $module_service = $this->createMock(ModuleService::class); - $module_service - ->expects(self::once()) - ->method('findByInterface') - ->with(PedigreeChartModule::class) - ->willReturn(new Collection([$module])); $tree_service = $this->createMock(TreeService::class); $tree_service - ->expects(self::once()) + ->expects($this->once()) ->method('all') ->willReturn(new Collection([])); $handler = new RedirectPedigreePhp($module_service, $tree_service); - $request = self::createRequest( - RequestMethodInterface::METHOD_GET, - ['ged' => 'tree1', 'rootid' => 'X123'] - ); + $request = self::createRequest(RequestMethodInterface::METHOD_GET, ['ged' => 'tree1', 'rootid' => 'X123']); $this->expectException(HttpGoneException::class); diff --git a/tests/app/Http/RequestHandlers/RedirectPlaceListPhpTest.php b/tests/app/Http/RequestHandlers/RedirectPlaceListPhpTest.php index 5afda3237b..4c0c3a15fa 100644 --- a/tests/app/Http/RequestHandlers/RedirectPlaceListPhpTest.php +++ b/tests/app/Http/RequestHandlers/RedirectPlaceListPhpTest.php @@ -21,7 +21,9 @@ namespace Fisharebest\Webtrees\Http\RequestHandlers; use Fig\Http\Message\RequestMethodInterface; use Fig\Http\Message\StatusCodeInterface; +use Fisharebest\Webtrees\GuestUser; use Fisharebest\Webtrees\Http\Exceptions\HttpGoneException; +use Fisharebest\Webtrees\Module\ModuleListInterface; use Fisharebest\Webtrees\Module\PlaceHierarchyListModule; use Fisharebest\Webtrees\Services\ModuleService; use Fisharebest\Webtrees\Services\TreeService; @@ -44,21 +46,21 @@ class RedirectPlaceListPhpTest extends TestCase $tree_service = $this->createMock(TreeService::class); $tree_service - ->expects(self::once()) + ->expects($this->once()) ->method('all') ->willReturn(new Collection(['tree1' => $tree])); $module = $this->createMock(PlaceHierarchyListModule::class); $module - ->expects(self::once()) + ->expects($this->once()) ->method('listUrl') ->willReturn('https://www.example.com'); $module_service = $this->createMock(ModuleService::class); $module_service - ->expects(self::once()) - ->method('findByInterface') - ->with(PlaceHierarchyListModule::class) + ->expects($this->once()) + ->method('findByComponent') + ->with(ModuleListInterface::class) ->willReturn(new Collection([$module])); $handler = new RedirectPlaceListPhp($module_service, $tree_service); @@ -73,19 +75,22 @@ class RedirectPlaceListPhpTest extends TestCase public function testModuleDisabled(): void { - $module_service = $this->createMock(ModuleService::class); - $module_service - ->expects(self::once())->method('findByInterface') - ->with(PlaceHierarchyListModule::class) - ->willReturn(new Collection()); - $tree = $this->createMock(Tree::class); + $tree + ->method('name') + ->willReturn('tree1'); $tree_service = $this->createMock(TreeService::class); $tree_service - ->expects(self::once()) + ->expects($this->once()) ->method('all') - ->willReturn(new Collection([$tree])); + ->willReturn(new Collection(['tree1' => $tree])); + + $module_service = $this->createMock(ModuleService::class); + $module_service + ->method('findByComponent') + ->with(ModuleListInterface::class, $tree, new GuestUser()) + ->willReturn(new Collection()); $handler = new RedirectPlaceListPhp($module_service, $tree_service); @@ -98,18 +103,11 @@ class RedirectPlaceListPhpTest extends TestCase public function testNoSuchTree(): void { - $module = $this->createMock(PlaceHierarchyListModule::class); - $module_service = $this->createMock(ModuleService::class); - $module_service - ->expects(self::once()) - ->method('findByInterface') - ->with(PlaceHierarchyListModule::class) - ->willReturn(new Collection([$module])); $tree_service = $this->createMock(TreeService::class); $tree_service - ->expects(self::once()) + ->expects($this->once()) ->method('all') ->willReturn(new Collection([])); diff --git a/tests/app/Http/RequestHandlers/RedirectRelationshipPhpTest.php b/tests/app/Http/RequestHandlers/RedirectRelationshipPhpTest.php index d7154afa35..9d58322eb7 100644 --- a/tests/app/Http/RequestHandlers/RedirectRelationshipPhpTest.php +++ b/tests/app/Http/RequestHandlers/RedirectRelationshipPhpTest.php @@ -22,8 +22,11 @@ namespace Fisharebest\Webtrees\Http\RequestHandlers; use Fig\Http\Message\RequestMethodInterface; use Fig\Http\Message\StatusCodeInterface; use Fisharebest\Webtrees\Factories\IndividualFactory; +use Fisharebest\Webtrees\GuestUser; use Fisharebest\Webtrees\Http\Exceptions\HttpGoneException; use Fisharebest\Webtrees\Individual; +use Fisharebest\Webtrees\Module\ModuleChartInterface; +use Fisharebest\Webtrees\Module\ModuleListInterface; use Fisharebest\Webtrees\Module\RelationshipsChartModule; use Fisharebest\Webtrees\Registry; use Fisharebest\Webtrees\Services\ModuleService; @@ -47,7 +50,7 @@ class RedirectRelationshipPhpTest extends TestCase $tree_service = $this->createMock(TreeService::class); $tree_service - ->expects(self::once()) + ->expects($this->once()) ->method('all') ->willReturn(new Collection(['tree1' => $tree])); @@ -55,7 +58,7 @@ class RedirectRelationshipPhpTest extends TestCase $individual_factory = $this->createMock(IndividualFactory::class); $individual_factory - ->expects(self::once()) + ->expects($this->once()) ->method('make') ->with('X123', $tree) ->willReturn($individual); @@ -64,23 +67,20 @@ class RedirectRelationshipPhpTest extends TestCase $module = $this->createMock(RelationshipsChartModule::class); $module - ->expects(self::once()) + ->expects($this->once()) ->method('chartUrl') ->willReturn('https://www.example.com'); $module_service = $this->createMock(ModuleService::class); $module_service - ->expects(self::once()) - ->method('findByInterface') - ->with(RelationshipsChartModule::class) + ->expects($this->once()) + ->method('findByComponent') + ->with(ModuleChartInterface::class) ->willReturn(new Collection([$module])); $handler = new RedirectRelationshipPhp($module_service, $tree_service); - $request = self::createRequest( - RequestMethodInterface::METHOD_GET, - ['ged' => 'tree1', 'pid1' => 'X123'] - ); + $request = self::createRequest(RequestMethodInterface::METHOD_GET, ['ged' => 'tree1', 'pid1' => 'X123']); $response = $handler->handle($request); @@ -90,26 +90,26 @@ class RedirectRelationshipPhpTest extends TestCase public function testModuleDisabled(): void { - $module_service = $this->createMock(ModuleService::class); - $module_service - ->expects(self::once())->method('findByInterface') - ->with(RelationshipsChartModule::class) - ->willReturn(new Collection()); - $tree = $this->createMock(Tree::class); + $tree + ->method('name') + ->willReturn('tree1'); $tree_service = $this->createMock(TreeService::class); $tree_service - ->expects(self::once()) + ->expects($this->once()) ->method('all') - ->willReturn(new Collection([$tree])); + ->willReturn(new Collection(['tree1' => $tree])); + + $module_service = $this->createMock(ModuleService::class); + $module_service + ->method('findByComponent') + ->with(ModuleChartInterface::class, $tree, new GuestUser()) + ->willReturn(new Collection()); $handler = new RedirectRelationshipPhp($module_service, $tree_service); - $request = self::createRequest( - RequestMethodInterface::METHOD_GET, - ['ged' => 'tree1', 'pid1' => 'X123'] - ); + $request = self::createRequest(RequestMethodInterface::METHOD_GET, ['ged' => 'tree1', 'pid1' => 'X123']); $this->expectException(HttpGoneException::class); @@ -118,27 +118,17 @@ class RedirectRelationshipPhpTest extends TestCase public function testNoSuchTree(): void { - $module = $this->createMock(RelationshipsChartModule::class); - $module_service = $this->createMock(ModuleService::class); - $module_service - ->expects(self::once()) - ->method('findByInterface') - ->with(RelationshipsChartModule::class) - ->willReturn(new Collection([$module])); $tree_service = $this->createMock(TreeService::class); $tree_service - ->expects(self::once()) + ->expects($this->once()) ->method('all') ->willReturn(new Collection([])); $handler = new RedirectRelationshipPhp($module_service, $tree_service); - $request = self::createRequest( - RequestMethodInterface::METHOD_GET, - ['ged' => 'tree1', 'pid1' => 'X123'] - ); + $request = self::createRequest(RequestMethodInterface::METHOD_GET, ['ged' => 'tree1', 'pid1' => 'X123']); $this->expectException(HttpGoneException::class); diff --git a/tests/app/Http/RequestHandlers/RedirectRepoListPhpTest.php b/tests/app/Http/RequestHandlers/RedirectRepoListPhpTest.php index 10a7c52e44..4831af8782 100644 --- a/tests/app/Http/RequestHandlers/RedirectRepoListPhpTest.php +++ b/tests/app/Http/RequestHandlers/RedirectRepoListPhpTest.php @@ -21,7 +21,9 @@ namespace Fisharebest\Webtrees\Http\RequestHandlers; use Fig\Http\Message\RequestMethodInterface; use Fig\Http\Message\StatusCodeInterface; +use Fisharebest\Webtrees\GuestUser; use Fisharebest\Webtrees\Http\Exceptions\HttpGoneException; +use Fisharebest\Webtrees\Module\ModuleListInterface; use Fisharebest\Webtrees\Module\RepositoryListModule; use Fisharebest\Webtrees\Services\ModuleService; use Fisharebest\Webtrees\Services\TreeService; @@ -44,21 +46,21 @@ class RedirectRepoListPhpTest extends TestCase $tree_service = $this->createMock(TreeService::class); $tree_service - ->expects(self::once()) + ->expects($this->once()) ->method('all') ->willReturn(new Collection(['tree1' => $tree])); $module = $this->createMock(RepositoryListModule::class); $module - ->expects(self::once()) + ->expects($this->once()) ->method('listUrl') ->willReturn('https://www.example.com'); $module_service = $this->createMock(ModuleService::class); $module_service - ->expects(self::once()) - ->method('findByInterface') - ->with(RepositoryListModule::class) + ->expects($this->once()) + ->method('findByComponent') + ->with(ModuleListInterface::class) ->willReturn(new Collection([$module])); $handler = new RedirectRepoListPhp($module_service, $tree_service); @@ -73,19 +75,22 @@ class RedirectRepoListPhpTest extends TestCase public function testModuleDisabled(): void { - $module_service = $this->createMock(ModuleService::class); - $module_service - ->expects(self::once())->method('findByInterface') - ->with(RepositoryListModule::class) - ->willReturn(new Collection()); - $tree = $this->createMock(Tree::class); + $tree + ->method('name') + ->willReturn('tree1'); $tree_service = $this->createMock(TreeService::class); $tree_service - ->expects(self::once()) + ->expects($this->once()) ->method('all') - ->willReturn(new Collection([$tree])); + ->willReturn(new Collection(['tree1' => $tree])); + + $module_service = $this->createMock(ModuleService::class); + $module_service + ->method('findByComponent') + ->with(ModuleListInterface::class, $tree, new GuestUser()) + ->willReturn(new Collection()); $handler = new RedirectRepoListPhp($module_service, $tree_service); @@ -98,18 +103,11 @@ class RedirectRepoListPhpTest extends TestCase public function testNoSuchTree(): void { - $module = $this->createMock(RepositoryListModule::class); - $module_service = $this->createMock(ModuleService::class); - $module_service - ->expects(self::once()) - ->method('findByInterface') - ->with(RepositoryListModule::class) - ->willReturn(new Collection([$module])); $tree_service = $this->createMock(TreeService::class); $tree_service - ->expects(self::once()) + ->expects($this->once()) ->method('all') ->willReturn(new Collection([])); diff --git a/tests/app/Http/RequestHandlers/RedirectReportEnginePhpTest.php b/tests/app/Http/RequestHandlers/RedirectReportEnginePhpTest.php index 399c9b4f4b..30ef502ed0 100644 --- a/tests/app/Http/RequestHandlers/RedirectReportEnginePhpTest.php +++ b/tests/app/Http/RequestHandlers/RedirectReportEnginePhpTest.php @@ -42,7 +42,7 @@ class RedirectReportEnginePhpTest extends TestCase $tree_service = $this->createMock(TreeService::class); $tree_service - ->expects(self::once()) + ->expects($this->once()) ->method('all') ->willReturn(new Collection(['tree1' => $tree])); @@ -69,7 +69,7 @@ class RedirectReportEnginePhpTest extends TestCase { $tree_service = $this->createMock(TreeService::class); $tree_service - ->expects(self::once()) + ->expects($this->once()) ->method('all') ->willReturn(new Collection([])); diff --git a/tests/app/Http/RequestHandlers/RedirectRepositoryPhpTest.php b/tests/app/Http/RequestHandlers/RedirectRepositoryPhpTest.php index bfd2450663..f1aebd2e3e 100644 --- a/tests/app/Http/RequestHandlers/RedirectRepositoryPhpTest.php +++ b/tests/app/Http/RequestHandlers/RedirectRepositoryPhpTest.php @@ -46,7 +46,7 @@ class RedirectRepositoryPhpTest extends TestCase $tree_service = $this->createMock(TreeService::class); $tree_service - ->expects(self::once()) + ->expects($this->once()) ->method('all') ->willReturn(new Collection(['tree1' => $tree])); @@ -57,7 +57,7 @@ class RedirectRepositoryPhpTest extends TestCase $repository_factory = $this->createMock(RepositoryFactory::class); $repository_factory - ->expects(self::once()) + ->expects($this->once()) ->method('make') ->with('X123', $tree) ->willReturn($repository); @@ -66,10 +66,7 @@ class RedirectRepositoryPhpTest extends TestCase $handler = new RedirectRepositoryPhp($tree_service); - $request = self::createRequest( - RequestMethodInterface::METHOD_GET, - ['ged' => 'tree1', 'rid' => 'X123'] - ); + $request = self::createRequest(RequestMethodInterface::METHOD_GET, ['ged' => 'tree1', 'rid' => 'X123']); $response = $handler->handle($request); @@ -83,16 +80,13 @@ class RedirectRepositoryPhpTest extends TestCase $tree_service = $this->createMock(TreeService::class); $tree_service - ->expects(self::once()) + ->expects($this->once()) ->method('all') - ->willReturn(new Collection([$tree])); + ->willReturn(new Collection(['tree1' => $tree])); $handler = new RedirectRepositoryPhp($tree_service); - $request = self::createRequest( - RequestMethodInterface::METHOD_GET, - ['ged' => 'tree1', 'rid' => 'X123'] - ); + $request = self::createRequest(RequestMethodInterface::METHOD_GET, ['ged' => 'tree1', 'rid' => 'X123']); $this->expectException(HttpGoneException::class); diff --git a/tests/app/Http/RequestHandlers/RedirectSourceListPhpTest.php b/tests/app/Http/RequestHandlers/RedirectSourceListPhpTest.php index 5bcc1de965..dd4b5011a2 100644 --- a/tests/app/Http/RequestHandlers/RedirectSourceListPhpTest.php +++ b/tests/app/Http/RequestHandlers/RedirectSourceListPhpTest.php @@ -21,7 +21,9 @@ namespace Fisharebest\Webtrees\Http\RequestHandlers; use Fig\Http\Message\RequestMethodInterface; use Fig\Http\Message\StatusCodeInterface; +use Fisharebest\Webtrees\GuestUser; use Fisharebest\Webtrees\Http\Exceptions\HttpGoneException; +use Fisharebest\Webtrees\Module\ModuleListInterface; use Fisharebest\Webtrees\Module\SourceListModule; use Fisharebest\Webtrees\Services\ModuleService; use Fisharebest\Webtrees\Services\TreeService; @@ -44,21 +46,21 @@ class RedirectSourceListPhpTest extends TestCase $tree_service = $this->createMock(TreeService::class); $tree_service - ->expects(self::once()) + ->expects($this->once()) ->method('all') ->willReturn(new Collection(['tree1' => $tree])); $module = $this->createMock(SourceListModule::class); $module - ->expects(self::once()) + ->expects($this->once()) ->method('listUrl') ->willReturn('https://www.example.com'); $module_service = $this->createMock(ModuleService::class); $module_service - ->expects(self::once()) - ->method('findByInterface') - ->with(SourceListModule::class) + ->expects($this->once()) + ->method('findByComponent') + ->with(ModuleListInterface::class) ->willReturn(new Collection([$module])); $handler = new RedirectSourceListPhp($module_service, $tree_service); @@ -73,19 +75,22 @@ class RedirectSourceListPhpTest extends TestCase public function testModuleDisabled(): void { - $module_service = $this->createMock(ModuleService::class); - $module_service - ->expects(self::once())->method('findByInterface') - ->with(SourceListModule::class) - ->willReturn(new Collection()); - $tree = $this->createMock(Tree::class); + $tree + ->method('name') + ->willReturn('tree1'); $tree_service = $this->createMock(TreeService::class); $tree_service - ->expects(self::once()) + ->expects($this->once()) ->method('all') - ->willReturn(new Collection([$tree])); + ->willReturn(new Collection(['tree1' => $tree])); + + $module_service = $this->createMock(ModuleService::class); + $module_service + ->method('findByComponent') + ->with(ModuleListInterface::class, $tree, new GuestUser()) + ->willReturn(new Collection()); $handler = new RedirectSourceListPhp($module_service, $tree_service); @@ -98,18 +103,11 @@ class RedirectSourceListPhpTest extends TestCase public function testNoSuchTree(): void { - $module = $this->createMock(SourceListModule::class); - $module_service = $this->createMock(ModuleService::class); - $module_service - ->expects(self::once()) - ->method('findByInterface') - ->with(SourceListModule::class) - ->willReturn(new Collection([$module])); $tree_service = $this->createMock(TreeService::class); $tree_service - ->expects(self::once()) + ->expects($this->once()) ->method('all') ->willReturn(new Collection([])); diff --git a/tests/app/Http/RequestHandlers/RedirectSourcePhpTest.php b/tests/app/Http/RequestHandlers/RedirectSourcePhpTest.php index 4dc2b8c94f..9f565c3f02 100644 --- a/tests/app/Http/RequestHandlers/RedirectSourcePhpTest.php +++ b/tests/app/Http/RequestHandlers/RedirectSourcePhpTest.php @@ -46,7 +46,7 @@ class RedirectSourcePhpTest extends TestCase $tree_service = $this->createMock(TreeService::class); $tree_service - ->expects(self::once()) + ->expects($this->once()) ->method('all') ->willReturn(new Collection(['tree1' => $tree])); @@ -57,7 +57,7 @@ class RedirectSourcePhpTest extends TestCase $source_factory = $this->createMock(SourceFactory::class); $source_factory - ->expects(self::once()) + ->expects($this->once()) ->method('make') ->with('X123', $tree) ->willReturn($source); @@ -66,10 +66,7 @@ class RedirectSourcePhpTest extends TestCase $handler = new RedirectSourcePhp($tree_service); - $request = self::createRequest( - RequestMethodInterface::METHOD_GET, - ['ged' => 'tree1', 'sid' => 'X123'] - ); + $request = self::createRequest(RequestMethodInterface::METHOD_GET, ['ged' => 'tree1', 'sid' => 'X123']); $response = $handler->handle($request); @@ -83,16 +80,13 @@ class RedirectSourcePhpTest extends TestCase $tree_service = $this->createMock(TreeService::class); $tree_service - ->expects(self::once()) + ->expects($this->once()) ->method('all') - ->willReturn(new Collection([$tree])); + ->willReturn(new Collection(['tree1' => $tree])); $handler = new RedirectSourcePhp($tree_service); - $request = self::createRequest( - RequestMethodInterface::METHOD_GET, - ['ged' => 'tree1', 'sid' => 'X123'] - ); + $request = self::createRequest(RequestMethodInterface::METHOD_GET, ['ged' => 'tree1', 'sid' => 'X123']); $this->expectException(HttpGoneException::class); diff --git a/tests/app/Http/RequestHandlers/RedirectStatisticsPhpTest.php b/tests/app/Http/RequestHandlers/RedirectStatisticsPhpTest.php index 14aa742f00..305cbe8144 100644 --- a/tests/app/Http/RequestHandlers/RedirectStatisticsPhpTest.php +++ b/tests/app/Http/RequestHandlers/RedirectStatisticsPhpTest.php @@ -21,7 +21,10 @@ namespace Fisharebest\Webtrees\Http\RequestHandlers; use Fig\Http\Message\RequestMethodInterface; use Fig\Http\Message\StatusCodeInterface; +use Fisharebest\Webtrees\GuestUser; use Fisharebest\Webtrees\Http\Exceptions\HttpGoneException; +use Fisharebest\Webtrees\Module\ModuleChartInterface; +use Fisharebest\Webtrees\Module\ModuleListInterface; use Fisharebest\Webtrees\Module\StatisticsChartModule; use Fisharebest\Webtrees\Services\ModuleService; use Fisharebest\Webtrees\Services\TreeService; @@ -44,21 +47,21 @@ class RedirectStatisticsPhpTest extends TestCase $tree_service = $this->createMock(TreeService::class); $tree_service - ->expects(self::once()) + ->expects($this->once()) ->method('all') ->willReturn(new Collection(['tree1' => $tree])); $module = $this->createMock(StatisticsChartModule::class); $module - ->expects(self::once()) + ->expects($this->once()) ->method('chartUrl') ->willReturn('https://www.example.com'); $module_service = $this->createMock(ModuleService::class); $module_service - ->expects(self::once()) - ->method('findByInterface') - ->with(StatisticsChartModule::class) + ->expects($this->once()) + ->method('findByComponent') + ->with(ModuleChartInterface::class) ->willReturn(new Collection([$module])); $handler = new RedirectStatisticsPhp($module_service, $tree_service); @@ -73,19 +76,22 @@ class RedirectStatisticsPhpTest extends TestCase public function testModuleDisabled(): void { - $module_service = $this->createMock(ModuleService::class); - $module_service - ->expects(self::once())->method('findByInterface') - ->with(StatisticsChartModule::class) - ->willReturn(new Collection()); - $tree = $this->createMock(Tree::class); + $tree + ->method('name') + ->willReturn('tree1'); $tree_service = $this->createMock(TreeService::class); $tree_service - ->expects(self::once()) + ->expects($this->once()) ->method('all') - ->willReturn(new Collection([$tree])); + ->willReturn(new Collection(['tree1' => $tree])); + + $module_service = $this->createMock(ModuleService::class); + $module_service + ->method('findByComponent') + ->with(ModuleChartInterface::class, $tree, new GuestUser()) + ->willReturn(new Collection()); $handler = new RedirectStatisticsPhp($module_service, $tree_service); @@ -98,18 +104,11 @@ class RedirectStatisticsPhpTest extends TestCase public function testNoSuchTree(): void { - $module = $this->createMock(StatisticsChartModule::class); - $module_service = $this->createMock(ModuleService::class); - $module_service - ->expects(self::once()) - ->method('findByInterface') - ->with(StatisticsChartModule::class) - ->willReturn(new Collection([$module])); $tree_service = $this->createMock(TreeService::class); $tree_service - ->expects(self::once()) + ->expects($this->once()) ->method('all') ->willReturn(new Collection([])); diff --git a/tests/app/Http/RequestHandlers/RedirectTimeLinePhpTest.php b/tests/app/Http/RequestHandlers/RedirectTimeLinePhpTest.php index ee3440622b..e8fef96218 100644 --- a/tests/app/Http/RequestHandlers/RedirectTimeLinePhpTest.php +++ b/tests/app/Http/RequestHandlers/RedirectTimeLinePhpTest.php @@ -22,8 +22,11 @@ namespace Fisharebest\Webtrees\Http\RequestHandlers; use Fig\Http\Message\RequestMethodInterface; use Fig\Http\Message\StatusCodeInterface; use Fisharebest\Webtrees\Factories\IndividualFactory; +use Fisharebest\Webtrees\GuestUser; use Fisharebest\Webtrees\Http\Exceptions\HttpGoneException; use Fisharebest\Webtrees\Individual; +use Fisharebest\Webtrees\Module\ModuleChartInterface; +use Fisharebest\Webtrees\Module\ModuleListInterface; use Fisharebest\Webtrees\Module\TimelineChartModule; use Fisharebest\Webtrees\Registry; use Fisharebest\Webtrees\Services\ModuleService; @@ -47,7 +50,7 @@ class RedirectTimeLinePhpTest extends TestCase $tree_service = $this->createMock(TreeService::class); $tree_service - ->expects(self::once()) + ->expects($this->once()) ->method('all') ->willReturn(new Collection(['tree1' => $tree])); @@ -55,7 +58,7 @@ class RedirectTimeLinePhpTest extends TestCase $individual_factory = $this->createMock(IndividualFactory::class); $individual_factory - ->expects(self::once()) + ->expects($this->once()) ->method('make') ->with('X123', $tree) ->willReturn($individual); @@ -64,23 +67,20 @@ class RedirectTimeLinePhpTest extends TestCase $module = $this->createMock(TimelineChartModule::class); $module - ->expects(self::once()) + ->expects($this->once()) ->method('chartUrl') ->willReturn('https://www.example.com'); $module_service = $this->createMock(ModuleService::class); $module_service - ->expects(self::once()) - ->method('findByInterface') - ->with(TimelineChartModule::class) + ->expects($this->once()) + ->method('findByComponent') + ->with(ModuleChartInterface::class) ->willReturn(new Collection([$module])); $handler = new RedirectTimeLinePhp($module_service, $tree_service); - $request = self::createRequest( - RequestMethodInterface::METHOD_GET, - ['ged' => 'tree1', 'pids' => ['X123']] - ); + $request = self::createRequest(RequestMethodInterface::METHOD_GET, ['ged' => 'tree1', 'pids' => ['X123']]); $response = $handler->handle($request); @@ -90,26 +90,26 @@ class RedirectTimeLinePhpTest extends TestCase public function testModuleDisabled(): void { - $module_service = $this->createMock(ModuleService::class); - $module_service - ->expects(self::once())->method('findByInterface') - ->with(TimelineChartModule::class) - ->willReturn(new Collection()); - $tree = $this->createMock(Tree::class); + $tree + ->method('name') + ->willReturn('tree1'); $tree_service = $this->createMock(TreeService::class); $tree_service - ->expects(self::once()) + ->expects($this->once()) ->method('all') - ->willReturn(new Collection([$tree])); + ->willReturn(new Collection(['tree1' => $tree])); + + $module_service = $this->createMock(ModuleService::class); + $module_service + ->method('findByComponent') + ->with(ModuleChartInterface::class, $tree, new GuestUser()) + ->willReturn(new Collection()); $handler = new RedirectTimeLinePhp($module_service, $tree_service); - $request = self::createRequest( - RequestMethodInterface::METHOD_GET, - ['ged' => 'tree1', 'pids' => ['X123']] - ); + $request = self::createRequest(RequestMethodInterface::METHOD_GET, ['ged' => 'tree1', 'pids' => ['X123']]); $this->expectException(HttpGoneException::class); @@ -118,18 +118,11 @@ class RedirectTimeLinePhpTest extends TestCase public function testNoSuchTree(): void { - $module = $this->createMock(TimelineChartModule::class); - $module_service = $this->createMock(ModuleService::class); - $module_service - ->expects(self::once()) - ->method('findByInterface') - ->with(TimelineChartModule::class) - ->willReturn(new Collection([$module])); $tree_service = $this->createMock(TreeService::class); $tree_service - ->expects(self::once()) + ->expects($this->once()) ->method('all') ->willReturn(new Collection([])); diff --git a/tests/app/Http/RequestHandlers/SelectThemeTest.php b/tests/app/Http/RequestHandlers/SelectThemeTest.php index 19f15261aa..d96ee3bf07 100644 --- a/tests/app/Http/RequestHandlers/SelectThemeTest.php +++ b/tests/app/Http/RequestHandlers/SelectThemeTest.php @@ -31,7 +31,7 @@ class SelectThemeTest extends TestCase public function testSelectThemeForGuest(): void { $user = $this->createMock(GuestUser::class); - $user->expects(self::once())->method('setPreference')->with('theme', 'FOO'); + $user->expects($this->once())->method('setPreference')->with('theme', 'FOO'); $request = self::createRequest() ->withAttribute('theme', 'FOO') @@ -46,7 +46,7 @@ class SelectThemeTest extends TestCase public function testSelectThemeForUser(): void { $user = $this->createMock(User::class); - $user->expects(self::once())->method('setPreference')->with('theme', 'FOO'); + $user->expects($this->once())->method('setPreference')->with('theme', 'FOO'); $request = self::createRequest() ->withAttribute('user', $user) |
