xref: /webtrees/tests/app/SurnameTradition/PaternalSurnameTraditionTest.php (revision 84e2cf4e2b1803b300330f631d304db1a3c443dd)
1323788f4SGreg Roach<?php
2323788f4SGreg Roach/**
3323788f4SGreg Roach * webtrees: online genealogy
41062a142SGreg Roach * Copyright (C) 2018 webtrees development team
5323788f4SGreg Roach * This program is free software: you can redistribute it and/or modify
6323788f4SGreg Roach * it under the terms of the GNU General Public License as published by
7323788f4SGreg Roach * the Free Software Foundation, either version 3 of the License, or
8323788f4SGreg Roach * (at your option) any later version.
9323788f4SGreg Roach * This program is distributed in the hope that it will be useful,
10323788f4SGreg Roach * but WITHOUT ANY WARRANTY; without even the implied warranty of
11323788f4SGreg Roach * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12323788f4SGreg Roach * GNU General Public License for more details.
13323788f4SGreg Roach * You should have received a copy of the GNU General Public License
14323788f4SGreg Roach * along with this program. If not, see <http://www.gnu.org/licenses/>.
15323788f4SGreg Roach */
16*84e2cf4eSGreg Roachnamespace Fisharebest\Webtrees\SurnameTradition;
17c1010edaSGreg Roach
18323788f4SGreg Roachuse Fisharebest\Webtrees\SurnameTradition\PaternalSurnameTradition;
19323788f4SGreg Roachuse Fisharebest\Webtrees\SurnameTradition\SurnameTraditionInterface;
20323788f4SGreg Roach
21323788f4SGreg Roach/**
22323788f4SGreg Roach * Test harness for the class PaternalSurnameTradition
23323788f4SGreg Roach */
24*84e2cf4eSGreg Roachclass PaternalSurnameTraditionTest extends \Fisharebest\Webtrees\TestCase
25c1010edaSGreg Roach{
26323788f4SGreg Roach    /** @var SurnameTraditionInterface */
27323788f4SGreg Roach    private $surname_tradition;
28323788f4SGreg Roach
29323788f4SGreg Roach    /**
30323788f4SGreg Roach     * Prepare the environment for these tests
31323788f4SGreg Roach     */
32c1010edaSGreg Roach    public function setUp()
33c1010edaSGreg Roach    {
34323788f4SGreg Roach        $this->surname_tradition = new PaternalSurnameTradition;
35323788f4SGreg Roach    }
36323788f4SGreg Roach
37323788f4SGreg Roach    /**
38323788f4SGreg Roach     * Test whether married surnames are used
3917d74f3aSGreg Roach     *
4015d603e7SGreg Roach     * @covers \Fisharebest\Webtrees\SurnameTradition\PaternalSurnameTradition
41323788f4SGreg Roach     */
42c1010edaSGreg Roach    public function testMarriedSurnames()
43c1010edaSGreg Roach    {
44323788f4SGreg Roach        $this->assertSame(true, $this->surname_tradition->hasMarriedNames());
45323788f4SGreg Roach    }
46323788f4SGreg Roach
47323788f4SGreg Roach    /**
48c1ec7145SGreg Roach     * Test whether surnames are used
4917d74f3aSGreg Roach     *
5015d603e7SGreg Roach     * @covers \Fisharebest\Webtrees\SurnameTradition\PaternalSurnameTradition
51c1ec7145SGreg Roach     */
52c1010edaSGreg Roach    public function testSurnames()
53c1010edaSGreg Roach    {
54c1ec7145SGreg Roach        $this->assertSame(true, $this->surname_tradition->hasSurnames());
55c1ec7145SGreg Roach    }
56c1ec7145SGreg Roach
57c1ec7145SGreg Roach    /**
58323788f4SGreg Roach     * Test new son names
5917d74f3aSGreg Roach     *
6015d603e7SGreg Roach     * @covers \Fisharebest\Webtrees\SurnameTradition\PaternalSurnameTradition
61323788f4SGreg Roach     */
62c1010edaSGreg Roach    public function testNewSonNames()
63c1010edaSGreg Roach    {
64323788f4SGreg Roach        $this->assertSame(
65c1010edaSGreg Roach            [
66c1010edaSGreg Roach                'NAME' => '/White/',
67c1010edaSGreg Roach                'SURN' => 'White',
68c1010edaSGreg Roach            ],
69323788f4SGreg Roach            $this->surname_tradition->newChildNames('John /White/', 'Mary /Black/', 'M')
70323788f4SGreg Roach        );
71323788f4SGreg Roach    }
72323788f4SGreg Roach
73323788f4SGreg Roach    /**
74323788f4SGreg Roach     * Test new daughter names
7517d74f3aSGreg Roach     *
7615d603e7SGreg Roach     * @covers \Fisharebest\Webtrees\SurnameTradition\PaternalSurnameTradition
77323788f4SGreg Roach     */
78c1010edaSGreg Roach    public function testNewDaughterNames()
79c1010edaSGreg Roach    {
80323788f4SGreg Roach        $this->assertSame(
81c1010edaSGreg Roach            [
82c1010edaSGreg Roach                'NAME' => '/White/',
83c1010edaSGreg Roach                'SURN' => 'White',
84c1010edaSGreg Roach            ],
85323788f4SGreg Roach            $this->surname_tradition->newChildNames('John /White/', 'Mary /Black/', 'F')
86323788f4SGreg Roach        );
87323788f4SGreg Roach    }
88323788f4SGreg Roach
89323788f4SGreg Roach    /**
90323788f4SGreg Roach     * Test new child names
9117d74f3aSGreg Roach     *
9215d603e7SGreg Roach     * @covers \Fisharebest\Webtrees\SurnameTradition\PaternalSurnameTradition
93323788f4SGreg Roach     */
94c1010edaSGreg Roach    public function testNewChildNames()
95c1010edaSGreg Roach    {
96323788f4SGreg Roach        $this->assertSame(
97c1010edaSGreg Roach            [
98c1010edaSGreg Roach                'NAME' => '/White/',
99c1010edaSGreg Roach                'SURN' => 'White',
100c1010edaSGreg Roach            ],
101323788f4SGreg Roach            $this->surname_tradition->newChildNames('John /White/', 'Mary /Black/', 'U')
102323788f4SGreg Roach        );
103323788f4SGreg Roach    }
104323788f4SGreg Roach
105323788f4SGreg Roach    /**
106323788f4SGreg Roach     * Test new child names
10717d74f3aSGreg Roach     *
10815d603e7SGreg Roach     * @covers \Fisharebest\Webtrees\SurnameTradition\PaternalSurnameTradition
109323788f4SGreg Roach     */
110c1010edaSGreg Roach    public function testNewChildNamesWithSpfx()
111c1010edaSGreg Roach    {
112323788f4SGreg Roach        $this->assertSame(
113c1010edaSGreg Roach            [
114c1010edaSGreg Roach                'NAME' => '/de White/',
115c1010edaSGreg Roach                'SPFX' => 'de',
116c1010edaSGreg Roach                'SURN' => 'White',
117c1010edaSGreg Roach            ],
118323788f4SGreg Roach            $this->surname_tradition->newChildNames('John /de White/', 'Mary /van Black/', 'U')
119323788f4SGreg Roach        );
120323788f4SGreg Roach    }
121323788f4SGreg Roach
122323788f4SGreg Roach    /**
1238caf8226SGreg Roach     * Test new child names
1248caf8226SGreg Roach     *
12515d603e7SGreg Roach     * @covers \Fisharebest\Webtrees\SurnameTradition\PaternalSurnameTradition
1268caf8226SGreg Roach     */
127c1010edaSGreg Roach    public function testNewChildNamesWithMultipleSpfx()
128c1010edaSGreg Roach    {
1298caf8226SGreg Roach        $this->assertSame(
130c1010edaSGreg Roach            [
131c1010edaSGreg Roach                'NAME' => '/van der White/',
132c1010edaSGreg Roach                'SPFX' => 'van der',
133c1010edaSGreg Roach                'SURN' => 'White',
134c1010edaSGreg Roach            ],
1358caf8226SGreg Roach            $this->surname_tradition->newChildNames('John /van der White/', 'Mary /van Black/', 'U')
1368caf8226SGreg Roach        );
1378caf8226SGreg Roach    }
1388caf8226SGreg Roach
1398caf8226SGreg Roach    /**
1409797fe2eSGreg Roach     * Test new child names
1419797fe2eSGreg Roach     *
14215d603e7SGreg Roach     * @covers \Fisharebest\Webtrees\SurnameTradition\PaternalSurnameTradition
1439797fe2eSGreg Roach     */
144c1010edaSGreg Roach    public function testNewChildNamesWithDutchSpfx()
145c1010edaSGreg Roach    {
1469797fe2eSGreg Roach        $this->assertSame(
147c1010edaSGreg Roach            [
148c1010edaSGreg Roach                'NAME' => '/\'t White/',
149c1010edaSGreg Roach                'SPFX' => '\'t',
150c1010edaSGreg Roach                'SURN' => 'White',
151c1010edaSGreg Roach            ],
1529797fe2eSGreg Roach            $this->surname_tradition->newChildNames('John /\'t White/', 'Mary /van Black/', 'U')
1539797fe2eSGreg Roach        );
1549797fe2eSGreg Roach        $this->assertSame(
155c1010edaSGreg Roach            [
156c1010edaSGreg Roach                'NAME' => '/’t White/',
157c1010edaSGreg Roach                'SPFX' => '’t',
158c1010edaSGreg Roach                'SURN' => 'White',
159c1010edaSGreg Roach            ],
1609797fe2eSGreg Roach            $this->surname_tradition->newChildNames('John /’t White/', 'Mary /van Black/', 'U')
1619797fe2eSGreg Roach        );
1629797fe2eSGreg Roach    }
1639797fe2eSGreg Roach
1649797fe2eSGreg Roach    /**
1659797fe2eSGreg Roach     * Test new child names
1669797fe2eSGreg Roach     *
16715d603e7SGreg Roach     * @covers \Fisharebest\Webtrees\SurnameTradition\PaternalSurnameTradition
1689797fe2eSGreg Roach     */
169c1010edaSGreg Roach    public function testNewChildNamesWithMultipleDutchSpfx()
170c1010edaSGreg Roach    {
1719797fe2eSGreg Roach        $this->assertSame(
172c1010edaSGreg Roach            [
173c1010edaSGreg Roach                'NAME' => '/van \'t White/',
174c1010edaSGreg Roach                'SPFX' => 'van \'t',
175c1010edaSGreg Roach                'SURN' => 'White',
176c1010edaSGreg Roach            ],
1779797fe2eSGreg Roach            $this->surname_tradition->newChildNames('John /van \'t White/', 'Mary /van Black/', 'U')
1789797fe2eSGreg Roach        );
1799797fe2eSGreg Roach        $this->assertSame(
180c1010edaSGreg Roach            [
181c1010edaSGreg Roach                'NAME' => '/van ’t White/',
182c1010edaSGreg Roach                'SPFX' => 'van ’t',
183c1010edaSGreg Roach                'SURN' => 'White',
184c1010edaSGreg Roach            ],
1859797fe2eSGreg Roach            $this->surname_tradition->newChildNames('John /van ’t White/', 'Mary /van Black/', 'U')
1869797fe2eSGreg Roach        );
1879797fe2eSGreg Roach    }
1889797fe2eSGreg Roach
1899797fe2eSGreg Roach    /**
190323788f4SGreg Roach     * Test new father names
19117d74f3aSGreg Roach     *
19215d603e7SGreg Roach     * @covers \Fisharebest\Webtrees\SurnameTradition\PaternalSurnameTradition
193323788f4SGreg Roach     */
194c1010edaSGreg Roach    public function testNewFatherNames()
195c1010edaSGreg Roach    {
196323788f4SGreg Roach        $this->assertSame(
197c1010edaSGreg Roach            [
198c1010edaSGreg Roach                'NAME' => '/White/',
199c1010edaSGreg Roach                'SURN' => 'White',
200c1010edaSGreg Roach            ],
201323788f4SGreg Roach            $this->surname_tradition->newParentNames('John /White/', 'M')
202323788f4SGreg Roach        );
203323788f4SGreg Roach    }
204323788f4SGreg Roach
205323788f4SGreg Roach    /**
206323788f4SGreg Roach     * Test new mother names
20717d74f3aSGreg Roach     *
20815d603e7SGreg Roach     * @covers \Fisharebest\Webtrees\SurnameTradition\PaternalSurnameTradition
209323788f4SGreg Roach     */
210c1010edaSGreg Roach    public function testNewMotherNames()
211c1010edaSGreg Roach    {
212323788f4SGreg Roach        $this->assertSame(
213c1010edaSGreg Roach            [
214c1010edaSGreg Roach                'NAME'   => '//',
215c1010edaSGreg Roach                '_MARNM' => '/White/',
216c1010edaSGreg Roach            ],
217323788f4SGreg Roach            $this->surname_tradition->newParentNames('John /White/', 'F')
218323788f4SGreg Roach        );
219323788f4SGreg Roach    }
220323788f4SGreg Roach
221323788f4SGreg Roach    /**
222323788f4SGreg Roach     * Test new parent names
22317d74f3aSGreg Roach     *
22415d603e7SGreg Roach     * @covers \Fisharebest\Webtrees\SurnameTradition\PaternalSurnameTradition
225323788f4SGreg Roach     */
226c1010edaSGreg Roach    public function testNewParentNames()
227c1010edaSGreg Roach    {
228323788f4SGreg Roach        $this->assertSame(
22913abd6f3SGreg Roach            ['NAME' => '//'],
230323788f4SGreg Roach            $this->surname_tradition->newParentNames('John /White/', 'U')
231323788f4SGreg Roach        );
232323788f4SGreg Roach    }
233323788f4SGreg Roach
234323788f4SGreg Roach    /**
235323788f4SGreg Roach     * Test new husband names
23617d74f3aSGreg Roach     *
23715d603e7SGreg Roach     * @covers \Fisharebest\Webtrees\SurnameTradition\PaternalSurnameTradition
238323788f4SGreg Roach     */
239c1010edaSGreg Roach    public function testNewHusbandNames()
240c1010edaSGreg Roach    {
241323788f4SGreg Roach        $this->assertSame(
24213abd6f3SGreg Roach            ['NAME' => '//'],
243323788f4SGreg Roach            $this->surname_tradition->newSpouseNames('Mary /Black/', 'M')
244323788f4SGreg Roach        );
245323788f4SGreg Roach    }
246323788f4SGreg Roach
247323788f4SGreg Roach    /**
248323788f4SGreg Roach     * Test new wife names
24917d74f3aSGreg Roach     *
25015d603e7SGreg Roach     * @covers \Fisharebest\Webtrees\SurnameTradition\PaternalSurnameTradition
251323788f4SGreg Roach     */
252c1010edaSGreg Roach    public function testNewWifeNames()
253c1010edaSGreg Roach    {
254323788f4SGreg Roach        $this->assertSame(
255c1010edaSGreg Roach            [
256c1010edaSGreg Roach                'NAME'   => '//',
257c1010edaSGreg Roach                '_MARNM' => '/White/',
258c1010edaSGreg Roach            ],
259323788f4SGreg Roach            $this->surname_tradition->newSpouseNames('John /White/', 'F')
260323788f4SGreg Roach        );
261323788f4SGreg Roach    }
262323788f4SGreg Roach
263323788f4SGreg Roach    /**
2645b2de99fSGreg Roach     * Test new wife names
2655b2de99fSGreg Roach     *
26615d603e7SGreg Roach     * @covers \Fisharebest\Webtrees\SurnameTradition\PaternalSurnameTradition
2675b2de99fSGreg Roach     */
268c1010edaSGreg Roach    public function testNewWifeNamesWithSpfx()
269c1010edaSGreg Roach    {
2705b2de99fSGreg Roach        $this->assertSame(
271c1010edaSGreg Roach            [
272c1010edaSGreg Roach                'NAME'   => '//',
273c1010edaSGreg Roach                '_MARNM' => '/van der White/',
274c1010edaSGreg Roach            ],
2755b2de99fSGreg Roach            $this->surname_tradition->newSpouseNames('John /van der White/', 'F')
2765b2de99fSGreg Roach        );
2775b2de99fSGreg Roach    }
2785b2de99fSGreg Roach
2795b2de99fSGreg Roach    /**
280323788f4SGreg Roach     * Test new spouse names
28117d74f3aSGreg Roach     *
28215d603e7SGreg Roach     * @covers \Fisharebest\Webtrees\SurnameTradition\PaternalSurnameTradition
283323788f4SGreg Roach     */
284c1010edaSGreg Roach    public function testNewSpouseNames()
285c1010edaSGreg Roach    {
286323788f4SGreg Roach        $this->assertSame(
28713abd6f3SGreg Roach            ['NAME' => '//'],
288323788f4SGreg Roach            $this->surname_tradition->newSpouseNames('Chris /Green/', 'U')
289323788f4SGreg Roach        );
290323788f4SGreg Roach    }
291323788f4SGreg Roach}
292