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