xref: /webtrees/tests/feature/RelationshipNamesTest.php (revision 41e0cd5c0cf95e342f1da982eded94170e6aa785)
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;
24a004d330SGreg Roachuse Fisharebest\Webtrees\Module\LanguageEnglishAustralia;
25d8a5ab6eSJonathan Jaubartuse Fisharebest\Webtrees\Module\LanguageEnglishGreatBritain;
26a004d330SGreg Roachuse Fisharebest\Webtrees\Module\LanguageEnglishUnitedStates;
27d8a5ab6eSJonathan Jaubartuse Fisharebest\Webtrees\Module\LanguageFrench;
28a004d330SGreg Roachuse Fisharebest\Webtrees\Module\ModuleLanguageInterface;
296fcafd02SGreg Roachuse Fisharebest\Webtrees\Services\RelationshipService;
306fcafd02SGreg Roach
31a004d330SGreg Roachuse function array_reverse;
32a004d330SGreg 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        //                            |                                                              |
62*41e0cd5cSGreg Roach        //              i12f===f4m===i11m  i13m===f5m===i14f                                        i34f===f16
63d8a5ab6eSJonathan Jaubart        //                      |                  |                                                        |
64*41e0cd5cSGreg Roach        //                     i1m===f1m==========i2f===f2d===i6m=====f13m===i31m===f14d===i32f            i35m===f17
65*41e0cd5cSGreg Roach        //                            |                  |                           |                             |
66*41e0cd5cSGreg Roach        //                        +---+---+          +---+---+                       |                            i36f
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);
115*41e0cd5cSGreg Roach        $i35m = new Individual('i35m', "0 @i35m@ INDI\n1 SEX M\n1 FAMS @f17@\n1 FAMC @f16@", null, $tree);
116*41e0cd5cSGreg Roach        $i36f = new Individual('i36f', "0 @i36f@ INDI\n1 SEX F\n1 FAMC @fF17@", null, $tree);
1176fcafd02SGreg Roach
1186fcafd02SGreg Roach        $individual_factory->method('make')->will($this->returnValueMap([
1196fcafd02SGreg Roach            'i1m'  => $i1m,
1206fcafd02SGreg Roach            'i2f'  => $i2f,
1216fcafd02SGreg Roach            'i3m'  => $i3m,
1226fcafd02SGreg Roach            'i4f'  => $i4f,
1236fcafd02SGreg Roach            'i5u'  => $i5u,
1246fcafd02SGreg Roach            'i6m'  => $i6m,
1256fcafd02SGreg Roach            'i7ma' => $i7ma,
1266fcafd02SGreg Roach            'i8f'  => $i8f,
1276fcafd02SGreg Roach            'i9u'  => $i9u,
1286fcafd02SGreg Roach            'i10f' => $i10f,
1296fcafd02SGreg Roach            'i11m' => $i11m,
1306fcafd02SGreg Roach            'i12f' => $i12f,
1316fcafd02SGreg Roach            'i13m' => $i13m,
1326fcafd02SGreg Roach            'i14f' => $i14f,
1336fcafd02SGreg Roach            'i15u' => $i15u,
1346fcafd02SGreg Roach            'i16m' => $i16m,
1356fcafd02SGreg Roach            'i17f' => $i17f,
1366fcafd02SGreg Roach            'i18m' => $i18m,
1376fcafd02SGreg Roach            'i19f' => $i19f,
1386fcafd02SGreg Roach            'i20m' => $i20m,
1396fcafd02SGreg Roach            'i21f' => $i21f,
140d8a5ab6eSJonathan Jaubart            'i22m' => $i22m,
141d8a5ab6eSJonathan Jaubart            'i23f' => $i23f,
142d8a5ab6eSJonathan Jaubart            'i24m' => $i24m,
143d8a5ab6eSJonathan Jaubart            'i25f' => $i25f,
144d8a5ab6eSJonathan Jaubart            'i26f' => $i26f,
145d8a5ab6eSJonathan Jaubart            'i27m' => $i27m,
146d8a5ab6eSJonathan Jaubart            'i28u' => $i28u,
147d8a5ab6eSJonathan Jaubart            'i29m' => $i29m,
148d8a5ab6eSJonathan Jaubart            'i30m' => $i30m,
149d8a5ab6eSJonathan Jaubart            'i31m' => $i31m,
150d8a5ab6eSJonathan Jaubart            'i32f' => $i32f,
151d8a5ab6eSJonathan Jaubart            'i33f' => $i33f,
152a004d330SGreg Roach            'i34f' => $i34f,
153*41e0cd5cSGreg Roach            'i35m' => $i35m,
154*41e0cd5cSGreg Roach            'i36f' => $i36f,
1556fcafd02SGreg Roach        ]));
1566fcafd02SGreg Roach
1576fcafd02SGreg 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);
1586fcafd02SGreg 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);
1596fcafd02SGreg Roach        $f3e  = new Family('f3e', "0 @f3e@ FAM\n1 ENGA Y\n1 HUSB @i3m@\n1 WIFE @i10f@", null, $tree);
1606fcafd02SGreg Roach        $f4m  = new Family('f4m', "0 @f4m@ FAM\n1 MARR Y\n1 HUSB @i11m@\n1 WIFE @i12f@\n1 CHIL @i1m@", null, $tree);
1616fcafd02SGreg Roach        $f5m  = new Family('f5m', "0 @f5m@ FAM\n1 MARR Y\n1 HUSB @i13m@\n1 WIFE @i14f@\n1 CHIL @i2f@", null, $tree);
1626fcafd02SGreg Roach        $f6   = new Family('f6', "0 @f6@ FAM\n1 HUSB @i9u@\n1 WIFE @i15u@", null, $tree);
1636fcafd02SGreg Roach        $f7   = new Family('f7', "0 @f7@ FAM\n1 HUSB @i16m@\n1 WIFE @i17f@\n1 CHIL @i11m@", null, $tree);
164d8a5ab6eSJonathan Jaubart        $f8   = new Family('f8', "0 @f8@ FAM\n1 HUSB @i18m@\n1 WIFE @i19f@\n1 CHIL @i17f@\n1 CHIL @i30m@", null, $tree);
1656fcafd02SGreg Roach        $f9   = new Family('f9', "0 @f9@ FAM\n1 HUSB @i20m@\n1 WIFE @i21f@\n1 CHIL @i18m@", null, $tree);
166d8a5ab6eSJonathan Jaubart        $f10  = new Family('f10', "0 @f10@ FAM\n1 HUSB @i22m@\n1 WIFE @i23f@\n1 CHIL @i21f@\n1 CHIL @i24m@", null, $tree);
167d8a5ab6eSJonathan Jaubart        $f11m = new Family('f11m', "0 @f11m@ FAM\n1 MARR Y\n1 HUSB @i24m@\n1 WIFE @i25f@\n1 CHIL @i26f@", null, $tree);
168d8a5ab6eSJonathan Jaubart        $f12  = new Family('f12', "0 @f12@ FAM\n1 HUSB @i27m@\n1 WIFE @i26f@\n1 CHIL @i28u@\n1 CHIL @i29m@", null, $tree);
169d8a5ab6eSJonathan Jaubart        $f13m = new Family('f13m', "0 @f13m@ FAM\n1 MARR Y\n1 HUSB @i6m@\n1 WIFE @i31m@", null, $tree);
170d8a5ab6eSJonathan Jaubart        $f14d = new Family('f14d', "0 @f14d@ FAM\n1 DIV Y\n1 HUSB @i31m@\n1 WIFE @i32f@\n1 CHIL @i33f@\n", null, $tree);
171d8a5ab6eSJonathan Jaubart        $f15  = new Family('f15', "0 @f15@ FAM\n1 HUSB @i29m@\n1 CHIL @i34f@\n", null, $tree);
172*41e0cd5cSGreg Roach        $f16  = new Family('f16', "0 @f16@ FAM\n1 WIFE @i34f@\n1 CHIL @i35m@\n", null, $tree);
173*41e0cd5cSGreg Roach        $f17  = new Family('f17', "0 @f17@ FAM\n1 HUSB @i35m@\n1 CHIL @i36f@\n", null, $tree);
1746fcafd02SGreg Roach
1756fcafd02SGreg Roach        $family_factory->method('make')->will($this->returnValueMap([
1766fcafd02SGreg Roach            'f1m'  => $f1m,
1776fcafd02SGreg Roach            'f2d'  => $f2d,
1786fcafd02SGreg Roach            'f3e'  => $f3e,
1796fcafd02SGreg Roach            'f4m'  => $f4m,
1806fcafd02SGreg Roach            'f5m'  => $f5m,
1816fcafd02SGreg Roach            'f6'   => $f6,
1826fcafd02SGreg Roach            'f7'   => $f7,
1836fcafd02SGreg Roach            'f8'   => $f8,
1846fcafd02SGreg Roach            'f9'   => $f9,
1856fcafd02SGreg Roach            'f10'  => $f10,
186d8a5ab6eSJonathan Jaubart            'f11m' => $f11m,
187d8a5ab6eSJonathan Jaubart            'f12'  => $f12,
188d8a5ab6eSJonathan Jaubart            'f13m' => $f13m,
189d8a5ab6eSJonathan Jaubart            'f14d' => $f14d,
190a004d330SGreg Roach            'f15'  => $f15,
191*41e0cd5cSGreg Roach            'f16'  => $f16,
192*41e0cd5cSGreg Roach            'f17'  => $f17,
1936fcafd02SGreg Roach        ]));
1946fcafd02SGreg Roach
195a004d330SGreg Roach        ///////////////////////////////////////////////////////////////////////
1966fcafd02SGreg Roach        // ENGLISH
197a004d330SGreg Roach        ///////////////////////////////////////////////////////////////////////
198a004d330SGreg Roach
199a004d330SGreg Roach        $en_au = new LanguageEnglishAustralia();
200d8a5ab6eSJonathan Jaubart        $en_gb = new LanguageEnglishGreatBritain();
201a004d330SGreg Roach        $en_us = new LanguageEnglishUnitedStates();
2026fcafd02SGreg Roach
203a004d330SGreg Roach        foreach ([$en_us, $en_gb, $en_au] as $en) {
204a004d330SGreg Roach            self::assertRelationship('himself', [$i3m], $en);
205a004d330SGreg Roach            self::assertRelationship('herself', [$i4f], $en);
206a004d330SGreg Roach            self::assertRelationship('themself', [$i5u], $en);
207a004d330SGreg Roach            self::assertRelationships('wife', 'husband', [$i1m, $f1m, $i2f], $en);
208a004d330SGreg Roach            self::assertRelationships('partner', 'partner', [$i9u, $f6, $i15u], $en);
209a004d330SGreg Roach            self::assertRelationships('ex-husband', 'ex-wife', [$i2f, $f2d, $i6m], $en);
210a004d330SGreg Roach            self::assertRelationships('fiancé', 'fiancée', [$i10f, $f3e, $i3m], $en);
211a004d330SGreg Roach            self::assertRelationships('son', 'father', [$i1m, $f1m, $i3m], $en);
212a004d330SGreg Roach            self::assertRelationships('daughter', 'mother', [$i2f, $f1m, $i4f], $en);
213a004d330SGreg Roach            self::assertRelationships('child', 'father', [$i1m, $f1m, $i5u], $en);
214a004d330SGreg Roach            self::assertRelationships('elder brother', 'younger sister', [$i4f, $f1m, $i3m], $en);
215a004d330SGreg Roach            self::assertRelationships('younger sibling', 'elder brother', [$i3m, $f1m, $i5u], $en);
216a004d330SGreg Roach            self::assertRelationships('brother', 'sister', [$i8f, $f2d, $i7ma], $en);
217a004d330SGreg Roach            self::assertRelationships('sibling', 'brother', [$i7ma, $f2d, $i9u], $en);
218a004d330SGreg Roach            self::assertRelationships('adoptive-mother', 'adopted-son', [$i7ma, $f2d, $i2f], $en);
219a004d330SGreg Roach            self::assertRelationships('stepfather', 'stepchild', [$i9u, $f2d, $i2f, $f1m, $i1m], $en);
220a004d330SGreg Roach            self::assertRelationships('stepdaughter', 'stepmother', [$i2f, $f1m, $i2f, $f2d, $i8f], $en);
221a004d330SGreg Roach            self::assertRelationships('stepsister', 'stepsibling', [$i9u, $f2d, $i6m, $f13m, $i31m, $f14d, $i33f], $en);
222a004d330SGreg Roach            self::assertRelationships('half-brother', 'half-sister', [$i8f, $f2d, $i2f, $f1m, $i3m], $en);
223a004d330SGreg Roach            self::assertRelationships('mother-in-law', 'daughter-in-law', [$i2f, $f1m, $i1m, $f4m, $i12f], $en);
224a004d330SGreg Roach            self::assertRelationships('paternal-grandfather', 'grandson', [$i3m, $f1m, $i1m, $f4m, $i11m], $en);
225a004d330SGreg Roach            self::assertRelationships('paternal-grandmother', 'granddaughter', [$i4f, $f1m, $i1m, $f4m, $i12f], $en);
226a004d330SGreg Roach            self::assertRelationships('maternal-grandfather', 'grandson', [$i3m, $f1m, $i2f, $f5m, $i13m], $en);
227a004d330SGreg Roach            self::assertRelationships('maternal-grandmother', 'grandchild', [$i5u, $f1m, $i2f, $f5m, $i14f], $en);
228a004d330SGreg Roach            self::assertRelationship('paternal great-grandfather', [$i3m, $f1m, $i1m, $f4m, $i11m, $f7, $i16m], $en);
229a004d330SGreg Roach            self::assertRelationship('paternal great-grandmother', [$i3m, $f1m, $i1m, $f4m, $i11m, $f7, $i17f], $en);
230a004d330SGreg Roach            self::assertRelationship('paternal great-great-grandfather', [$i3m, $f1m, $i1m, $f4m, $i11m, $f7, $i17f, $f8, $i18m], $en);
231a004d330SGreg Roach            self::assertRelationship('paternal great-great-grandmother', [$i3m, $f1m, $i1m, $f4m, $i11m, $f7, $i17f, $f8, $i19f], $en);
232a004d330SGreg Roach            self::assertRelationship('paternal great-great-great-grandfather', [$i3m, $f1m, $i1m, $f4m, $i11m, $f7, $i17f, $f8, $i18m, $f9, $i20m], $en);
233a004d330SGreg Roach            self::assertRelationship('paternal great-great-great-grandmother', [$i3m, $f1m, $i1m, $f4m, $i11m, $f7, $i17f, $f8, $i18m, $f9, $i21f], $en);
234a004d330SGreg Roach            self::assertRelationship('paternal great ×4 grandfather', [$i3m, $f1m, $i1m, $f4m, $i11m, $f7, $i17f, $f8, $i18m, $f9, $i21f, $f10, $i22m], $en);
235a004d330SGreg Roach            self::assertRelationship('paternal great ×4 grandmother', [$i3m, $f1m, $i1m, $f4m, $i11m, $f7, $i17f, $f8, $i18m, $f9, $i21f, $f10, $i23f], $en);
236a004d330SGreg Roach            self::assertRelationship('uncle', [$i18m, $f9, $i21f, $f10, $i24m], $en);
237a004d330SGreg Roach            self::assertRelationship('great-uncle', [$i30m, $f8, $i18m, $f9, $i21f, $f10, $i24m], $en);
238a004d330SGreg Roach            self::assertRelationship('great-great-uncle', [$i11m, $f7, $i17f, $f8, $i18m, $f9, $i21f, $f10, $i24m], $en);
239a004d330SGreg Roach            self::assertRelationship('nephew', [$i24m, $f10, $i21f, $f9, $i18m], $en);
240a004d330SGreg Roach            self::assertRelationship('great-niece', [$i24m, $f10, $i21f, $f9, $i18m, $f8, $i17f], $en);
241a004d330SGreg Roach            self::assertRelationship('great-great-nephew', [$i24m, $f10, $i21f, $f9, $i18m, $f8, $i17f, $f7, $i11m], $en);
242*41e0cd5cSGreg Roach            self::assertRelationships('first cousin', 'first cousin', [$i18m, $f9, $i21f, $f10, $i24m, $f11m, $i26f], $en);
243*41e0cd5cSGreg Roach            self::assertRelationships('second cousin', 'second cousin', [$i17f, $f8, $i18m, $f9, $i21f, $f10, $i24m, $f11m, $i26f, $f12, $i29m], $en);
244*41e0cd5cSGreg Roach            self::assertRelationships('first cousin once removed ascending', 'first cousin once removed descending', [$i17f, $f8, $i18m, $f9, $i21f, $f10, $i24m, $f11m, $i26f], $en);
245*41e0cd5cSGreg Roach            self::assertRelationships('third cousin', 'third cousin', [$i11m, $f7, $i17f, $f8, $i18m, $f9, $i21f, $f10, $i24m, $f11m, $i26f, $f12, $i29m, $f15, $i34f], $en);
246*41e0cd5cSGreg Roach            self::assertRelationships('second cousin once removed ascending', 'second cousin once removed descending', [$i11m, $f7, $i17f, $f8, $i18m, $f9, $i21f, $f10, $i24m, $f11m, $i26f, $f12, $i29m], $en);
247*41e0cd5cSGreg Roach            self::assertRelationships('first cousin twice removed ascending', 'first cousin twice removed descending', [$i11m, $f7, $i17f, $f8, $i18m, $f9, $i21f, $f10, $i24m, $f11m, $i26f], $en);
248*41e0cd5cSGreg Roach            self::assertRelationships('fourth cousin', 'fourth cousin', [$i1m, $f4m, $i11m, $f7, $i17f, $f8, $i18m, $f9, $i21f, $f10, $i24m, $f11m, $i26f, $f12, $i29m, $f15, $i34f, $f16, $i35m], $en);
249*41e0cd5cSGreg Roach            self::assertRelationships('third cousin once removed ascending', 'third cousin once removed descending', [$i1m, $f4m, $i11m, $f7, $i17f, $f8, $i18m, $f9, $i21f, $f10, $i24m, $f11m, $i26f, $f12, $i29m, $f15, $i34f], $en);
250*41e0cd5cSGreg Roach            self::assertRelationships('second cousin twice removed ascending', 'second cousin twice removed descending', [$i1m, $f4m, $i11m, $f7, $i17f, $f8, $i18m, $f9, $i21f, $f10, $i24m, $f11m, $i26f, $f12, $i29m], $en);
251a004d330SGreg Roach            // Compound relationships
252a004d330SGreg Roach            self::assertRelationship('wife’s ex-husband', [$i1m, $f1m, $i2f, $f2d, $i6m], $en);
253a004d330SGreg Roach        }
254a004d330SGreg Roach
255*41e0cd5cSGreg Roach        self::assertRelationships('first cousin thrice removed ascending', 'first cousin thrice removed descending', [$i1m, $f4m, $i11m, $f7, $i17f, $f8, $i18m, $f9, $i21f, $f10, $i24m, $f11m, $i26f], $en_au);
256*41e0cd5cSGreg Roach        self::assertRelationships('first cousin thrice removed ascending', 'first cousin thrice removed descending', [$i1m, $f4m, $i11m, $f7, $i17f, $f8, $i18m, $f9, $i21f, $f10, $i24m, $f11m, $i26f], $en_gb);
257*41e0cd5cSGreg Roach        self::assertRelationships('first cousin three times removed ascending', 'first cousin three times removed descending', [$i1m, $f4m, $i11m, $f7, $i17f, $f8, $i18m, $f9, $i21f, $f10, $i24m, $f11m, $i26f], $en_us);
258*41e0cd5cSGreg Roach
259a004d330SGreg Roach        ///////////////////////////////////////////////////////////////////////
260d8a5ab6eSJonathan Jaubart        // FRENCH
261a004d330SGreg Roach        ///////////////////////////////////////////////////////////////////////
262d8a5ab6eSJonathan Jaubart
263a004d330SGreg Roach        $fr_fr = new LanguageFrench();
264a004d330SGreg Roach        $fr_ca = new LanguageFrench();
265a004d330SGreg Roach
266a004d330SGreg Roach        foreach ([$fr_fr, $fr_ca] as $fr) {
267d8a5ab6eSJonathan Jaubart            // Static relationships
268a004d330SGreg Roach            self::assertRelationship('épouse', [$i1m, $f1m, $i2f], $fr);
269a004d330SGreg Roach            self::assertRelationship('époux', [$i2f, $f1m, $i1m], $fr);
270a004d330SGreg Roach            self::assertRelationship('conjoint', [$i9u, $f6, $i15u], $fr);
271a004d330SGreg Roach            self::assertRelationship('ex-époux', [$i2f, $f2d, $i6m], $fr);
272a004d330SGreg Roach            self::assertRelationship('ex-épouse', [$i6m, $f2d, $i2f], $fr);
273a004d330SGreg Roach            self::assertRelationship('fiancé', [$i10f, $f3e, $i3m], $fr);
274a004d330SGreg Roach            self::assertRelationship('fiancée', [$i3m, $f3e, $i10f], $fr);
275a004d330SGreg Roach            self::assertRelationship('fils', [$i1m, $f1m, $i3m], $fr);
276a004d330SGreg Roach            self::assertRelationship('fille', [$i1m, $f1m, $i4f], $fr);
277a004d330SGreg Roach            self::assertRelationship('enfant', [$i1m, $f1m, $i5u], $fr);
278a004d330SGreg Roach            self::assertRelationship('grand frère', [$i4f, $f1m, $i3m], $fr);
279a004d330SGreg Roach            self::assertRelationship('petite sœur', [$i3m, $f1m, $i4f], $fr);
280a004d330SGreg Roach            self::assertRelationship('petit frère/sœur', [$i3m, $f1m, $i5u], $fr);
281a004d330SGreg Roach            self::assertRelationship('frère', [$i8f, $f2d, $i7ma], $fr);
282a004d330SGreg Roach            self::assertRelationship('sœur', [$i7ma, $f2d, $i8f], $fr);
283a004d330SGreg Roach            self::assertRelationship('frère/sœur', [$i7ma, $f2d, $i9u], $fr);
284a004d330SGreg Roach            self::assertRelationship('mère adoptive', [$i7ma, $f2d, $i2f], $fr);
285a004d330SGreg Roach            self::assertRelationship('père adoptif', [$i7ma, $f2d, $i6m], $fr);
286a004d330SGreg Roach            self::assertRelationship('fils adoptif', [$i6m, $f2d, $i7ma], $fr);
287a004d330SGreg Roach            self::assertRelationship('beau-père', [$i8f, $f2d, $i2f, $f1m, $i1m], $fr);
288a004d330SGreg Roach            self::assertRelationship('belle-fille', [$i1m, $f1m, $i2f, $f2d, $i8f], $fr);
289a004d330SGreg Roach            self::assertRelationship('demi-frère', [$i8f, $f2d, $i2f, $f1m, $i3m], $fr);
290a004d330SGreg Roach            self::assertRelationship('quasi-sœur', [$i8f, $f2d, $i6m, $f13m, $i31m, $f14d, $i33f], $fr);
291a004d330SGreg Roach            self::assertRelationship('beau-père', [$i8f, $f2d, $i6m, $f13m, $i31m], $fr);
292a004d330SGreg Roach            self::assertRelationship('belle-mère', [$i2f, $f1m, $i1m, $f4m, $i12f], $fr);
293a004d330SGreg Roach            self::assertRelationship('belle-fille', [$i12f, $f4m, $i1m, $f1m, $i2f], $fr);
294d8a5ab6eSJonathan Jaubart            // Dynamic relationships
295a004d330SGreg Roach            self::assertRelationship('grand-père paternel', [$i3m, $f1m, $i1m, $f4m, $i11m], $fr);
296a004d330SGreg Roach            self::assertRelationship('grand-mère paternelle', [$i3m, $f1m, $i1m, $f4m, $i12f], $fr);
297a004d330SGreg Roach            self::assertRelationship('grand-père maternel', [$i3m, $f1m, $i2f, $f5m, $i13m], $fr);
298a004d330SGreg Roach            self::assertRelationship('grand-mère maternelle', [$i3m, $f1m, $i2f, $f5m, $i14f], $fr);
299a004d330SGreg Roach            self::assertRelationship('arrière-grand-père paternel', [$i3m, $f1m, $i1m, $f4m, $i11m, $f7, $i16m], $fr);
300a004d330SGreg Roach            self::assertRelationship('arrière-grand-mère paternelle', [$i3m, $f1m, $i1m, $f4m, $i11m, $f7, $i17f], $fr);
301a004d330SGreg Roach            self::assertRelationship('arrière-arrière-grand-père paternel', [$i3m, $f1m, $i1m, $f4m, $i11m, $f7, $i17f, $f8, $i18m], $fr);
302a004d330SGreg Roach            self::assertRelationship('arrière-arrière-grand-mère paternelle', [$i3m, $f1m, $i1m, $f4m, $i11m, $f7, $i17f, $f8, $i19f], $fr);
303a004d330SGreg Roach            self::assertRelationship('arrière-(x3)-grand-père paternel', [$i3m, $f1m, $i1m, $f4m, $i11m, $f7, $i17f, $f8, $i18m, $f9, $i20m], $fr);
304a004d330SGreg Roach            self::assertRelationship('arrière-(x3)-grand-mère paternelle', [$i3m, $f1m, $i1m, $f4m, $i11m, $f7, $i17f, $f8, $i18m, $f9, $i21f], $fr);
305a004d330SGreg Roach            self::assertRelationship('arrière-(x4)-grand-père paternel', [$i3m, $f1m, $i1m, $f4m, $i11m, $f7, $i17f, $f8, $i18m, $f9, $i21f, $f10, $i22m], $fr);
306a004d330SGreg Roach            self::assertRelationship('arrière-(x4)-grand-mère paternelle', [$i3m, $f1m, $i1m, $f4m, $i11m, $f7, $i17f, $f8, $i18m, $f9, $i21f, $f10, $i23f], $fr);
307a004d330SGreg Roach            self::assertRelationship('oncle', [$i18m, $f9, $i21f, $f10, $i24m], $fr);
308a004d330SGreg Roach            self::assertRelationship('grand-oncle', [$i30m, $f8, $i18m, $f9, $i21f, $f10, $i24m], $fr);
309a004d330SGreg Roach            self::assertRelationship('arrière-grand-oncle', [$i11m, $f7, $i17f, $f8, $i18m, $f9, $i21f, $f10, $i24m], $fr);
310a004d330SGreg Roach            self::assertRelationship('neveu', [$i24m, $f10, $i21f, $f9, $i18m], $fr);
311a004d330SGreg Roach            self::assertRelationship('petite-nièce', [$i24m, $f10, $i21f, $f9, $i18m, $f8, $i17f], $fr);
312a004d330SGreg Roach            self::assertRelationship('arrière-petit-neveu', [$i24m, $f10, $i21f, $f9, $i18m, $f8, $i17f, $f7, $i11m], $fr);
313a004d330SGreg Roach            self::assertRelationship('cousine germaine', [$i18m, $f9, $i21f, $f10, $i24m, $f11m, $i26f], $fr);
314a004d330SGreg Roach            self::assertRelationship('cousin issu de germain', [$i30m, $f8, $i18m, $f9, $i21f, $f10, $i24m, $f11m, $i26f, $f12, $i29m], $fr);
315a004d330SGreg 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);
316a004d330SGreg Roach            self::assertRelationship('grand-cousine', [$i30m, $f8, $i18m, $f9, $i21f, $f10, $i24m, $f11m, $i26f], $fr);
317a004d330SGreg Roach            self::assertRelationship('petit-cousin', [$i26f, $f11m, $i24m, $f10, $i21f, $f9, $i18m, $f8, $i30m], $fr);
318a004d330SGreg 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);
319a004d330SGreg 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);
320d8a5ab6eSJonathan Jaubart            // Compound relationships
321a004d330SGreg Roach            self::assertRelationship('ex-époux de l’épouse', [$i1m, $f1m, $i2f, $f2d, $i6m], $fr);
322a004d330SGreg Roach        }
323d8a5ab6eSJonathan Jaubart
324a004d330SGreg Roach        ///////////////////////////////////////////////////////////////////////
3256fcafd02SGreg Roach        // SLOVAK
326a004d330SGreg Roach        ///////////////////////////////////////////////////////////////////////
327a004d330SGreg Roach    }
328a004d330SGreg Roach
329a004d330SGreg Roach    /**
330a004d330SGreg Roach     * @param string                  $expected
331a004d330SGreg Roach     * @param array                   $nodes
332a004d330SGreg Roach     * @param ModuleLanguageInterface $language
333a004d330SGreg Roach     */
334a004d330SGreg Roach    private static function assertRelationship(string $expected, array $nodes, ModuleLanguageInterface $language): void
335a004d330SGreg Roach    {
336a004d330SGreg Roach        $service = new RelationshipService();
337a004d330SGreg Roach        $actual  = $service->nameFromPath($nodes, $language);
338a004d330SGreg Roach        $path    = implode('-', array_map(fn (GedcomRecord $record): string => $record->xref(), $nodes));
339a004d330SGreg Roach        $english = $service->nameFromPath($nodes, new LanguageEnglishUnitedStates());
340a004d330SGreg Roach        $message = 'Language: ' . $language->title() . PHP_EOL . 'Path: ' . $path . ' (' . $english . ')';
341a004d330SGreg Roach
342a004d330SGreg Roach        self::assertSame($expected, $actual, $message);
343a004d330SGreg Roach    }
344a004d330SGreg Roach
345a004d330SGreg Roach    /**
346a004d330SGreg Roach     * Test a relationship name in both directions
347a004d330SGreg Roach     *
348a004d330SGreg Roach     * @param string                  $fwd
349a004d330SGreg Roach     * @param string                  $rev
350a004d330SGreg Roach     * @param array                   $nodes
351a004d330SGreg Roach     * @param ModuleLanguageInterface $language
352a004d330SGreg Roach     */
353a004d330SGreg Roach    private static function assertRelationships(string $fwd, string $rev, array $nodes, ModuleLanguageInterface $language): void
354a004d330SGreg Roach    {
355a004d330SGreg Roach        self::assertRelationship($fwd, $nodes, $language);
356a004d330SGreg Roach        self::assertRelationship($rev, array_reverse($nodes), $language);
3576fcafd02SGreg Roach    }
3586fcafd02SGreg Roach}
359