1<?php 2 3/** 4 * webtrees: online genealogy 5 * Copyright (C) 2021 webtrees development team 6 * This program is free software: you can redistribute it and/or modify 7 * it under the terms of the GNU General Public License as published by 8 * the Free Software Foundation, either version 3 of the License, or 9 * (at your option) any later version. 10 * This program is distributed in the hope that it will be useful, 11 * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 * GNU General Public License for more details. 14 * You should have received a copy of the GNU General Public License 15 * along with this program. If not, see <https://www.gnu.org/licenses/>. 16 */ 17 18declare(strict_types=1); 19 20namespace Fisharebest\Webtrees; 21 22use Fisharebest\Webtrees\Factories\FamilyFactory; 23use Fisharebest\Webtrees\Factories\IndividualFactory; 24use Fisharebest\Webtrees\Module\LanguageEnglishAustralia; 25use Fisharebest\Webtrees\Module\LanguageEnglishGreatBritain; 26use Fisharebest\Webtrees\Module\LanguageEnglishUnitedStates; 27use Fisharebest\Webtrees\Module\LanguageFrench; 28use Fisharebest\Webtrees\Module\ModuleLanguageInterface; 29use Fisharebest\Webtrees\Services\RelationshipService; 30 31use function array_reverse; 32 33/** 34 * Test the user functions 35 * 36 * @covers \Fisharebest\Webtrees\Relationship 37 * @covers \Fisharebest\Webtrees\Services\RelationshipService 38 * @covers \Fisharebest\Webtrees\Module\LanguageEnglishGreatBritain 39 * @covers \Fisharebest\Webtrees\Module\LanguageEnglishUnitedStates 40 * @covers \Fisharebest\Webtrees\Module\LanguageFrench 41 * @covers \Fisharebest\Webtrees\Module\ModuleLanguageTrait 42 */ 43class RelationshipNamesTest extends TestCase 44{ 45 /** 46 * @return void 47 */ 48 public function testRelationshipNames(): void 49 { 50 // i22m===f10===i23f 51 // | 52 // +-----+-----+ 53 // | | 54 // i20m===f9===i21f i24m===f11m===i25f 55 // | | 56 // i19f===f8===i18m i26f===f12===i27m 57 // | | 58 // +---+---+ +---+---+ 59 // | | | | 60 // i16m===f7===i17f i30m i28u i29m===f15 61 // | | 62 // i12f===f4m===i11m i13m===f5m===i14f i34f 63 // | | 64 // i1m===f1m==========i2f===f2d===i6m=====f13m===i31m===f14d===i32f 65 // | | | 66 // +---+---+ +---+---+ | 67 // | | | | | | | 68 // i10f===f3e===i3m i4f i5u i7ma i8f i9u===f6===i15u i33f 69 // 70 // Individual suffixes - m(ale), f(emale), u(nknown), a(dopted) 71 // Family suffixes - m(arried), d(ivorced), e(ngaged) 72 // 73 $tree = $this->createMock(Tree::class); 74 75 $individual_factory = $this->createStub(IndividualFactory::class); 76 $family_factory = $this->createStub(FamilyFactory::class); 77 78 Registry::familyFactory($family_factory); 79 Registry::individualFactory($individual_factory); 80 81 $i1m = new Individual('i1m', "0 @i1m@ INDI\n1 SEX M\n1 FAMS @f1m@\n1 FAMC @f4m@", null, $tree); 82 $i2f = new Individual('i2f', "0 @i2f@ INDI\n1 SEX F\n1 FAMS @f1m@\n1 FAMS @f2d@\n2 FAMC @f5m@", null, $tree); 83 $i3m = new Individual('i3m', "0 @i3m@ INDI\n1 SEX M\n1 FAMC @f1m@\n1 FAMS @f3e@\n1 BIRT\n2 DATE 2000", null, $tree); 84 $i4f = new Individual('i4f', "0 @i4f@ INDI\n1 SEX F\n1 FAMC @f1m@\n1 BIRT\n2 DATE 2001", null, $tree); 85 $i5u = new Individual('i5u', "0 @i5u@ INDI\n1 SEX U\n1 FAMC @f1m@\n1 BIRT\n2 DATE 2002", null, $tree); 86 $i6m = new Individual('i6m', "0 @i6m@ INDI\n1 SEX M\n1 FAMS @f2d@", null, $tree); 87 $i7ma = new Individual('i7ma', "0 @i7ma@ INDI\n1 SEX M\n1 FAMC @f2d@\n2 PEDI adopted", null, $tree); 88 $i8f = new Individual('i8f', "0 @i8f@ INDI\n1 SEX F\n1 FAMC @f2d@", null, $tree); 89 $i9u = new Individual('i9u', "0 @i9u@ INDI\n1 SEX U\n1 FAMC @f2d@\n1 FAMS @f6@", null, $tree); 90 $i10f = new Individual('i10f', "0 @i10f@ INDI\n1 SEX F\n1 FAMS @f3e@", null, $tree); 91 $i11m = new Individual('i11m', "0 @i11f@ INDI\n1 SEX M\n1 FAMS @f4m@\n1 FAMC @f7@", null, $tree); 92 $i12f = new Individual('i12f', "0 @i12f@ INDI\n1 SEX F\n1 FAMS @f4m@", null, $tree); 93 $i13m = new Individual('i13m', "0 @i13f@ INDI\n1 SEX M\n1 FAMS @f5m@", null, $tree); 94 $i14f = new Individual('i14f', "0 @i14f@ INDI\n1 SEX F\n1 FAMS @f5m@", null, $tree); 95 $i15u = new Individual('i15u', "0 @i15u@ INDI\n1 SEX U\n1 FAMS @f6@", null, $tree); 96 $i16m = new Individual('i16m', "0 @i16m@ INDI\n1 SEX M\n1 FAMS @f7@", null, $tree); 97 $i17f = new Individual('i17f', "0 @i17f@ INDI\n1 SEX F\n1 FAMS @f7@\n1 FAMC @f8@", null, $tree); 98 $i18m = new Individual('i18m', "0 @i18m@ INDI\n1 SEX M\n1 FAMS @f8@\n1 FAMC @f9@", null, $tree); 99 $i19f = new Individual('i19f', "0 @i19f@ INDI\n1 SEX F\n1 FAMS @f8@", null, $tree); 100 $i20m = new Individual('i20m', "0 @i20m@ INDI\n1 SEX M\n1 FAMS @f9@", null, $tree); 101 $i21f = new Individual('i21f', "0 @i21f@ INDI\n1 SEX F\n1 FAMS @f9@\n1 FAMC @f10@", null, $tree); 102 $i22m = new Individual('i22m', "0 @i22m@ INDI\n1 SEX M\n1 FAMS @f10@", null, $tree); 103 $i23f = new Individual('i23f', "0 @i23f@ INDI\n1 SEX F\n1 FAMS @f10@", null, $tree); 104 $i24m = new Individual('i24m', "0 @i24m@ INDI\n1 SEX M\n1 FAMS @f11@\n1 FAMC @f10@", null, $tree); 105 $i25f = new Individual('i25f', "0 @i25f@ INDI\n1 SEX F\n1 FAMS @f11@", null, $tree); 106 $i26f = new Individual('i26f', "0 @i26f@ INDI\n1 SEX F\n1 FAMS @f12@\n1 FAMC @f11@", null, $tree); 107 $i27m = new Individual('i27m', "0 @i27m@ INDI\n1 SEX M\n1 FAMS @f12@", null, $tree); 108 $i28u = new Individual('i28u', "0 @i28u@ INDI\n1 SEX U\n1 FAMC @f12@", null, $tree); 109 $i29m = new Individual('i29m', "0 @i29m@ INDI\n1 SEX M\n1 FAMC @f12@", null, $tree); 110 $i30m = new Individual('i30m', "0 @i30m@ INDI\n1 SEX M\n1 FAMC @f8@", null, $tree); 111 $i31m = new Individual('i31m', "0 @i31m@ INDI\n1 SEX M\n1 FAMS @f13m@\n1 FAMS @f14d@", null, $tree); 112 $i32f = new Individual('i32f', "0 @i32f@ INDI\n1 SEX F\n1 FAMS @f14d@", null, $tree); 113 $i33f = new Individual('i33f', "0 @i33f@ INDI\n1 SEX F\n1 FAMC @f14d@", null, $tree); 114 $i34f = new Individual('i34f', "0 @i34f@ INDI\n1 SEX F\n1 FAMC @f15@", null, $tree); 115 116 $individual_factory->method('make')->will($this->returnValueMap([ 117 'i1m' => $i1m, 118 'i2f' => $i2f, 119 'i3m' => $i3m, 120 'i4f' => $i4f, 121 'i5u' => $i5u, 122 'i6m' => $i6m, 123 'i7ma' => $i7ma, 124 'i8f' => $i8f, 125 'i9u' => $i9u, 126 'i10f' => $i10f, 127 'i11m' => $i11m, 128 'i12f' => $i12f, 129 'i13m' => $i13m, 130 'i14f' => $i14f, 131 'i15u' => $i15u, 132 'i16m' => $i16m, 133 'i17f' => $i17f, 134 'i18m' => $i18m, 135 'i19f' => $i19f, 136 'i20m' => $i20m, 137 'i21f' => $i21f, 138 'i22m' => $i22m, 139 'i23f' => $i23f, 140 'i24m' => $i24m, 141 'i25f' => $i25f, 142 'i26f' => $i26f, 143 'i27m' => $i27m, 144 'i28u' => $i28u, 145 'i29m' => $i29m, 146 'i30m' => $i30m, 147 'i31m' => $i31m, 148 'i32f' => $i32f, 149 'i33f' => $i33f, 150 'i34f' => $i34f, 151 ])); 152 153 $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); 154 $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); 155 $f3e = new Family('f3e', "0 @f3e@ FAM\n1 ENGA Y\n1 HUSB @i3m@\n1 WIFE @i10f@", null, $tree); 156 $f4m = new Family('f4m', "0 @f4m@ FAM\n1 MARR Y\n1 HUSB @i11m@\n1 WIFE @i12f@\n1 CHIL @i1m@", null, $tree); 157 $f5m = new Family('f5m', "0 @f5m@ FAM\n1 MARR Y\n1 HUSB @i13m@\n1 WIFE @i14f@\n1 CHIL @i2f@", null, $tree); 158 $f6 = new Family('f6', "0 @f6@ FAM\n1 HUSB @i9u@\n1 WIFE @i15u@", null, $tree); 159 $f7 = new Family('f7', "0 @f7@ FAM\n1 HUSB @i16m@\n1 WIFE @i17f@\n1 CHIL @i11m@", null, $tree); 160 $f8 = new Family('f8', "0 @f8@ FAM\n1 HUSB @i18m@\n1 WIFE @i19f@\n1 CHIL @i17f@\n1 CHIL @i30m@", null, $tree); 161 $f9 = new Family('f9', "0 @f9@ FAM\n1 HUSB @i20m@\n1 WIFE @i21f@\n1 CHIL @i18m@", null, $tree); 162 $f10 = new Family('f10', "0 @f10@ FAM\n1 HUSB @i22m@\n1 WIFE @i23f@\n1 CHIL @i21f@\n1 CHIL @i24m@", null, $tree); 163 $f11m = new Family('f11m', "0 @f11m@ FAM\n1 MARR Y\n1 HUSB @i24m@\n1 WIFE @i25f@\n1 CHIL @i26f@", null, $tree); 164 $f12 = new Family('f12', "0 @f12@ FAM\n1 HUSB @i27m@\n1 WIFE @i26f@\n1 CHIL @i28u@\n1 CHIL @i29m@", null, $tree); 165 $f13m = new Family('f13m', "0 @f13m@ FAM\n1 MARR Y\n1 HUSB @i6m@\n1 WIFE @i31m@", null, $tree); 166 $f14d = new Family('f14d', "0 @f14d@ FAM\n1 DIV Y\n1 HUSB @i31m@\n1 WIFE @i32f@\n1 CHIL @i33f@\n", null, $tree); 167 $f15 = new Family('f15', "0 @f15@ FAM\n1 HUSB @i29m@\n1 CHIL @i34f@\n", null, $tree); 168 169 $family_factory->method('make')->will($this->returnValueMap([ 170 'f1m' => $f1m, 171 'f2d' => $f2d, 172 'f3e' => $f3e, 173 'f4m' => $f4m, 174 'f5m' => $f5m, 175 'f6' => $f6, 176 'f7' => $f7, 177 'f8' => $f8, 178 'f9' => $f9, 179 'f10' => $f10, 180 'f11m' => $f11m, 181 'f12' => $f12, 182 'f13m' => $f13m, 183 'f14d' => $f14d, 184 'f15' => $f15, 185 ])); 186 187 $service = new RelationshipService(); 188 189 /////////////////////////////////////////////////////////////////////// 190 // ENGLISH 191 /////////////////////////////////////////////////////////////////////// 192 193 $en_au = new LanguageEnglishAustralia(); 194 $en_gb = new LanguageEnglishGreatBritain(); 195 $en_us = new LanguageEnglishUnitedStates(); 196 197 foreach ([$en_us, $en_gb, $en_au] as $en) { 198 self::assertRelationship('himself', [$i3m], $en); 199 self::assertRelationship('herself', [$i4f], $en); 200 self::assertRelationship('themself', [$i5u], $en); 201 self::assertRelationships('wife', 'husband', [$i1m, $f1m, $i2f], $en); 202 self::assertRelationships('partner', 'partner', [$i9u, $f6, $i15u], $en); 203 self::assertRelationships('ex-husband', 'ex-wife', [$i2f, $f2d, $i6m], $en); 204 self::assertRelationships('fiancé', 'fiancée', [$i10f, $f3e, $i3m], $en); 205 self::assertRelationships('son', 'father', [$i1m, $f1m, $i3m], $en); 206 self::assertRelationships('daughter', 'mother', [$i2f, $f1m, $i4f], $en); 207 self::assertRelationships('child', 'father', [$i1m, $f1m, $i5u], $en); 208 self::assertRelationships('elder brother', 'younger sister', [$i4f, $f1m, $i3m], $en); 209 self::assertRelationships('younger sibling', 'elder brother', [$i3m, $f1m, $i5u], $en); 210 self::assertRelationships('brother', 'sister', [$i8f, $f2d, $i7ma], $en); 211 self::assertRelationships('sibling', 'brother', [$i7ma, $f2d, $i9u], $en); 212 self::assertRelationships('adoptive-mother', 'adopted-son', [$i7ma, $f2d, $i2f], $en); 213 self::assertRelationships('stepfather', 'stepchild', [$i9u, $f2d, $i2f, $f1m, $i1m], $en); 214 self::assertRelationships('stepdaughter', 'stepmother', [$i2f, $f1m, $i2f, $f2d, $i8f], $en); 215 self::assertRelationships('stepsister', 'stepsibling', [$i9u, $f2d, $i6m, $f13m, $i31m, $f14d, $i33f], $en); 216 self::assertRelationships('half-brother', 'half-sister', [$i8f, $f2d, $i2f, $f1m, $i3m], $en); 217 self::assertRelationships('mother-in-law', 'daughter-in-law', [$i2f, $f1m, $i1m, $f4m, $i12f], $en); 218 self::assertRelationships('paternal-grandfather', 'grandson', [$i3m, $f1m, $i1m, $f4m, $i11m], $en); 219 self::assertRelationships('paternal-grandmother', 'granddaughter', [$i4f, $f1m, $i1m, $f4m, $i12f], $en); 220 self::assertRelationships('maternal-grandfather', 'grandson', [$i3m, $f1m, $i2f, $f5m, $i13m], $en); 221 self::assertRelationships('maternal-grandmother', 'grandchild', [$i5u, $f1m, $i2f, $f5m, $i14f], $en); 222 self::assertRelationship('paternal great-grandfather', [$i3m, $f1m, $i1m, $f4m, $i11m, $f7, $i16m], $en); 223 self::assertRelationship('paternal great-grandmother', [$i3m, $f1m, $i1m, $f4m, $i11m, $f7, $i17f], $en); 224 self::assertRelationship('paternal great-great-grandfather', [$i3m, $f1m, $i1m, $f4m, $i11m, $f7, $i17f, $f8, $i18m], $en); 225 self::assertRelationship('paternal great-great-grandmother', [$i3m, $f1m, $i1m, $f4m, $i11m, $f7, $i17f, $f8, $i19f], $en); 226 self::assertRelationship('paternal great-great-great-grandfather', [$i3m, $f1m, $i1m, $f4m, $i11m, $f7, $i17f, $f8, $i18m, $f9, $i20m], $en); 227 self::assertRelationship('paternal great-great-great-grandmother', [$i3m, $f1m, $i1m, $f4m, $i11m, $f7, $i17f, $f8, $i18m, $f9, $i21f], $en); 228 self::assertRelationship('paternal great ×4 grandfather', [$i3m, $f1m, $i1m, $f4m, $i11m, $f7, $i17f, $f8, $i18m, $f9, $i21f, $f10, $i22m], $en); 229 self::assertRelationship('paternal great ×4 grandmother', [$i3m, $f1m, $i1m, $f4m, $i11m, $f7, $i17f, $f8, $i18m, $f9, $i21f, $f10, $i23f], $en); 230 self::assertRelationship('uncle', [$i18m, $f9, $i21f, $f10, $i24m], $en); 231 self::assertRelationship('great-uncle', [$i30m, $f8, $i18m, $f9, $i21f, $f10, $i24m], $en); 232 self::assertRelationship('great-great-uncle', [$i11m, $f7, $i17f, $f8, $i18m, $f9, $i21f, $f10, $i24m], $en); 233 self::assertRelationship('nephew', [$i24m, $f10, $i21f, $f9, $i18m], $en); 234 self::assertRelationship('great-niece', [$i24m, $f10, $i21f, $f9, $i18m, $f8, $i17f], $en); 235 self::assertRelationship('great-great-nephew', [$i24m, $f10, $i21f, $f9, $i18m, $f8, $i17f, $f7, $i11m], $en); 236 self::assertRelationship('first cousin', [$i18m, $f9, $i21f, $f10, $i24m, $f11m, $i26f], $en); 237 self::assertRelationship('second cousin', [$i30m, $f8, $i18m, $f9, $i21f, $f10, $i24m, $f11m, $i26f, $f12, $i29m], $en); 238 self::assertRelationship('first cousin once removed ascending', [$i30m, $f8, $i18m, $f9, $i21f, $f10, $i24m, $f11m, $i26f], $en); 239 self::assertRelationship('first cousin once removed descending', [$i26f, $f11m, $i24m, $f10, $i21f, $f9, $i18m, $f8, $i17f], $en); 240 self::assertRelationship('second cousin once removed ascending', [$i11m, $f7, $i17f, $f8, $i18m, $f9, $i21f, $f10, $i24m, $f11m, $i26f, $f12, $i29m], $en); 241 // Compound relationships 242 self::assertRelationship('wife’s ex-husband', [$i1m, $f1m, $i2f, $f2d, $i6m], $en); 243 } 244 245 /////////////////////////////////////////////////////////////////////// 246 // FRENCH 247 /////////////////////////////////////////////////////////////////////// 248 249 $fr_fr = new LanguageFrench(); 250 $fr_ca = new LanguageFrench(); 251 252 foreach ([$fr_fr, $fr_ca] as $fr) { 253 // Static relationships 254 self::assertRelationship('épouse', [$i1m, $f1m, $i2f], $fr); 255 self::assertRelationship('époux', [$i2f, $f1m, $i1m], $fr); 256 self::assertRelationship('conjoint', [$i9u, $f6, $i15u], $fr); 257 self::assertRelationship('ex-époux', [$i2f, $f2d, $i6m], $fr); 258 self::assertRelationship('ex-épouse', [$i6m, $f2d, $i2f], $fr); 259 self::assertRelationship('fiancé', [$i10f, $f3e, $i3m], $fr); 260 self::assertRelationship('fiancée', [$i3m, $f3e, $i10f], $fr); 261 self::assertRelationship('fils', [$i1m, $f1m, $i3m], $fr); 262 self::assertRelationship('fille', [$i1m, $f1m, $i4f], $fr); 263 self::assertRelationship('enfant', [$i1m, $f1m, $i5u], $fr); 264 self::assertRelationship('grand frère', [$i4f, $f1m, $i3m], $fr); 265 self::assertRelationship('petite sœur', [$i3m, $f1m, $i4f], $fr); 266 self::assertRelationship('petit frère/sœur', [$i3m, $f1m, $i5u], $fr); 267 self::assertRelationship('frère', [$i8f, $f2d, $i7ma], $fr); 268 self::assertRelationship('sœur', [$i7ma, $f2d, $i8f], $fr); 269 self::assertRelationship('frère/sœur', [$i7ma, $f2d, $i9u], $fr); 270 self::assertRelationship('mère adoptive', [$i7ma, $f2d, $i2f], $fr); 271 self::assertRelationship('père adoptif', [$i7ma, $f2d, $i6m], $fr); 272 self::assertRelationship('fils adoptif', [$i6m, $f2d, $i7ma], $fr); 273 self::assertRelationship('beau-père', [$i8f, $f2d, $i2f, $f1m, $i1m], $fr); 274 self::assertRelationship('belle-fille', [$i1m, $f1m, $i2f, $f2d, $i8f], $fr); 275 self::assertRelationship('demi-frère', [$i8f, $f2d, $i2f, $f1m, $i3m], $fr); 276 self::assertRelationship('quasi-sœur', [$i8f, $f2d, $i6m, $f13m, $i31m, $f14d, $i33f], $fr); 277 self::assertRelationship('beau-père', [$i8f, $f2d, $i6m, $f13m, $i31m], $fr); 278 self::assertRelationship('belle-mère', [$i2f, $f1m, $i1m, $f4m, $i12f], $fr); 279 self::assertRelationship('belle-fille', [$i12f, $f4m, $i1m, $f1m, $i2f], $fr); 280 // Dynamic relationships 281 self::assertRelationship('grand-père paternel', [$i3m, $f1m, $i1m, $f4m, $i11m], $fr); 282 self::assertRelationship('grand-mère paternelle', [$i3m, $f1m, $i1m, $f4m, $i12f], $fr); 283 self::assertRelationship('grand-père maternel', [$i3m, $f1m, $i2f, $f5m, $i13m], $fr); 284 self::assertRelationship('grand-mère maternelle', [$i3m, $f1m, $i2f, $f5m, $i14f], $fr); 285 self::assertRelationship('arrière-grand-père paternel', [$i3m, $f1m, $i1m, $f4m, $i11m, $f7, $i16m], $fr); 286 self::assertRelationship('arrière-grand-mère paternelle', [$i3m, $f1m, $i1m, $f4m, $i11m, $f7, $i17f], $fr); 287 self::assertRelationship('arrière-arrière-grand-père paternel', [$i3m, $f1m, $i1m, $f4m, $i11m, $f7, $i17f, $f8, $i18m], $fr); 288 self::assertRelationship('arrière-arrière-grand-mère paternelle', [$i3m, $f1m, $i1m, $f4m, $i11m, $f7, $i17f, $f8, $i19f], $fr); 289 self::assertRelationship('arrière-(x3)-grand-père paternel', [$i3m, $f1m, $i1m, $f4m, $i11m, $f7, $i17f, $f8, $i18m, $f9, $i20m], $fr); 290 self::assertRelationship('arrière-(x3)-grand-mère paternelle', [$i3m, $f1m, $i1m, $f4m, $i11m, $f7, $i17f, $f8, $i18m, $f9, $i21f], $fr); 291 self::assertRelationship('arrière-(x4)-grand-père paternel', [$i3m, $f1m, $i1m, $f4m, $i11m, $f7, $i17f, $f8, $i18m, $f9, $i21f, $f10, $i22m], $fr); 292 self::assertRelationship('arrière-(x4)-grand-mère paternelle', [$i3m, $f1m, $i1m, $f4m, $i11m, $f7, $i17f, $f8, $i18m, $f9, $i21f, $f10, $i23f], $fr); 293 self::assertRelationship('oncle', [$i18m, $f9, $i21f, $f10, $i24m], $fr); 294 self::assertRelationship('grand-oncle', [$i30m, $f8, $i18m, $f9, $i21f, $f10, $i24m], $fr); 295 self::assertRelationship('arrière-grand-oncle', [$i11m, $f7, $i17f, $f8, $i18m, $f9, $i21f, $f10, $i24m], $fr); 296 self::assertRelationship('neveu', [$i24m, $f10, $i21f, $f9, $i18m], $fr); 297 self::assertRelationship('petite-nièce', [$i24m, $f10, $i21f, $f9, $i18m, $f8, $i17f], $fr); 298 self::assertRelationship('arrière-petit-neveu', [$i24m, $f10, $i21f, $f9, $i18m, $f8, $i17f, $f7, $i11m], $fr); 299 self::assertRelationship('cousine germaine', [$i18m, $f9, $i21f, $f10, $i24m, $f11m, $i26f], $fr); 300 self::assertRelationship('cousin issu de germain', [$i30m, $f8, $i18m, $f9, $i21f, $f10, $i24m, $f11m, $i26f, $f12, $i29m], $fr); 301 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 self::assertRelationship('grand-cousine', [$i30m, $f8, $i18m, $f9, $i21f, $f10, $i24m, $f11m, $i26f], $fr); 303 self::assertRelationship('petit-cousin', [$i26f, $f11m, $i24m, $f10, $i21f, $f9, $i18m, $f8, $i30m], $fr); 304 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 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); 306 // Compound relationships 307 self::assertRelationship('ex-époux de l’épouse', [$i1m, $f1m, $i2f, $f2d, $i6m], $fr); 308 } 309 310 /////////////////////////////////////////////////////////////////////// 311 // SLOVAK 312 /////////////////////////////////////////////////////////////////////// 313 } 314 315 /** 316 * @param string $expected 317 * @param array $nodes 318 * @param ModuleLanguageInterface $language 319 */ 320 private static function assertRelationship(string $expected, array $nodes, ModuleLanguageInterface $language): void 321 { 322 $service = new RelationshipService(); 323 $actual = $service->nameFromPath($nodes, $language); 324 $path = implode('-', array_map(fn (GedcomRecord $record): string => $record->xref(), $nodes)); 325 $english = $service->nameFromPath($nodes, new LanguageEnglishUnitedStates()); 326 $message = 'Language: ' . $language->title() . PHP_EOL . 'Path: ' . $path . ' (' . $english . ')'; 327 328 self::assertSame($expected, $actual, $message); 329 } 330 331 /** 332 * Test a relationship name in both directions 333 * 334 * @param string $fwd 335 * @param string $rev 336 * @param array $nodes 337 * @param ModuleLanguageInterface $language 338 */ 339 private static function assertRelationships(string $fwd, string $rev, array $nodes, ModuleLanguageInterface $language): void 340 { 341 self::assertRelationship($fwd, $nodes, $language); 342 self::assertRelationship($rev, array_reverse($nodes), $language); 343 } 344} 345