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