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