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