xref: /webtrees/tests/app/SurnameTradition/SpanishSurnameTraditionTest.php (revision 3cfcc809af53e831fa6cafac7b274a2cb407db6e)
1323788f4SGreg Roach<?php
23976b470SGreg Roach
3323788f4SGreg Roach/**
4323788f4SGreg Roach * webtrees: online genealogy
58fcd0d32SGreg Roach * Copyright (C) 2019 webtrees development team
6323788f4SGreg Roach * This program is free software: you can redistribute it and/or modify
7323788f4SGreg Roach * it under the terms of the GNU General Public License as published by
8323788f4SGreg Roach * the Free Software Foundation, either version 3 of the License, or
9323788f4SGreg Roach * (at your option) any later version.
10323788f4SGreg Roach * This program is distributed in the hope that it will be useful,
11323788f4SGreg Roach * but WITHOUT ANY WARRANTY; without even the implied warranty of
12323788f4SGreg Roach * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13323788f4SGreg Roach * GNU General Public License for more details.
14323788f4SGreg Roach * You should have received a copy of the GNU General Public License
15323788f4SGreg Roach * along with this program. If not, see <http://www.gnu.org/licenses/>.
16323788f4SGreg Roach */
17e7f56f2aSGreg Roachdeclare(strict_types=1);
18e7f56f2aSGreg Roach
1984e2cf4eSGreg Roachnamespace Fisharebest\Webtrees\SurnameTradition;
20c1010edaSGreg Roach
21*3cfcc809SGreg Roachuse Fisharebest\Webtrees\TestCase;
22*3cfcc809SGreg Roach
23323788f4SGreg Roach/**
24323788f4SGreg Roach * Test harness for the class SpanishSurnameTradition
25323788f4SGreg Roach */
26*3cfcc809SGreg Roachclass SpanishSurnameTraditionTest extends TestCase
27c1010edaSGreg Roach{
28323788f4SGreg Roach    /** @var SurnameTraditionInterface */
29323788f4SGreg Roach    private $surname_tradition;
30323788f4SGreg Roach
31323788f4SGreg Roach    /**
32323788f4SGreg Roach     * Prepare the environment for these tests
3352348eb8SGreg Roach     *
3452348eb8SGreg Roach     * @return void
35323788f4SGreg Roach     */
365c48bcd6SGreg Roach    protected function setUp(): void
37c1010edaSGreg Roach    {
380115bc16SGreg Roach        parent::setUp();
390115bc16SGreg Roach
4074d6dc0eSGreg Roach        $this->surname_tradition = new SpanishSurnameTradition();
41323788f4SGreg Roach    }
42323788f4SGreg Roach
43323788f4SGreg Roach    /**
44323788f4SGreg Roach     * Test whether married surnames are used
4517d74f3aSGreg Roach     *
4615d603e7SGreg Roach     * @covers \Fisharebest\Webtrees\SurnameTradition\SpanishSurnameTradition
4752348eb8SGreg Roach     *
4852348eb8SGreg Roach     * @return void
49323788f4SGreg Roach     */
509b802b22SGreg Roach    public function testMarriedSurnames(): void
51c1010edaSGreg Roach    {
52a32e6421SGreg Roach        $this->assertFalse($this->surname_tradition->hasMarriedNames());
53323788f4SGreg Roach    }
54323788f4SGreg Roach
55323788f4SGreg Roach    /**
56c1ec7145SGreg Roach     * Test whether surnames are used
5717d74f3aSGreg Roach     *
5815d603e7SGreg Roach     * @covers \Fisharebest\Webtrees\SurnameTradition\SpanishSurnameTradition
5952348eb8SGreg Roach     *
6052348eb8SGreg Roach     * @return void
61c1ec7145SGreg Roach     */
629b802b22SGreg Roach    public function testSurnames(): void
63c1010edaSGreg Roach    {
64a32e6421SGreg Roach        $this->assertTrue($this->surname_tradition->hasSurnames());
65c1ec7145SGreg Roach    }
66c1ec7145SGreg Roach
67c1ec7145SGreg Roach    /**
68323788f4SGreg Roach     * Test new son names
6917d74f3aSGreg Roach     *
7015d603e7SGreg Roach     * @covers \Fisharebest\Webtrees\SurnameTradition\SpanishSurnameTradition
7152348eb8SGreg Roach     *
7252348eb8SGreg Roach     * @return void
73323788f4SGreg Roach     */
749b802b22SGreg Roach    public function testNewSonNames(): void
75c1010edaSGreg Roach    {
76323788f4SGreg Roach        $this->assertSame(
77c1010edaSGreg Roach            [
78c1010edaSGreg Roach                'NAME' => '/Garcia/ /Ruiz/',
79c1010edaSGreg Roach                'SURN' => 'Garcia,Ruiz',
80c1010edaSGreg Roach            ],
81323788f4SGreg Roach            $this->surname_tradition->newChildNames('Gabriel /Garcia/ /Iglesias/', 'Maria /Ruiz/ /Lorca/', 'M')
82323788f4SGreg Roach        );
83323788f4SGreg Roach    }
84323788f4SGreg Roach
85323788f4SGreg Roach    /**
86323788f4SGreg Roach     * Test new daughter names
8717d74f3aSGreg Roach     *
8815d603e7SGreg Roach     * @covers \Fisharebest\Webtrees\SurnameTradition\SpanishSurnameTradition
8952348eb8SGreg Roach     *
9052348eb8SGreg Roach     * @return void
91323788f4SGreg Roach     */
929b802b22SGreg Roach    public function testNewDaughterNames(): void
93c1010edaSGreg Roach    {
94323788f4SGreg Roach        $this->assertSame(
95c1010edaSGreg Roach            [
96c1010edaSGreg Roach                'NAME' => '/Garcia/ /Ruiz/',
97c1010edaSGreg Roach                'SURN' => 'Garcia,Ruiz',
98c1010edaSGreg Roach            ],
99323788f4SGreg Roach            $this->surname_tradition->newChildNames('Gabriel /Garcia/ /Iglesias/', 'Maria /Ruiz/ /Lorca/', 'M')
100323788f4SGreg Roach        );
101323788f4SGreg Roach    }
102323788f4SGreg Roach
103323788f4SGreg Roach    /**
104323788f4SGreg Roach     * Test new child names
10517d74f3aSGreg Roach     *
10615d603e7SGreg Roach     * @covers \Fisharebest\Webtrees\SurnameTradition\SpanishSurnameTradition
10752348eb8SGreg Roach     *
10852348eb8SGreg Roach     * @return void
109323788f4SGreg Roach     */
1109b802b22SGreg Roach    public function testNewChildNames(): void
111c1010edaSGreg Roach    {
112323788f4SGreg Roach        $this->assertSame(
113c1010edaSGreg Roach            [
114c1010edaSGreg Roach                'NAME' => '/Garcia/ /Ruiz/',
115c1010edaSGreg Roach                'SURN' => 'Garcia,Ruiz',
116c1010edaSGreg Roach            ],
117323788f4SGreg Roach            $this->surname_tradition->newChildNames('Gabriel /Garcia/ /Iglesias/', 'Maria /Ruiz/ /Lorca/', 'M')
118323788f4SGreg Roach        );
119323788f4SGreg Roach    }
120323788f4SGreg Roach
121323788f4SGreg Roach    /**
122323788f4SGreg Roach     * Test new child names
12317d74f3aSGreg Roach     *
12415d603e7SGreg Roach     * @covers \Fisharebest\Webtrees\SurnameTradition\SpanishSurnameTradition
12552348eb8SGreg Roach     *
12652348eb8SGreg Roach     * @return void
127323788f4SGreg Roach     */
1289b802b22SGreg Roach    public function testNewChildNamesWithNoParentsNames(): void
129c1010edaSGreg Roach    {
1301677a03aSGreg Roach        $this->assertSame(
131c1010edaSGreg Roach            [
132c1010edaSGreg Roach                'NAME' => '// //',
133c1010edaSGreg Roach                'SURN' => '',
134c1010edaSGreg Roach            ],
1351677a03aSGreg Roach            $this->surname_tradition->newChildNames('', '', 'U')
1361677a03aSGreg Roach        );
1371677a03aSGreg Roach    }
1381677a03aSGreg Roach
1391677a03aSGreg Roach    /**
1401677a03aSGreg Roach     * Test new child names
14117d74f3aSGreg Roach     *
14215d603e7SGreg Roach     * @covers \Fisharebest\Webtrees\SurnameTradition\SpanishSurnameTradition
14352348eb8SGreg Roach     *
14452348eb8SGreg Roach     * @return void
1451677a03aSGreg Roach     */
1469b802b22SGreg Roach    public function testNewChildNamesCompunds(): void
147c1010edaSGreg Roach    {
148323788f4SGreg Roach        $this->assertSame(
149c1010edaSGreg Roach            [
150c1010edaSGreg Roach                'NAME' => '/Garcia/ /Ruiz/',
151c1010edaSGreg Roach                'SURN' => 'Garcia,Ruiz',
152c1010edaSGreg Roach            ],
153323788f4SGreg Roach            $this->surname_tradition->newChildNames('Gabriel /Garcia Iglesias/', 'Maria /Ruiz Lorca/', 'M')
154323788f4SGreg Roach        );
155323788f4SGreg Roach        $this->assertSame(
156c1010edaSGreg Roach            [
157c1010edaSGreg Roach                'NAME' => '/Garcia/ /Ruiz/',
158c1010edaSGreg Roach                'SURN' => 'Garcia,Ruiz',
159c1010edaSGreg Roach            ],
160323788f4SGreg Roach            $this->surname_tradition->newChildNames('Gabriel /Garcia y Iglesias/', 'Maria /Ruiz y Lorca/', 'M')
161323788f4SGreg Roach        );
162323788f4SGreg Roach    }
163323788f4SGreg Roach
164323788f4SGreg Roach    /**
165323788f4SGreg Roach     * Test new father names
16617d74f3aSGreg Roach     *
16715d603e7SGreg Roach     * @covers \Fisharebest\Webtrees\SurnameTradition\SpanishSurnameTradition
16852348eb8SGreg Roach     *
16952348eb8SGreg Roach     * @return void
170323788f4SGreg Roach     */
1719b802b22SGreg Roach    public function testNewFatherNames(): void
172c1010edaSGreg Roach    {
173323788f4SGreg Roach        $this->assertSame(
174c1010edaSGreg Roach            [
175c1010edaSGreg Roach                'NAME' => '/Garcia/ //',
176c1010edaSGreg Roach                'SURN' => 'Garcia',
177c1010edaSGreg Roach            ],
178323788f4SGreg Roach            $this->surname_tradition->newParentNames('Gabriel /Garcia/ /Iglesias/', 'M')
179323788f4SGreg Roach        );
180323788f4SGreg Roach    }
181323788f4SGreg Roach
182323788f4SGreg Roach    /**
183323788f4SGreg Roach     * Test new mother names
18417d74f3aSGreg Roach     *
18515d603e7SGreg Roach     * @covers \Fisharebest\Webtrees\SurnameTradition\SpanishSurnameTradition
18652348eb8SGreg Roach     *
18752348eb8SGreg Roach     * @return void
188323788f4SGreg Roach     */
1899b802b22SGreg Roach    public function testNewMotherNames(): void
190c1010edaSGreg Roach    {
191323788f4SGreg Roach        $this->assertSame(
192c1010edaSGreg Roach            [
193c1010edaSGreg Roach                'NAME' => '/Iglesias/ //',
194c1010edaSGreg Roach                'SURN' => 'Iglesias',
195c1010edaSGreg Roach            ],
196323788f4SGreg Roach            $this->surname_tradition->newParentNames('Gabriel /Garcia/ /Iglesias/', 'F')
197323788f4SGreg Roach        );
198323788f4SGreg Roach    }
199323788f4SGreg Roach
200323788f4SGreg Roach    /**
201323788f4SGreg Roach     * Test new parent names
20217d74f3aSGreg Roach     *
20315d603e7SGreg Roach     * @covers \Fisharebest\Webtrees\SurnameTradition\SpanishSurnameTradition
20452348eb8SGreg Roach     *
20552348eb8SGreg Roach     * @return void
206323788f4SGreg Roach     */
2079b802b22SGreg Roach    public function testNewParentNames(): void
208c1010edaSGreg Roach    {
209323788f4SGreg Roach        $this->assertSame(
21013abd6f3SGreg Roach            ['NAME' => '// //'],
211323788f4SGreg Roach            $this->surname_tradition->newParentNames('Gabriel /Garcia/ /Iglesias/', 'U')
212323788f4SGreg Roach        );
213323788f4SGreg Roach    }
214323788f4SGreg Roach
215323788f4SGreg Roach    /**
216323788f4SGreg Roach     * Test new husband names
21717d74f3aSGreg Roach     *
21815d603e7SGreg Roach     * @covers \Fisharebest\Webtrees\SurnameTradition\SpanishSurnameTradition
21952348eb8SGreg Roach     *
22052348eb8SGreg Roach     * @return void
221323788f4SGreg Roach     */
2229b802b22SGreg Roach    public function testNewHusbandNames(): void
223c1010edaSGreg Roach    {
224323788f4SGreg Roach        $this->assertSame(
22513abd6f3SGreg Roach            ['NAME' => '// //'],
226323788f4SGreg Roach            $this->surname_tradition->newSpouseNames('Maria /Ruiz/ /Lorca/', 'M')
227323788f4SGreg Roach        );
228323788f4SGreg Roach    }
229323788f4SGreg Roach
230323788f4SGreg Roach    /**
231323788f4SGreg Roach     * Test new wife names
23217d74f3aSGreg Roach     *
23315d603e7SGreg Roach     * @covers \Fisharebest\Webtrees\SurnameTradition\SpanishSurnameTradition
23452348eb8SGreg Roach     *
23552348eb8SGreg Roach     * @return void
236323788f4SGreg Roach     */
2379b802b22SGreg Roach    public function testNewWifeNames(): void
238c1010edaSGreg Roach    {
239323788f4SGreg Roach        $this->assertSame(
24013abd6f3SGreg Roach            ['NAME' => '// //'],
241323788f4SGreg Roach            $this->surname_tradition->newSpouseNames('Gabriel /Garcia/ /Iglesias/', 'F')
242323788f4SGreg Roach        );
243323788f4SGreg Roach    }
244323788f4SGreg Roach
245323788f4SGreg Roach    /**
246323788f4SGreg Roach     * Test new spouse names
24717d74f3aSGreg Roach     *
24815d603e7SGreg Roach     * @covers \Fisharebest\Webtrees\SurnameTradition\SpanishSurnameTradition
24952348eb8SGreg Roach     *
25052348eb8SGreg Roach     * @return void
251323788f4SGreg Roach     */
2529b802b22SGreg Roach    public function testNewSpouseNames(): void
253c1010edaSGreg Roach    {
254323788f4SGreg Roach        $this->assertSame(
25513abd6f3SGreg Roach            ['NAME' => '// //'],
256323788f4SGreg Roach            $this->surname_tradition->newSpouseNames('Gabriel /Garcia/ /Iglesias/', 'U')
257323788f4SGreg Roach        );
258323788f4SGreg Roach    }
259323788f4SGreg Roach}
260