xref: /webtrees/tests/app/SurnameTradition/SpanishSurnameTraditionTest.php (revision 73df4c545c87012519818766e1a8eb02272a59b5)
1<?php
2
3/**
4 * webtrees: online genealogy
5 * Copyright (C) 2016 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\SpanishSurnameTradition;
18use Fisharebest\Webtrees\SurnameTradition\SurnameTraditionInterface;
19
20/**
21 * Test harness for the class SpanishSurnameTradition
22 */
23class SpanishSurnameTraditionTest 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 SpanishSurnameTradition;
32	}
33
34	/**
35	 * Test whether married surnames are used
36	 *
37	 * @covers Fisharebest\Webtrees\SurnameTradition\SpanishSurnameTradition
38	 */
39	public function testMarriedSurnames() {
40		$this->assertSame(false, $this->surname_tradition->hasMarriedNames());
41	}
42
43	/**
44	 * Test whether surnames are used
45	 *
46	 * @covers Fisharebest\Webtrees\SurnameTradition\SpanishSurnameTradition
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\SpanishSurnameTradition
56	 */
57	public function testNewSonNames() {
58		$this->assertSame(
59			array('NAME' => '/Garcia/ /Ruiz/', 'SURN' => 'Garcia,Ruiz'),
60			$this->surname_tradition->newChildNames('Gabriel /Garcia/ /Iglesias/', 'Maria /Ruiz/ /Lorca/', 'M')
61		);
62	}
63
64	/**
65	 * Test new daughter names
66	 *
67	 * @covers Fisharebest\Webtrees\SurnameTradition\SpanishSurnameTradition
68	 */
69	public function testNewDaughterNames() {
70		$this->assertSame(
71			array('NAME' => '/Garcia/ /Ruiz/', 'SURN' => 'Garcia,Ruiz'),
72			$this->surname_tradition->newChildNames('Gabriel /Garcia/ /Iglesias/', 'Maria /Ruiz/ /Lorca/', 'M')
73		);
74	}
75
76	/**
77	 * Test new child names
78	 *
79	 * @covers Fisharebest\Webtrees\SurnameTradition\SpanishSurnameTradition
80	 */
81	public function testNewChildNames() {
82		$this->assertSame(
83			array('NAME' => '/Garcia/ /Ruiz/', 'SURN' => 'Garcia,Ruiz'),
84			$this->surname_tradition->newChildNames('Gabriel /Garcia/ /Iglesias/', 'Maria /Ruiz/ /Lorca/', 'M')
85		);
86	}
87
88	/**
89	 * Test new child names
90	 *
91	 * @covers Fisharebest\Webtrees\SurnameTradition\SpanishSurnameTradition
92	 */
93	public function testNewChildNamesWithNoParentsNames() {
94		$this->assertSame(
95			array('NAME' => '// //', 'SURN' => ''),
96			$this->surname_tradition->newChildNames('', '', 'U')
97		);
98	}
99
100	/**
101	 * Test new child names
102	 *
103	 * @covers Fisharebest\Webtrees\SurnameTradition\SpanishSurnameTradition
104	 */
105	public function testNewChildNamesCompunds() {
106		$this->assertSame(
107			array('NAME' => '/Garcia/ /Ruiz/', 'SURN' => 'Garcia,Ruiz'),
108			$this->surname_tradition->newChildNames('Gabriel /Garcia Iglesias/', 'Maria /Ruiz Lorca/', 'M')
109		);
110		$this->assertSame(
111			array('NAME' => '/Garcia/ /Ruiz/', 'SURN' => 'Garcia,Ruiz'),
112			$this->surname_tradition->newChildNames('Gabriel /Garcia y Iglesias/', 'Maria /Ruiz y Lorca/', 'M')
113		);
114	}
115
116	/**
117	 * Test new father names
118	 *
119	 * @covers Fisharebest\Webtrees\SurnameTradition\SpanishSurnameTradition
120	 */
121	public function testNewFatherNames() {
122		$this->assertSame(
123			array('NAME' => '/Garcia/ //', 'SURN' => 'Garcia'),
124			$this->surname_tradition->newParentNames('Gabriel /Garcia/ /Iglesias/', 'M')
125		);
126	}
127
128	/**
129	 * Test new mother names
130	 *
131	 * @covers Fisharebest\Webtrees\SurnameTradition\SpanishSurnameTradition
132	 */
133	public function testNewMotherNames() {
134		$this->assertSame(
135			array('NAME' => '/Iglesias/ //', 'SURN' => 'Iglesias'),
136			$this->surname_tradition->newParentNames('Gabriel /Garcia/ /Iglesias/', 'F')
137		);
138	}
139
140	/**
141	 * Test new parent names
142	 *
143	 * @covers Fisharebest\Webtrees\SurnameTradition\SpanishSurnameTradition
144	 */
145	public function testNewParentNames() {
146		$this->assertSame(
147			array('NAME' => '// //'),
148			$this->surname_tradition->newParentNames('Gabriel /Garcia/ /Iglesias/', 'U')
149		);
150	}
151
152	/**
153	 * Test new husband names
154	 *
155	 * @covers Fisharebest\Webtrees\SurnameTradition\SpanishSurnameTradition
156	 */
157	public function testNewHusbandNames() {
158		$this->assertSame(
159			array('NAME' => '// //'),
160			$this->surname_tradition->newSpouseNames('Maria /Ruiz/ /Lorca/', 'M')
161		);
162	}
163
164	/**
165	 * Test new wife names
166	 *
167	 * @covers Fisharebest\Webtrees\SurnameTradition\SpanishSurnameTradition
168	 */
169	public function testNewWifeNames() {
170		$this->assertSame(
171			array('NAME' => '// //'),
172			$this->surname_tradition->newSpouseNames('Gabriel /Garcia/ /Iglesias/', 'F')
173		);
174	}
175
176	/**
177	 * Test new spouse names
178	 *
179	 * @covers Fisharebest\Webtrees\SurnameTradition\SpanishSurnameTradition
180	 */
181	public function testNewSpouseNames() {
182		$this->assertSame(
183			array('NAME' => '// //'),
184			$this->surname_tradition->newSpouseNames('Gabriel /Garcia/ /Iglesias/', 'U')
185		);
186	}
187}
188