16fcafd02SGreg Roach<?php 26fcafd02SGreg Roach 36fcafd02SGreg Roach/** 46fcafd02SGreg Roach * webtrees: online genealogy 56fcafd02SGreg Roach * Copyright (C) 2021 webtrees development team 66fcafd02SGreg Roach * This program is free software: you can redistribute it and/or modify 76fcafd02SGreg Roach * it under the terms of the GNU General Public License as published by 86fcafd02SGreg Roach * the Free Software Foundation, either version 3 of the License, or 96fcafd02SGreg Roach * (at your option) any later version. 106fcafd02SGreg Roach * This program is distributed in the hope that it will be useful, 116fcafd02SGreg Roach * but WITHOUT ANY WARRANTY; without even the implied warranty of 126fcafd02SGreg Roach * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 136fcafd02SGreg Roach * GNU General Public License for more details. 146fcafd02SGreg Roach * You should have received a copy of the GNU General Public License 156fcafd02SGreg Roach * along with this program. If not, see <https://www.gnu.org/licenses/>. 166fcafd02SGreg Roach */ 176fcafd02SGreg Roach 186fcafd02SGreg Roachdeclare(strict_types=1); 196fcafd02SGreg Roach 206fcafd02SGreg Roachnamespace Fisharebest\Webtrees; 216fcafd02SGreg Roach 226fcafd02SGreg Roachuse Fisharebest\Webtrees\Factories\FamilyFactory; 236fcafd02SGreg Roachuse Fisharebest\Webtrees\Factories\IndividualFactory; 24*a004d330SGreg Roachuse Fisharebest\Webtrees\Module\LanguageEnglishAustralia; 25d8a5ab6eSJonathan Jaubartuse Fisharebest\Webtrees\Module\LanguageEnglishGreatBritain; 26*a004d330SGreg Roachuse Fisharebest\Webtrees\Module\LanguageEnglishUnitedStates; 27d8a5ab6eSJonathan Jaubartuse Fisharebest\Webtrees\Module\LanguageFrench; 28*a004d330SGreg Roachuse Fisharebest\Webtrees\Module\ModuleLanguageInterface; 296fcafd02SGreg Roachuse Fisharebest\Webtrees\Services\RelationshipService; 306fcafd02SGreg Roach 31*a004d330SGreg Roachuse function array_reverse; 32*a004d330SGreg Roach 336fcafd02SGreg Roach/** 346fcafd02SGreg Roach * Test the user functions 356fcafd02SGreg Roach * 366fcafd02SGreg Roach * @covers \Fisharebest\Webtrees\Relationship 376fcafd02SGreg Roach * @covers \Fisharebest\Webtrees\Services\RelationshipService 386fcafd02SGreg Roach * @covers \Fisharebest\Webtrees\Module\LanguageEnglishGreatBritain 39d8a5ab6eSJonathan Jaubart * @covers \Fisharebest\Webtrees\Module\LanguageEnglishUnitedStates 40d8a5ab6eSJonathan Jaubart * @covers \Fisharebest\Webtrees\Module\LanguageFrench 41b72623feSGreg Roach * @covers \Fisharebest\Webtrees\Module\ModuleLanguageTrait 426fcafd02SGreg Roach */ 436fcafd02SGreg Roachclass RelationshipNamesTest extends TestCase 446fcafd02SGreg Roach{ 456fcafd02SGreg Roach /** 466fcafd02SGreg Roach * @return void 476fcafd02SGreg Roach */ 486fcafd02SGreg Roach public function testRelationshipNames(): void 496fcafd02SGreg Roach { 506fcafd02SGreg Roach // i22m===f10===i23f 516fcafd02SGreg Roach // | 526fcafd02SGreg Roach // +-----+-----+ 536fcafd02SGreg Roach // | | 54d8a5ab6eSJonathan Jaubart // i20m===f9===i21f i24m===f11m===i25f 55d8a5ab6eSJonathan Jaubart // | | 56d8a5ab6eSJonathan Jaubart // i19f===f8===i18m i26f===f12===i27m 576fcafd02SGreg Roach // | | 586fcafd02SGreg Roach // +---+---+ +---+---+ 59d8a5ab6eSJonathan Jaubart // | | | | 60d8a5ab6eSJonathan Jaubart // i16m===f7===i17f i30m i28u i29m===f15 61d8a5ab6eSJonathan Jaubart // | | 62d8a5ab6eSJonathan Jaubart // i12f===f4m===i11m i13m===f5m===i14f i34f 63d8a5ab6eSJonathan Jaubart // | | 64d8a5ab6eSJonathan Jaubart // i1m===f1m==========i2f===f2d===i6m=====f13m===i31m===f14d===i32f 65d8a5ab6eSJonathan Jaubart // | | | 66d8a5ab6eSJonathan Jaubart // +---+---+ +---+---+ | 67d8a5ab6eSJonathan Jaubart // | | | | | | | 68d8a5ab6eSJonathan Jaubart // i10f===f3e===i3m i4f i5u i7ma i8f i9u===f6===i15u i33f 696fcafd02SGreg Roach // 706fcafd02SGreg Roach // Individual suffixes - m(ale), f(emale), u(nknown), a(dopted) 716fcafd02SGreg Roach // Family suffixes - m(arried), d(ivorced), e(ngaged) 726fcafd02SGreg Roach // 736fcafd02SGreg Roach $tree = $this->createMock(Tree::class); 746fcafd02SGreg Roach 756fcafd02SGreg Roach $individual_factory = $this->createStub(IndividualFactory::class); 766fcafd02SGreg Roach $family_factory = $this->createStub(FamilyFactory::class); 776fcafd02SGreg Roach 786fcafd02SGreg Roach Registry::familyFactory($family_factory); 796fcafd02SGreg Roach Registry::individualFactory($individual_factory); 806fcafd02SGreg Roach 816fcafd02SGreg Roach $i1m = new Individual('i1m', "0 @i1m@ INDI\n1 SEX M\n1 FAMS @f1m@\n1 FAMC @f4m@", null, $tree); 826fcafd02SGreg Roach $i2f = new Individual('i2f', "0 @i2f@ INDI\n1 SEX F\n1 FAMS @f1m@\n1 FAMS @f2d@\n2 FAMC @f5m@", null, $tree); 836fcafd02SGreg Roach $i3m = new Individual('i3m', "0 @i3m@ INDI\n1 SEX M\n1 FAMC @f1m@\n1 FAMS @f3e@\n1 BIRT\n2 DATE 2000", null, $tree); 846fcafd02SGreg Roach $i4f = new Individual('i4f', "0 @i4f@ INDI\n1 SEX F\n1 FAMC @f1m@\n1 BIRT\n2 DATE 2001", null, $tree); 856fcafd02SGreg Roach $i5u = new Individual('i5u', "0 @i5u@ INDI\n1 SEX U\n1 FAMC @f1m@\n1 BIRT\n2 DATE 2002", null, $tree); 866fcafd02SGreg Roach $i6m = new Individual('i6m', "0 @i6m@ INDI\n1 SEX M\n1 FAMS @f2d@", null, $tree); 876fcafd02SGreg Roach $i7ma = new Individual('i7ma', "0 @i7ma@ INDI\n1 SEX M\n1 FAMC @f2d@\n2 PEDI adopted", null, $tree); 886fcafd02SGreg Roach $i8f = new Individual('i8f', "0 @i8f@ INDI\n1 SEX F\n1 FAMC @f2d@", null, $tree); 896fcafd02SGreg Roach $i9u = new Individual('i9u', "0 @i9u@ INDI\n1 SEX U\n1 FAMC @f2d@\n1 FAMS @f6@", null, $tree); 906fcafd02SGreg Roach $i10f = new Individual('i10f', "0 @i10f@ INDI\n1 SEX F\n1 FAMS @f3e@", null, $tree); 916fcafd02SGreg Roach $i11m = new Individual('i11m', "0 @i11f@ INDI\n1 SEX M\n1 FAMS @f4m@\n1 FAMC @f7@", null, $tree); 926fcafd02SGreg Roach $i12f = new Individual('i12f', "0 @i12f@ INDI\n1 SEX F\n1 FAMS @f4m@", null, $tree); 936fcafd02SGreg Roach $i13m = new Individual('i13m', "0 @i13f@ INDI\n1 SEX M\n1 FAMS @f5m@", null, $tree); 946fcafd02SGreg Roach $i14f = new Individual('i14f', "0 @i14f@ INDI\n1 SEX F\n1 FAMS @f5m@", null, $tree); 956fcafd02SGreg Roach $i15u = new Individual('i15u', "0 @i15u@ INDI\n1 SEX U\n1 FAMS @f6@", null, $tree); 966fcafd02SGreg Roach $i16m = new Individual('i16m', "0 @i16m@ INDI\n1 SEX M\n1 FAMS @f7@", null, $tree); 976fcafd02SGreg Roach $i17f = new Individual('i17f', "0 @i17f@ INDI\n1 SEX F\n1 FAMS @f7@\n1 FAMC @f8@", null, $tree); 986fcafd02SGreg Roach $i18m = new Individual('i18m', "0 @i18m@ INDI\n1 SEX M\n1 FAMS @f8@\n1 FAMC @f9@", null, $tree); 996fcafd02SGreg Roach $i19f = new Individual('i19f', "0 @i19f@ INDI\n1 SEX F\n1 FAMS @f8@", null, $tree); 1006fcafd02SGreg Roach $i20m = new Individual('i20m', "0 @i20m@ INDI\n1 SEX M\n1 FAMS @f9@", null, $tree); 1016fcafd02SGreg Roach $i21f = new Individual('i21f', "0 @i21f@ INDI\n1 SEX F\n1 FAMS @f9@\n1 FAMC @f10@", null, $tree); 1026fcafd02SGreg Roach $i22m = new Individual('i22m', "0 @i22m@ INDI\n1 SEX M\n1 FAMS @f10@", null, $tree); 1036fcafd02SGreg Roach $i23f = new Individual('i23f', "0 @i23f@ INDI\n1 SEX F\n1 FAMS @f10@", null, $tree); 104d8a5ab6eSJonathan Jaubart $i24m = new Individual('i24m', "0 @i24m@ INDI\n1 SEX M\n1 FAMS @f11@\n1 FAMC @f10@", null, $tree); 105d8a5ab6eSJonathan Jaubart $i25f = new Individual('i25f', "0 @i25f@ INDI\n1 SEX F\n1 FAMS @f11@", null, $tree); 106d8a5ab6eSJonathan Jaubart $i26f = new Individual('i26f', "0 @i26f@ INDI\n1 SEX F\n1 FAMS @f12@\n1 FAMC @f11@", null, $tree); 107d8a5ab6eSJonathan Jaubart $i27m = new Individual('i27m', "0 @i27m@ INDI\n1 SEX M\n1 FAMS @f12@", null, $tree); 108d8a5ab6eSJonathan Jaubart $i28u = new Individual('i28u', "0 @i28u@ INDI\n1 SEX U\n1 FAMC @f12@", null, $tree); 109d8a5ab6eSJonathan Jaubart $i29m = new Individual('i29m', "0 @i29m@ INDI\n1 SEX M\n1 FAMC @f12@", null, $tree); 110d8a5ab6eSJonathan Jaubart $i30m = new Individual('i30m', "0 @i30m@ INDI\n1 SEX M\n1 FAMC @f8@", null, $tree); 111d8a5ab6eSJonathan Jaubart $i31m = new Individual('i31m', "0 @i31m@ INDI\n1 SEX M\n1 FAMS @f13m@\n1 FAMS @f14d@", null, $tree); 112d8a5ab6eSJonathan Jaubart $i32f = new Individual('i32f', "0 @i32f@ INDI\n1 SEX F\n1 FAMS @f14d@", null, $tree); 113d8a5ab6eSJonathan Jaubart $i33f = new Individual('i33f', "0 @i33f@ INDI\n1 SEX F\n1 FAMC @f14d@", null, $tree); 114d8a5ab6eSJonathan Jaubart $i34f = new Individual('i34f', "0 @i34f@ INDI\n1 SEX F\n1 FAMC @f15@", null, $tree); 1156fcafd02SGreg Roach 1166fcafd02SGreg Roach $individual_factory->method('make')->will($this->returnValueMap([ 1176fcafd02SGreg Roach 'i1m' => $i1m, 1186fcafd02SGreg Roach 'i2f' => $i2f, 1196fcafd02SGreg Roach 'i3m' => $i3m, 1206fcafd02SGreg Roach 'i4f' => $i4f, 1216fcafd02SGreg Roach 'i5u' => $i5u, 1226fcafd02SGreg Roach 'i6m' => $i6m, 1236fcafd02SGreg Roach 'i7ma' => $i7ma, 1246fcafd02SGreg Roach 'i8f' => $i8f, 1256fcafd02SGreg Roach 'i9u' => $i9u, 1266fcafd02SGreg Roach 'i10f' => $i10f, 1276fcafd02SGreg Roach 'i11m' => $i11m, 1286fcafd02SGreg Roach 'i12f' => $i12f, 1296fcafd02SGreg Roach 'i13m' => $i13m, 1306fcafd02SGreg Roach 'i14f' => $i14f, 1316fcafd02SGreg Roach 'i15u' => $i15u, 1326fcafd02SGreg Roach 'i16m' => $i16m, 1336fcafd02SGreg Roach 'i17f' => $i17f, 1346fcafd02SGreg Roach 'i18m' => $i18m, 1356fcafd02SGreg Roach 'i19f' => $i19f, 1366fcafd02SGreg Roach 'i20m' => $i20m, 1376fcafd02SGreg Roach 'i21f' => $i21f, 138d8a5ab6eSJonathan Jaubart 'i22m' => $i22m, 139d8a5ab6eSJonathan Jaubart 'i23f' => $i23f, 140d8a5ab6eSJonathan Jaubart 'i24m' => $i24m, 141d8a5ab6eSJonathan Jaubart 'i25f' => $i25f, 142d8a5ab6eSJonathan Jaubart 'i26f' => $i26f, 143d8a5ab6eSJonathan Jaubart 'i27m' => $i27m, 144d8a5ab6eSJonathan Jaubart 'i28u' => $i28u, 145d8a5ab6eSJonathan Jaubart 'i29m' => $i29m, 146d8a5ab6eSJonathan Jaubart 'i30m' => $i30m, 147d8a5ab6eSJonathan Jaubart 'i31m' => $i31m, 148d8a5ab6eSJonathan Jaubart 'i32f' => $i32f, 149d8a5ab6eSJonathan Jaubart 'i33f' => $i33f, 150*a004d330SGreg Roach 'i34f' => $i34f, 1516fcafd02SGreg Roach ])); 1526fcafd02SGreg Roach 1536fcafd02SGreg Roach $f1m = new Family('f1m', "0 @f1m@ FAM\n1 MARR Y\n1 HUSB @i1m@\n1 WIFE @i2f@\n1 CHIL @i3m@\n1 CHIL @i4f@\n1 CHIL @i5u@", null, $tree); 1546fcafd02SGreg Roach $f2d = new Family('f2d', "0 @f2d@ FAM\n1 DIV Y\n1 HUSB @i6m@\n1 WIFE @i2f@\n1 CHIL @i7ma@\n1 CHIL @i8f@\n1 CHIL @i9u@", null, $tree); 1556fcafd02SGreg Roach $f3e = new Family('f3e', "0 @f3e@ FAM\n1 ENGA Y\n1 HUSB @i3m@\n1 WIFE @i10f@", null, $tree); 1566fcafd02SGreg Roach $f4m = new Family('f4m', "0 @f4m@ FAM\n1 MARR Y\n1 HUSB @i11m@\n1 WIFE @i12f@\n1 CHIL @i1m@", null, $tree); 1576fcafd02SGreg Roach $f5m = new Family('f5m', "0 @f5m@ FAM\n1 MARR Y\n1 HUSB @i13m@\n1 WIFE @i14f@\n1 CHIL @i2f@", null, $tree); 1586fcafd02SGreg Roach $f6 = new Family('f6', "0 @f6@ FAM\n1 HUSB @i9u@\n1 WIFE @i15u@", null, $tree); 1596fcafd02SGreg Roach $f7 = new Family('f7', "0 @f7@ FAM\n1 HUSB @i16m@\n1 WIFE @i17f@\n1 CHIL @i11m@", null, $tree); 160d8a5ab6eSJonathan Jaubart $f8 = new Family('f8', "0 @f8@ FAM\n1 HUSB @i18m@\n1 WIFE @i19f@\n1 CHIL @i17f@\n1 CHIL @i30m@", null, $tree); 1616fcafd02SGreg Roach $f9 = new Family('f9', "0 @f9@ FAM\n1 HUSB @i20m@\n1 WIFE @i21f@\n1 CHIL @i18m@", null, $tree); 162d8a5ab6eSJonathan Jaubart $f10 = new Family('f10', "0 @f10@ FAM\n1 HUSB @i22m@\n1 WIFE @i23f@\n1 CHIL @i21f@\n1 CHIL @i24m@", null, $tree); 163d8a5ab6eSJonathan Jaubart $f11m = new Family('f11m', "0 @f11m@ FAM\n1 MARR Y\n1 HUSB @i24m@\n1 WIFE @i25f@\n1 CHIL @i26f@", null, $tree); 164d8a5ab6eSJonathan Jaubart $f12 = new Family('f12', "0 @f12@ FAM\n1 HUSB @i27m@\n1 WIFE @i26f@\n1 CHIL @i28u@\n1 CHIL @i29m@", null, $tree); 165d8a5ab6eSJonathan Jaubart $f13m = new Family('f13m', "0 @f13m@ FAM\n1 MARR Y\n1 HUSB @i6m@\n1 WIFE @i31m@", null, $tree); 166d8a5ab6eSJonathan Jaubart $f14d = new Family('f14d', "0 @f14d@ FAM\n1 DIV Y\n1 HUSB @i31m@\n1 WIFE @i32f@\n1 CHIL @i33f@\n", null, $tree); 167d8a5ab6eSJonathan Jaubart $f15 = new Family('f15', "0 @f15@ FAM\n1 HUSB @i29m@\n1 CHIL @i34f@\n", null, $tree); 1686fcafd02SGreg Roach 1696fcafd02SGreg Roach $family_factory->method('make')->will($this->returnValueMap([ 1706fcafd02SGreg Roach 'f1m' => $f1m, 1716fcafd02SGreg Roach 'f2d' => $f2d, 1726fcafd02SGreg Roach 'f3e' => $f3e, 1736fcafd02SGreg Roach 'f4m' => $f4m, 1746fcafd02SGreg Roach 'f5m' => $f5m, 1756fcafd02SGreg Roach 'f6' => $f6, 1766fcafd02SGreg Roach 'f7' => $f7, 1776fcafd02SGreg Roach 'f8' => $f8, 1786fcafd02SGreg Roach 'f9' => $f9, 1796fcafd02SGreg Roach 'f10' => $f10, 180d8a5ab6eSJonathan Jaubart 'f11m' => $f11m, 181d8a5ab6eSJonathan Jaubart 'f12' => $f12, 182d8a5ab6eSJonathan Jaubart 'f13m' => $f13m, 183d8a5ab6eSJonathan Jaubart 'f14d' => $f14d, 184*a004d330SGreg Roach 'f15' => $f15, 1856fcafd02SGreg Roach ])); 1866fcafd02SGreg Roach 1876fcafd02SGreg Roach $service = new RelationshipService(); 1886fcafd02SGreg Roach 189*a004d330SGreg Roach /////////////////////////////////////////////////////////////////////// 1906fcafd02SGreg Roach // ENGLISH 191*a004d330SGreg Roach /////////////////////////////////////////////////////////////////////// 192*a004d330SGreg Roach 193*a004d330SGreg Roach $en_au = new LanguageEnglishAustralia(); 194d8a5ab6eSJonathan Jaubart $en_gb = new LanguageEnglishGreatBritain(); 195*a004d330SGreg Roach $en_us = new LanguageEnglishUnitedStates(); 1966fcafd02SGreg Roach 197*a004d330SGreg Roach foreach ([$en_us, $en_gb, $en_au] as $en) { 198*a004d330SGreg Roach self::assertRelationship('himself', [$i3m], $en); 199*a004d330SGreg Roach self::assertRelationship('herself', [$i4f], $en); 200*a004d330SGreg Roach self::assertRelationship('themself', [$i5u], $en); 201*a004d330SGreg Roach self::assertRelationships('wife', 'husband', [$i1m, $f1m, $i2f], $en); 202*a004d330SGreg Roach self::assertRelationships('partner', 'partner', [$i9u, $f6, $i15u], $en); 203*a004d330SGreg Roach self::assertRelationships('ex-husband', 'ex-wife', [$i2f, $f2d, $i6m], $en); 204*a004d330SGreg Roach self::assertRelationships('fiancé', 'fiancée', [$i10f, $f3e, $i3m], $en); 205*a004d330SGreg Roach self::assertRelationships('son', 'father', [$i1m, $f1m, $i3m], $en); 206*a004d330SGreg Roach self::assertRelationships('daughter', 'mother', [$i2f, $f1m, $i4f], $en); 207*a004d330SGreg Roach self::assertRelationships('child', 'father', [$i1m, $f1m, $i5u], $en); 208*a004d330SGreg Roach self::assertRelationships('elder brother', 'younger sister', [$i4f, $f1m, $i3m], $en); 209*a004d330SGreg Roach self::assertRelationships('younger sibling', 'elder brother', [$i3m, $f1m, $i5u], $en); 210*a004d330SGreg Roach self::assertRelationships('brother', 'sister', [$i8f, $f2d, $i7ma], $en); 211*a004d330SGreg Roach self::assertRelationships('sibling', 'brother', [$i7ma, $f2d, $i9u], $en); 212*a004d330SGreg Roach self::assertRelationships('adoptive-mother', 'adopted-son', [$i7ma, $f2d, $i2f], $en); 213*a004d330SGreg Roach self::assertRelationships('stepfather', 'stepchild', [$i9u, $f2d, $i2f, $f1m, $i1m], $en); 214*a004d330SGreg Roach self::assertRelationships('stepdaughter', 'stepmother', [$i2f, $f1m, $i2f, $f2d, $i8f], $en); 215*a004d330SGreg Roach self::assertRelationships('stepsister', 'stepsibling', [$i9u, $f2d, $i6m, $f13m, $i31m, $f14d, $i33f], $en); 216*a004d330SGreg Roach self::assertRelationships('half-brother', 'half-sister', [$i8f, $f2d, $i2f, $f1m, $i3m], $en); 217*a004d330SGreg Roach self::assertRelationships('mother-in-law', 'daughter-in-law', [$i2f, $f1m, $i1m, $f4m, $i12f], $en); 218*a004d330SGreg Roach self::assertRelationships('paternal-grandfather', 'grandson', [$i3m, $f1m, $i1m, $f4m, $i11m], $en); 219*a004d330SGreg Roach self::assertRelationships('paternal-grandmother', 'granddaughter', [$i4f, $f1m, $i1m, $f4m, $i12f], $en); 220*a004d330SGreg Roach self::assertRelationships('maternal-grandfather', 'grandson', [$i3m, $f1m, $i2f, $f5m, $i13m], $en); 221*a004d330SGreg Roach self::assertRelationships('maternal-grandmother', 'grandchild', [$i5u, $f1m, $i2f, $f5m, $i14f], $en); 222*a004d330SGreg Roach self::assertRelationship('paternal great-grandfather', [$i3m, $f1m, $i1m, $f4m, $i11m, $f7, $i16m], $en); 223*a004d330SGreg Roach self::assertRelationship('paternal great-grandmother', [$i3m, $f1m, $i1m, $f4m, $i11m, $f7, $i17f], $en); 224*a004d330SGreg Roach self::assertRelationship('paternal great-great-grandfather', [$i3m, $f1m, $i1m, $f4m, $i11m, $f7, $i17f, $f8, $i18m], $en); 225*a004d330SGreg Roach self::assertRelationship('paternal great-great-grandmother', [$i3m, $f1m, $i1m, $f4m, $i11m, $f7, $i17f, $f8, $i19f], $en); 226*a004d330SGreg Roach self::assertRelationship('paternal great-great-great-grandfather', [$i3m, $f1m, $i1m, $f4m, $i11m, $f7, $i17f, $f8, $i18m, $f9, $i20m], $en); 227*a004d330SGreg Roach self::assertRelationship('paternal great-great-great-grandmother', [$i3m, $f1m, $i1m, $f4m, $i11m, $f7, $i17f, $f8, $i18m, $f9, $i21f], $en); 228*a004d330SGreg Roach self::assertRelationship('paternal great ×4 grandfather', [$i3m, $f1m, $i1m, $f4m, $i11m, $f7, $i17f, $f8, $i18m, $f9, $i21f, $f10, $i22m], $en); 229*a004d330SGreg Roach self::assertRelationship('paternal great ×4 grandmother', [$i3m, $f1m, $i1m, $f4m, $i11m, $f7, $i17f, $f8, $i18m, $f9, $i21f, $f10, $i23f], $en); 230*a004d330SGreg Roach self::assertRelationship('uncle', [$i18m, $f9, $i21f, $f10, $i24m], $en); 231*a004d330SGreg Roach self::assertRelationship('great-uncle', [$i30m, $f8, $i18m, $f9, $i21f, $f10, $i24m], $en); 232*a004d330SGreg Roach self::assertRelationship('great-great-uncle', [$i11m, $f7, $i17f, $f8, $i18m, $f9, $i21f, $f10, $i24m], $en); 233*a004d330SGreg Roach self::assertRelationship('nephew', [$i24m, $f10, $i21f, $f9, $i18m], $en); 234*a004d330SGreg Roach self::assertRelationship('great-niece', [$i24m, $f10, $i21f, $f9, $i18m, $f8, $i17f], $en); 235*a004d330SGreg Roach self::assertRelationship('great-great-nephew', [$i24m, $f10, $i21f, $f9, $i18m, $f8, $i17f, $f7, $i11m], $en); 236*a004d330SGreg Roach self::assertRelationship('first cousin', [$i18m, $f9, $i21f, $f10, $i24m, $f11m, $i26f], $en); 237*a004d330SGreg Roach self::assertRelationship('second cousin', [$i30m, $f8, $i18m, $f9, $i21f, $f10, $i24m, $f11m, $i26f, $f12, $i29m], $en); 238*a004d330SGreg Roach self::assertRelationship('first cousin once removed ascending', [$i30m, $f8, $i18m, $f9, $i21f, $f10, $i24m, $f11m, $i26f], $en); 239*a004d330SGreg Roach self::assertRelationship('first cousin once removed descending', [$i26f, $f11m, $i24m, $f10, $i21f, $f9, $i18m, $f8, $i17f], $en); 240*a004d330SGreg Roach self::assertRelationship('second cousin once removed ascending', [$i11m, $f7, $i17f, $f8, $i18m, $f9, $i21f, $f10, $i24m, $f11m, $i26f, $f12, $i29m], $en); 241*a004d330SGreg Roach // Compound relationships 242*a004d330SGreg Roach self::assertRelationship('wife’s ex-husband', [$i1m, $f1m, $i2f, $f2d, $i6m], $en); 243*a004d330SGreg Roach } 244*a004d330SGreg Roach 245*a004d330SGreg Roach /////////////////////////////////////////////////////////////////////// 246d8a5ab6eSJonathan Jaubart // FRENCH 247*a004d330SGreg Roach /////////////////////////////////////////////////////////////////////// 248d8a5ab6eSJonathan Jaubart 249*a004d330SGreg Roach $fr_fr = new LanguageFrench(); 250*a004d330SGreg Roach $fr_ca = new LanguageFrench(); 251*a004d330SGreg Roach 252*a004d330SGreg Roach foreach ([$fr_fr, $fr_ca] as $fr) { 253d8a5ab6eSJonathan Jaubart // Static relationships 254*a004d330SGreg Roach self::assertRelationship('épouse', [$i1m, $f1m, $i2f], $fr); 255*a004d330SGreg Roach self::assertRelationship('époux', [$i2f, $f1m, $i1m], $fr); 256*a004d330SGreg Roach self::assertRelationship('conjoint', [$i9u, $f6, $i15u], $fr); 257*a004d330SGreg Roach self::assertRelationship('ex-époux', [$i2f, $f2d, $i6m], $fr); 258*a004d330SGreg Roach self::assertRelationship('ex-épouse', [$i6m, $f2d, $i2f], $fr); 259*a004d330SGreg Roach self::assertRelationship('fiancé', [$i10f, $f3e, $i3m], $fr); 260*a004d330SGreg Roach self::assertRelationship('fiancée', [$i3m, $f3e, $i10f], $fr); 261*a004d330SGreg Roach self::assertRelationship('fils', [$i1m, $f1m, $i3m], $fr); 262*a004d330SGreg Roach self::assertRelationship('fille', [$i1m, $f1m, $i4f], $fr); 263*a004d330SGreg Roach self::assertRelationship('enfant', [$i1m, $f1m, $i5u], $fr); 264*a004d330SGreg Roach self::assertRelationship('grand frère', [$i4f, $f1m, $i3m], $fr); 265*a004d330SGreg Roach self::assertRelationship('petite sœur', [$i3m, $f1m, $i4f], $fr); 266*a004d330SGreg Roach self::assertRelationship('petit frère/sœur', [$i3m, $f1m, $i5u], $fr); 267*a004d330SGreg Roach self::assertRelationship('frère', [$i8f, $f2d, $i7ma], $fr); 268*a004d330SGreg Roach self::assertRelationship('sœur', [$i7ma, $f2d, $i8f], $fr); 269*a004d330SGreg Roach self::assertRelationship('frère/sœur', [$i7ma, $f2d, $i9u], $fr); 270*a004d330SGreg Roach self::assertRelationship('mère adoptive', [$i7ma, $f2d, $i2f], $fr); 271*a004d330SGreg Roach self::assertRelationship('père adoptif', [$i7ma, $f2d, $i6m], $fr); 272*a004d330SGreg Roach self::assertRelationship('fils adoptif', [$i6m, $f2d, $i7ma], $fr); 273*a004d330SGreg Roach self::assertRelationship('beau-père', [$i8f, $f2d, $i2f, $f1m, $i1m], $fr); 274*a004d330SGreg Roach self::assertRelationship('belle-fille', [$i1m, $f1m, $i2f, $f2d, $i8f], $fr); 275*a004d330SGreg Roach self::assertRelationship('demi-frère', [$i8f, $f2d, $i2f, $f1m, $i3m], $fr); 276*a004d330SGreg Roach self::assertRelationship('quasi-sœur', [$i8f, $f2d, $i6m, $f13m, $i31m, $f14d, $i33f], $fr); 277*a004d330SGreg Roach self::assertRelationship('beau-père', [$i8f, $f2d, $i6m, $f13m, $i31m], $fr); 278*a004d330SGreg Roach self::assertRelationship('belle-mère', [$i2f, $f1m, $i1m, $f4m, $i12f], $fr); 279*a004d330SGreg Roach self::assertRelationship('belle-fille', [$i12f, $f4m, $i1m, $f1m, $i2f], $fr); 280d8a5ab6eSJonathan Jaubart // Dynamic relationships 281*a004d330SGreg Roach self::assertRelationship('grand-père paternel', [$i3m, $f1m, $i1m, $f4m, $i11m], $fr); 282*a004d330SGreg Roach self::assertRelationship('grand-mère paternelle', [$i3m, $f1m, $i1m, $f4m, $i12f], $fr); 283*a004d330SGreg Roach self::assertRelationship('grand-père maternel', [$i3m, $f1m, $i2f, $f5m, $i13m], $fr); 284*a004d330SGreg Roach self::assertRelationship('grand-mère maternelle', [$i3m, $f1m, $i2f, $f5m, $i14f], $fr); 285*a004d330SGreg Roach self::assertRelationship('arrière-grand-père paternel', [$i3m, $f1m, $i1m, $f4m, $i11m, $f7, $i16m], $fr); 286*a004d330SGreg Roach self::assertRelationship('arrière-grand-mère paternelle', [$i3m, $f1m, $i1m, $f4m, $i11m, $f7, $i17f], $fr); 287*a004d330SGreg Roach self::assertRelationship('arrière-arrière-grand-père paternel', [$i3m, $f1m, $i1m, $f4m, $i11m, $f7, $i17f, $f8, $i18m], $fr); 288*a004d330SGreg Roach self::assertRelationship('arrière-arrière-grand-mère paternelle', [$i3m, $f1m, $i1m, $f4m, $i11m, $f7, $i17f, $f8, $i19f], $fr); 289*a004d330SGreg Roach self::assertRelationship('arrière-(x3)-grand-père paternel', [$i3m, $f1m, $i1m, $f4m, $i11m, $f7, $i17f, $f8, $i18m, $f9, $i20m], $fr); 290*a004d330SGreg Roach self::assertRelationship('arrière-(x3)-grand-mère paternelle', [$i3m, $f1m, $i1m, $f4m, $i11m, $f7, $i17f, $f8, $i18m, $f9, $i21f], $fr); 291*a004d330SGreg Roach self::assertRelationship('arrière-(x4)-grand-père paternel', [$i3m, $f1m, $i1m, $f4m, $i11m, $f7, $i17f, $f8, $i18m, $f9, $i21f, $f10, $i22m], $fr); 292*a004d330SGreg Roach self::assertRelationship('arrière-(x4)-grand-mère paternelle', [$i3m, $f1m, $i1m, $f4m, $i11m, $f7, $i17f, $f8, $i18m, $f9, $i21f, $f10, $i23f], $fr); 293*a004d330SGreg Roach self::assertRelationship('oncle', [$i18m, $f9, $i21f, $f10, $i24m], $fr); 294*a004d330SGreg Roach self::assertRelationship('grand-oncle', [$i30m, $f8, $i18m, $f9, $i21f, $f10, $i24m], $fr); 295*a004d330SGreg Roach self::assertRelationship('arrière-grand-oncle', [$i11m, $f7, $i17f, $f8, $i18m, $f9, $i21f, $f10, $i24m], $fr); 296*a004d330SGreg Roach self::assertRelationship('neveu', [$i24m, $f10, $i21f, $f9, $i18m], $fr); 297*a004d330SGreg Roach self::assertRelationship('petite-nièce', [$i24m, $f10, $i21f, $f9, $i18m, $f8, $i17f], $fr); 298*a004d330SGreg Roach self::assertRelationship('arrière-petit-neveu', [$i24m, $f10, $i21f, $f9, $i18m, $f8, $i17f, $f7, $i11m], $fr); 299*a004d330SGreg Roach self::assertRelationship('cousine germaine', [$i18m, $f9, $i21f, $f10, $i24m, $f11m, $i26f], $fr); 300*a004d330SGreg Roach self::assertRelationship('cousin issu de germain', [$i30m, $f8, $i18m, $f9, $i21f, $f10, $i24m, $f11m, $i26f, $f12, $i29m], $fr); 301*a004d330SGreg Roach self::assertRelationship('cousine au 3<sup>e</sup> degré', [$i11m, $f7, $i17f, $f8, $i18m, $f9, $i21f, $f10, $i24m, $f11m, $i26f, $f12, $i29m, $f15, $i34f], $fr); 302*a004d330SGreg Roach self::assertRelationship('grand-cousine', [$i30m, $f8, $i18m, $f9, $i21f, $f10, $i24m, $f11m, $i26f], $fr); 303*a004d330SGreg Roach self::assertRelationship('petit-cousin', [$i26f, $f11m, $i24m, $f10, $i21f, $f9, $i18m, $f8, $i30m], $fr); 304*a004d330SGreg Roach self::assertRelationship('cousin du 2<sup>e</sup> au 3<sup>e</sup> degré', [$i11m, $f7, $i17f, $f8, $i18m, $f9, $i21f, $f10, $i24m, $f11m, $i26f, $f12, $i29m], $fr); 305*a004d330SGreg Roach self::assertRelationship('cousine du 3<sup>e</sup> au 2<sup>e</sup> degré', [$i17f, $f8, $i18m, $f9, $i21f, $f10, $i24m, $f11m, $i26f, $f12, $i29m, $f15, $i34f], $fr); 306d8a5ab6eSJonathan Jaubart // Compound relationships 307*a004d330SGreg Roach self::assertRelationship('ex-époux de l’épouse', [$i1m, $f1m, $i2f, $f2d, $i6m], $fr); 308*a004d330SGreg Roach } 309d8a5ab6eSJonathan Jaubart 310*a004d330SGreg Roach /////////////////////////////////////////////////////////////////////// 3116fcafd02SGreg Roach // SLOVAK 312*a004d330SGreg Roach /////////////////////////////////////////////////////////////////////// 313*a004d330SGreg Roach } 314*a004d330SGreg Roach 315*a004d330SGreg Roach /** 316*a004d330SGreg Roach * @param string $expected 317*a004d330SGreg Roach * @param array $nodes 318*a004d330SGreg Roach * @param ModuleLanguageInterface $language 319*a004d330SGreg Roach */ 320*a004d330SGreg Roach private static function assertRelationship(string $expected, array $nodes, ModuleLanguageInterface $language): void 321*a004d330SGreg Roach { 322*a004d330SGreg Roach $service = new RelationshipService(); 323*a004d330SGreg Roach $actual = $service->nameFromPath($nodes, $language); 324*a004d330SGreg Roach $path = implode('-', array_map(fn (GedcomRecord $record): string => $record->xref(), $nodes)); 325*a004d330SGreg Roach $english = $service->nameFromPath($nodes, new LanguageEnglishUnitedStates()); 326*a004d330SGreg Roach $message = 'Language: ' . $language->title() . PHP_EOL . 'Path: ' . $path . ' (' . $english . ')'; 327*a004d330SGreg Roach 328*a004d330SGreg Roach self::assertSame($expected, $actual, $message); 329*a004d330SGreg Roach } 330*a004d330SGreg Roach 331*a004d330SGreg Roach /** 332*a004d330SGreg Roach * Test a relationship name in both directions 333*a004d330SGreg Roach * 334*a004d330SGreg Roach * @param string $fwd 335*a004d330SGreg Roach * @param string $rev 336*a004d330SGreg Roach * @param array $nodes 337*a004d330SGreg Roach * @param ModuleLanguageInterface $language 338*a004d330SGreg Roach */ 339*a004d330SGreg Roach private static function assertRelationships(string $fwd, string $rev, array $nodes, ModuleLanguageInterface $language): void 340*a004d330SGreg Roach { 341*a004d330SGreg Roach self::assertRelationship($fwd, $nodes, $language); 342*a004d330SGreg Roach self::assertRelationship($rev, array_reverse($nodes), $language); 3436fcafd02SGreg Roach } 3446fcafd02SGreg Roach} 345