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