xref: /webtrees/tests/app/SurnameTradition/PatrilinealSurnameTraditionTest.php (revision 9b152ff9230017d2c03aa1bf603a98b18250446d)
1<?php
2
3/**
4 * webtrees: online genealogy
5 * Copyright (C) 2019 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 <http://www.gnu.org/licenses/>.
16 */
17
18declare(strict_types=1);
19
20namespace Fisharebest\Webtrees\SurnameTradition;
21
22use Fisharebest\Webtrees\TestCase;
23
24/**
25 * Test harness for the class PatrilinenalSurnameTradition
26 */
27class PatrilinealSurnameTraditionTest extends TestCase
28{
29    /** @var SurnameTraditionInterface */
30    private $surname_tradition;
31
32    /**
33     * Prepare the environment for these tests
34     *
35     * @return void
36     */
37    protected function setUp(): void
38    {
39        parent::setUp();
40
41        $this->surname_tradition = new PatrilinealSurnameTradition();
42    }
43
44    /**
45     * Test whether married surnames are used
46     *
47     * @covers \Fisharebest\Webtrees\SurnameTradition\PatrilinealSurnameTradition
48     *
49     * @return void
50     */
51    public function testMarriedSurnames(): void
52    {
53        $this->assertFalse($this->surname_tradition->hasMarriedNames());
54    }
55
56    /**
57     * Test whether surnames are used
58     *
59     * @covers \Fisharebest\Webtrees\SurnameTradition\PatrilinealSurnameTradition
60     *
61     * @return void
62     */
63    public function testSurnames(): void
64    {
65        $this->assertTrue($this->surname_tradition->hasSurnames());
66    }
67
68    /**
69     * Test new son names
70     *
71     * @covers \Fisharebest\Webtrees\SurnameTradition\PatrilinealSurnameTradition
72     *
73     * @return void
74     */
75    public function testNewSonNames(): void
76    {
77        $this->assertSame(
78            [
79                'NAME' => '/White/',
80                'SURN' => 'White',
81            ],
82            $this->surname_tradition->newChildNames('John /White/', 'Mary /Black/', 'M')
83        );
84    }
85
86    /**
87     * Test new daughter names
88     *
89     * @covers \Fisharebest\Webtrees\SurnameTradition\PatrilinealSurnameTradition
90     *
91     * @return void
92     */
93    public function testNewDaughterNames(): void
94    {
95        $this->assertSame(
96            [
97                'NAME' => '/White/',
98                'SURN' => 'White',
99            ],
100            $this->surname_tradition->newChildNames('John /White/', 'Mary /Black/', 'F')
101        );
102    }
103
104    /**
105     * Test new child names
106     *
107     * @covers \Fisharebest\Webtrees\SurnameTradition\PatrilinealSurnameTradition
108     *
109     * @return void
110     */
111    public function testNewChildNames(): void
112    {
113        $this->assertSame(
114            [
115                'NAME' => '/White/',
116                'SURN' => 'White',
117            ],
118            $this->surname_tradition->newChildNames('John /White/', 'Mary /Black/', 'U')
119        );
120    }
121
122    /**
123     * Test new child names
124     *
125     * @covers \Fisharebest\Webtrees\SurnameTradition\PatrilinealSurnameTradition
126     *
127     * @return void
128     */
129    public function testNewChildNamesWithSpfx(): void
130    {
131        $this->assertSame(
132            [
133                'NAME' => '/de White/',
134                'SPFX' => 'de',
135                'SURN' => 'White',
136            ],
137            $this->surname_tradition->newChildNames('John /de White/', 'Mary /van Black/', 'U')
138        );
139    }
140
141    /**
142     * Test new child names
143     *
144     * @covers \Fisharebest\Webtrees\SurnameTradition\PatrilinealSurnameTradition
145     *
146     * @return void
147     */
148    public function testNewChildNamesWithNoParentsNames(): void
149    {
150        $this->assertSame(
151            ['NAME' => '//'],
152            $this->surname_tradition->newChildNames('', '', 'U')
153        );
154    }
155
156    /**
157     * Test new father names
158     *
159     * @covers \Fisharebest\Webtrees\SurnameTradition\PatrilinealSurnameTradition
160     *
161     * @return void
162     */
163    public function testNewFatherNames(): void
164    {
165        $this->assertSame(
166            [
167                'NAME' => '/White/',
168                'SURN' => 'White',
169            ],
170            $this->surname_tradition->newParentNames('John /White/', 'M')
171        );
172    }
173
174    /**
175     * Test new mother names
176     *
177     * @covers \Fisharebest\Webtrees\SurnameTradition\PatrilinealSurnameTradition
178     *
179     * @return void
180     */
181    public function testNewMotherNames(): void
182    {
183        $this->assertSame(
184            ['NAME' => '//'],
185            $this->surname_tradition->newParentNames('John /White/', 'F')
186        );
187    }
188
189    /**
190     * Test new parent names
191     *
192     * @covers \Fisharebest\Webtrees\SurnameTradition\PatrilinealSurnameTradition
193     *
194     * @return void
195     */
196    public function testNewParentNames(): void
197    {
198        $this->assertSame(
199            ['NAME' => '//'],
200            $this->surname_tradition->newParentNames('John /White/', 'U')
201        );
202    }
203
204    /**
205     * Test new husband names
206     *
207     * @covers \Fisharebest\Webtrees\SurnameTradition\PatrilinealSurnameTradition
208     *
209     * @return void
210     */
211    public function testNewHusbandNames(): void
212    {
213        $this->assertSame(
214            ['NAME' => '//'],
215            $this->surname_tradition->newSpouseNames('Mary /Black/', 'M')
216        );
217    }
218
219    /**
220     * Test new wife names
221     *
222     * @covers \Fisharebest\Webtrees\SurnameTradition\PatrilinealSurnameTradition
223     *
224     * @return void
225     */
226    public function testNewWifeNames(): void
227    {
228        $this->assertSame(
229            ['NAME' => '//'],
230            $this->surname_tradition->newSpouseNames('John /White/', 'F')
231        );
232    }
233
234    /**
235     * Test new spouse names
236     *
237     * @covers \Fisharebest\Webtrees\SurnameTradition\PatrilinealSurnameTradition
238     *
239     * @return void
240     */
241    public function testNewSpouseNames(): void
242    {
243        $this->assertSame(
244            ['NAME' => '//'],
245            $this->surname_tradition->newSpouseNames('Chris /Green/', 'U')
246        );
247    }
248}
249