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