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