xref: /webtrees/tests/app/SurnameTradition/PatrilinealSurnameTraditionTest.php (revision 5c48bcd62613a083ce0d1998e379b7010eee8985)
1<?php
2/**
3 * webtrees: online genealogy
4 * Copyright (C) 2019 webtrees development team
5 * This program is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation, either version 3 of the License, or
8 * (at your option) any later version.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 */
16declare(strict_types=1);
17
18namespace Fisharebest\Webtrees\SurnameTradition;
19
20/**
21 * Test harness for the class PatrilinenalSurnameTradition
22 */
23class PatrilinealSurnameTraditionTest extends \Fisharebest\Webtrees\TestCase
24{
25    /** @var SurnameTraditionInterface */
26    private $surname_tradition;
27
28    /**
29     * Prepare the environment for these tests
30     *
31     * @return void
32     */
33    protected function setUp(): void
34    {
35        parent::setUp();
36
37        $this->surname_tradition = new PatrilinealSurnameTradition();
38    }
39
40    /**
41     * Test whether married surnames are used
42     *
43     * @covers \Fisharebest\Webtrees\SurnameTradition\PatrilinealSurnameTradition
44     *
45     * @return void
46     */
47    public function testMarriedSurnames(): void
48    {
49        $this->assertSame(false, $this->surname_tradition->hasMarriedNames());
50    }
51
52    /**
53     * Test whether surnames are used
54     *
55     * @covers \Fisharebest\Webtrees\SurnameTradition\PatrilinealSurnameTradition
56     *
57     * @return void
58     */
59    public function testSurnames(): void
60    {
61        $this->assertSame(true, $this->surname_tradition->hasSurnames());
62    }
63
64    /**
65     * Test new son names
66     *
67     * @covers \Fisharebest\Webtrees\SurnameTradition\PatrilinealSurnameTradition
68     *
69     * @return void
70     */
71    public function testNewSonNames(): void
72    {
73        $this->assertSame(
74            [
75                'NAME' => '/White/',
76                'SURN' => 'White',
77            ],
78            $this->surname_tradition->newChildNames('John /White/', 'Mary /Black/', 'M')
79        );
80    }
81
82    /**
83     * Test new daughter names
84     *
85     * @covers \Fisharebest\Webtrees\SurnameTradition\PatrilinealSurnameTradition
86     *
87     * @return void
88     */
89    public function testNewDaughterNames(): void
90    {
91        $this->assertSame(
92            [
93                'NAME' => '/White/',
94                'SURN' => 'White',
95            ],
96            $this->surname_tradition->newChildNames('John /White/', 'Mary /Black/', 'F')
97        );
98    }
99
100    /**
101     * Test new child names
102     *
103     * @covers \Fisharebest\Webtrees\SurnameTradition\PatrilinealSurnameTradition
104     *
105     * @return void
106     */
107    public function testNewChildNames(): void
108    {
109        $this->assertSame(
110            [
111                'NAME' => '/White/',
112                'SURN' => 'White',
113            ],
114            $this->surname_tradition->newChildNames('John /White/', 'Mary /Black/', 'U')
115        );
116    }
117
118    /**
119     * Test new child names
120     *
121     * @covers \Fisharebest\Webtrees\SurnameTradition\PatrilinealSurnameTradition
122     *
123     * @return void
124     */
125    public function testNewChildNamesWithSpfx(): void
126    {
127        $this->assertSame(
128            [
129                'NAME' => '/de White/',
130                'SPFX' => 'de',
131                'SURN' => 'White',
132            ],
133            $this->surname_tradition->newChildNames('John /de White/', 'Mary /van Black/', 'U')
134        );
135    }
136
137    /**
138     * Test new child names
139     *
140     * @covers \Fisharebest\Webtrees\SurnameTradition\PatrilinealSurnameTradition
141     *
142     * @return void
143     */
144    public function testNewChildNamesWithNoParentsNames(): void
145    {
146        $this->assertSame(
147            ['NAME' => '//'],
148            $this->surname_tradition->newChildNames('', '', 'U')
149        );
150    }
151
152    /**
153     * Test new father names
154     *
155     * @covers \Fisharebest\Webtrees\SurnameTradition\PatrilinealSurnameTradition
156     *
157     * @return void
158     */
159    public function testNewFatherNames(): void
160    {
161        $this->assertSame(
162            [
163                'NAME' => '/White/',
164                'SURN' => 'White',
165            ],
166            $this->surname_tradition->newParentNames('John /White/', 'M')
167        );
168    }
169
170    /**
171     * Test new mother names
172     *
173     * @covers \Fisharebest\Webtrees\SurnameTradition\PatrilinealSurnameTradition
174     *
175     * @return void
176     */
177    public function testNewMotherNames(): void
178    {
179        $this->assertSame(
180            ['NAME' => '//'],
181            $this->surname_tradition->newParentNames('John /White/', 'F')
182        );
183    }
184
185    /**
186     * Test new parent names
187     *
188     * @covers \Fisharebest\Webtrees\SurnameTradition\PatrilinealSurnameTradition
189     *
190     * @return void
191     */
192    public function testNewParentNames(): void
193    {
194        $this->assertSame(
195            ['NAME' => '//'],
196            $this->surname_tradition->newParentNames('John /White/', 'U')
197        );
198    }
199
200    /**
201     * Test new husband names
202     *
203     * @covers \Fisharebest\Webtrees\SurnameTradition\PatrilinealSurnameTradition
204     *
205     * @return void
206     */
207    public function testNewHusbandNames(): void
208    {
209        $this->assertSame(
210            ['NAME' => '//'],
211            $this->surname_tradition->newSpouseNames('Mary /Black/', 'M')
212        );
213    }
214
215    /**
216     * Test new wife names
217     *
218     * @covers \Fisharebest\Webtrees\SurnameTradition\PatrilinealSurnameTradition
219     *
220     * @return void
221     */
222    public function testNewWifeNames(): void
223    {
224        $this->assertSame(
225            ['NAME' => '//'],
226            $this->surname_tradition->newSpouseNames('John /White/', 'F')
227        );
228    }
229
230    /**
231     * Test new spouse names
232     *
233     * @covers \Fisharebest\Webtrees\SurnameTradition\PatrilinealSurnameTradition
234     *
235     * @return void
236     */
237    public function testNewSpouseNames(): void
238    {
239        $this->assertSame(
240            ['NAME' => '//'],
241            $this->surname_tradition->newSpouseNames('Chris /Green/', 'U')
242        );
243    }
244}
245