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