xref: /webtrees/tests/app/SurnameTradition/SpanishSurnameTraditionTest.php (revision 8fcd0d32e56ee262912bbdb593202cfd1cbc1615)
1323788f4SGreg Roach<?php
2323788f4SGreg Roach/**
3323788f4SGreg Roach * webtrees: online genealogy
4*8fcd0d32SGreg Roach * Copyright (C) 2019 webtrees development team
5323788f4SGreg Roach * This program is free software: you can redistribute it and/or modify
6323788f4SGreg Roach * it under the terms of the GNU General Public License as published by
7323788f4SGreg Roach * the Free Software Foundation, either version 3 of the License, or
8323788f4SGreg Roach * (at your option) any later version.
9323788f4SGreg Roach * This program is distributed in the hope that it will be useful,
10323788f4SGreg Roach * but WITHOUT ANY WARRANTY; without even the implied warranty of
11323788f4SGreg Roach * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12323788f4SGreg Roach * GNU General Public License for more details.
13323788f4SGreg Roach * You should have received a copy of the GNU General Public License
14323788f4SGreg Roach * along with this program. If not, see <http://www.gnu.org/licenses/>.
15323788f4SGreg Roach */
16e7f56f2aSGreg Roachdeclare(strict_types=1);
17e7f56f2aSGreg Roach
1884e2cf4eSGreg Roachnamespace Fisharebest\Webtrees\SurnameTradition;
19c1010edaSGreg Roach
20323788f4SGreg Roach/**
21323788f4SGreg Roach * Test harness for the class SpanishSurnameTradition
22323788f4SGreg Roach */
2384e2cf4eSGreg Roachclass SpanishSurnameTraditionTest extends \Fisharebest\Webtrees\TestCase
24c1010edaSGreg Roach{
25323788f4SGreg Roach    /** @var SurnameTraditionInterface */
26323788f4SGreg Roach    private $surname_tradition;
27323788f4SGreg Roach
28323788f4SGreg Roach    /**
29323788f4SGreg Roach     * Prepare the environment for these tests
3052348eb8SGreg Roach     *
3152348eb8SGreg Roach     * @return void
32323788f4SGreg Roach     */
330115bc16SGreg Roach    protected function setUp()
34c1010edaSGreg Roach    {
350115bc16SGreg Roach        parent::setUp();
360115bc16SGreg Roach
37323788f4SGreg Roach        $this->surname_tradition = new SpanishSurnameTradition;
38323788f4SGreg Roach    }
39323788f4SGreg Roach
40323788f4SGreg Roach    /**
41323788f4SGreg Roach     * Test whether married surnames are used
4217d74f3aSGreg Roach     *
4315d603e7SGreg Roach     * @covers \Fisharebest\Webtrees\SurnameTradition\SpanishSurnameTradition
4452348eb8SGreg Roach     *
4552348eb8SGreg Roach     * @return void
46323788f4SGreg Roach     */
47c1010edaSGreg Roach    public function testMarriedSurnames()
48c1010edaSGreg Roach    {
49323788f4SGreg Roach        $this->assertSame(false, $this->surname_tradition->hasMarriedNames());
50323788f4SGreg Roach    }
51323788f4SGreg Roach
52323788f4SGreg Roach    /**
53c1ec7145SGreg Roach     * Test whether surnames are used
5417d74f3aSGreg Roach     *
5515d603e7SGreg Roach     * @covers \Fisharebest\Webtrees\SurnameTradition\SpanishSurnameTradition
5652348eb8SGreg Roach     *
5752348eb8SGreg Roach     * @return void
58c1ec7145SGreg Roach     */
59c1010edaSGreg Roach    public function testSurnames()
60c1010edaSGreg Roach    {
61c1ec7145SGreg Roach        $this->assertSame(true, $this->surname_tradition->hasSurnames());
62c1ec7145SGreg Roach    }
63c1ec7145SGreg Roach
64c1ec7145SGreg Roach    /**
65323788f4SGreg Roach     * Test new son names
6617d74f3aSGreg Roach     *
6715d603e7SGreg Roach     * @covers \Fisharebest\Webtrees\SurnameTradition\SpanishSurnameTradition
6852348eb8SGreg Roach     *
6952348eb8SGreg Roach     * @return void
70323788f4SGreg Roach     */
71c1010edaSGreg Roach    public function testNewSonNames()
72c1010edaSGreg Roach    {
73323788f4SGreg Roach        $this->assertSame(
74c1010edaSGreg Roach            [
75c1010edaSGreg Roach                'NAME' => '/Garcia/ /Ruiz/',
76c1010edaSGreg Roach                'SURN' => 'Garcia,Ruiz',
77c1010edaSGreg Roach            ],
78323788f4SGreg Roach            $this->surname_tradition->newChildNames('Gabriel /Garcia/ /Iglesias/', 'Maria /Ruiz/ /Lorca/', 'M')
79323788f4SGreg Roach        );
80323788f4SGreg Roach    }
81323788f4SGreg Roach
82323788f4SGreg Roach    /**
83323788f4SGreg Roach     * Test new daughter names
8417d74f3aSGreg Roach     *
8515d603e7SGreg Roach     * @covers \Fisharebest\Webtrees\SurnameTradition\SpanishSurnameTradition
8652348eb8SGreg Roach     *
8752348eb8SGreg Roach     * @return void
88323788f4SGreg Roach     */
89c1010edaSGreg Roach    public function testNewDaughterNames()
90c1010edaSGreg Roach    {
91323788f4SGreg Roach        $this->assertSame(
92c1010edaSGreg Roach            [
93c1010edaSGreg Roach                'NAME' => '/Garcia/ /Ruiz/',
94c1010edaSGreg Roach                'SURN' => 'Garcia,Ruiz',
95c1010edaSGreg Roach            ],
96323788f4SGreg Roach            $this->surname_tradition->newChildNames('Gabriel /Garcia/ /Iglesias/', 'Maria /Ruiz/ /Lorca/', 'M')
97323788f4SGreg Roach        );
98323788f4SGreg Roach    }
99323788f4SGreg Roach
100323788f4SGreg Roach    /**
101323788f4SGreg Roach     * Test new child names
10217d74f3aSGreg Roach     *
10315d603e7SGreg Roach     * @covers \Fisharebest\Webtrees\SurnameTradition\SpanishSurnameTradition
10452348eb8SGreg Roach     *
10552348eb8SGreg Roach     * @return void
106323788f4SGreg Roach     */
107c1010edaSGreg Roach    public function testNewChildNames()
108c1010edaSGreg Roach    {
109323788f4SGreg Roach        $this->assertSame(
110c1010edaSGreg Roach            [
111c1010edaSGreg Roach                'NAME' => '/Garcia/ /Ruiz/',
112c1010edaSGreg Roach                'SURN' => 'Garcia,Ruiz',
113c1010edaSGreg Roach            ],
114323788f4SGreg Roach            $this->surname_tradition->newChildNames('Gabriel /Garcia/ /Iglesias/', 'Maria /Ruiz/ /Lorca/', 'M')
115323788f4SGreg Roach        );
116323788f4SGreg Roach    }
117323788f4SGreg Roach
118323788f4SGreg Roach    /**
119323788f4SGreg Roach     * Test new child names
12017d74f3aSGreg Roach     *
12115d603e7SGreg Roach     * @covers \Fisharebest\Webtrees\SurnameTradition\SpanishSurnameTradition
12252348eb8SGreg Roach     *
12352348eb8SGreg Roach     * @return void
124323788f4SGreg Roach     */
125c1010edaSGreg Roach    public function testNewChildNamesWithNoParentsNames()
126c1010edaSGreg Roach    {
1271677a03aSGreg Roach        $this->assertSame(
128c1010edaSGreg Roach            [
129c1010edaSGreg Roach                'NAME' => '// //',
130c1010edaSGreg Roach                'SURN' => '',
131c1010edaSGreg Roach            ],
1321677a03aSGreg Roach            $this->surname_tradition->newChildNames('', '', 'U')
1331677a03aSGreg Roach        );
1341677a03aSGreg Roach    }
1351677a03aSGreg Roach
1361677a03aSGreg Roach    /**
1371677a03aSGreg Roach     * Test new child names
13817d74f3aSGreg Roach     *
13915d603e7SGreg Roach     * @covers \Fisharebest\Webtrees\SurnameTradition\SpanishSurnameTradition
14052348eb8SGreg Roach     *
14152348eb8SGreg Roach     * @return void
1421677a03aSGreg Roach     */
143c1010edaSGreg Roach    public function testNewChildNamesCompunds()
144c1010edaSGreg Roach    {
145323788f4SGreg Roach        $this->assertSame(
146c1010edaSGreg Roach            [
147c1010edaSGreg Roach                'NAME' => '/Garcia/ /Ruiz/',
148c1010edaSGreg Roach                'SURN' => 'Garcia,Ruiz',
149c1010edaSGreg Roach            ],
150323788f4SGreg Roach            $this->surname_tradition->newChildNames('Gabriel /Garcia Iglesias/', 'Maria /Ruiz Lorca/', 'M')
151323788f4SGreg Roach        );
152323788f4SGreg Roach        $this->assertSame(
153c1010edaSGreg Roach            [
154c1010edaSGreg Roach                'NAME' => '/Garcia/ /Ruiz/',
155c1010edaSGreg Roach                'SURN' => 'Garcia,Ruiz',
156c1010edaSGreg Roach            ],
157323788f4SGreg Roach            $this->surname_tradition->newChildNames('Gabriel /Garcia y Iglesias/', 'Maria /Ruiz y Lorca/', 'M')
158323788f4SGreg Roach        );
159323788f4SGreg Roach    }
160323788f4SGreg Roach
161323788f4SGreg Roach    /**
162323788f4SGreg Roach     * Test new father names
16317d74f3aSGreg Roach     *
16415d603e7SGreg Roach     * @covers \Fisharebest\Webtrees\SurnameTradition\SpanishSurnameTradition
16552348eb8SGreg Roach     *
16652348eb8SGreg Roach     * @return void
167323788f4SGreg Roach     */
168c1010edaSGreg Roach    public function testNewFatherNames()
169c1010edaSGreg Roach    {
170323788f4SGreg Roach        $this->assertSame(
171c1010edaSGreg Roach            [
172c1010edaSGreg Roach                'NAME' => '/Garcia/ //',
173c1010edaSGreg Roach                'SURN' => 'Garcia',
174c1010edaSGreg Roach            ],
175323788f4SGreg Roach            $this->surname_tradition->newParentNames('Gabriel /Garcia/ /Iglesias/', 'M')
176323788f4SGreg Roach        );
177323788f4SGreg Roach    }
178323788f4SGreg Roach
179323788f4SGreg Roach    /**
180323788f4SGreg Roach     * Test new mother names
18117d74f3aSGreg Roach     *
18215d603e7SGreg Roach     * @covers \Fisharebest\Webtrees\SurnameTradition\SpanishSurnameTradition
18352348eb8SGreg Roach     *
18452348eb8SGreg Roach     * @return void
185323788f4SGreg Roach     */
186c1010edaSGreg Roach    public function testNewMotherNames()
187c1010edaSGreg Roach    {
188323788f4SGreg Roach        $this->assertSame(
189c1010edaSGreg Roach            [
190c1010edaSGreg Roach                'NAME' => '/Iglesias/ //',
191c1010edaSGreg Roach                'SURN' => 'Iglesias',
192c1010edaSGreg Roach            ],
193323788f4SGreg Roach            $this->surname_tradition->newParentNames('Gabriel /Garcia/ /Iglesias/', 'F')
194323788f4SGreg Roach        );
195323788f4SGreg Roach    }
196323788f4SGreg Roach
197323788f4SGreg Roach    /**
198323788f4SGreg Roach     * Test new parent names
19917d74f3aSGreg Roach     *
20015d603e7SGreg Roach     * @covers \Fisharebest\Webtrees\SurnameTradition\SpanishSurnameTradition
20152348eb8SGreg Roach     *
20252348eb8SGreg Roach     * @return void
203323788f4SGreg Roach     */
204c1010edaSGreg Roach    public function testNewParentNames()
205c1010edaSGreg Roach    {
206323788f4SGreg Roach        $this->assertSame(
20713abd6f3SGreg Roach            ['NAME' => '// //'],
208323788f4SGreg Roach            $this->surname_tradition->newParentNames('Gabriel /Garcia/ /Iglesias/', 'U')
209323788f4SGreg Roach        );
210323788f4SGreg Roach    }
211323788f4SGreg Roach
212323788f4SGreg Roach    /**
213323788f4SGreg Roach     * Test new husband names
21417d74f3aSGreg Roach     *
21515d603e7SGreg Roach     * @covers \Fisharebest\Webtrees\SurnameTradition\SpanishSurnameTradition
21652348eb8SGreg Roach     *
21752348eb8SGreg Roach     * @return void
218323788f4SGreg Roach     */
219c1010edaSGreg Roach    public function testNewHusbandNames()
220c1010edaSGreg Roach    {
221323788f4SGreg Roach        $this->assertSame(
22213abd6f3SGreg Roach            ['NAME' => '// //'],
223323788f4SGreg Roach            $this->surname_tradition->newSpouseNames('Maria /Ruiz/ /Lorca/', 'M')
224323788f4SGreg Roach        );
225323788f4SGreg Roach    }
226323788f4SGreg Roach
227323788f4SGreg Roach    /**
228323788f4SGreg Roach     * Test new wife names
22917d74f3aSGreg Roach     *
23015d603e7SGreg Roach     * @covers \Fisharebest\Webtrees\SurnameTradition\SpanishSurnameTradition
23152348eb8SGreg Roach     *
23252348eb8SGreg Roach     * @return void
233323788f4SGreg Roach     */
234c1010edaSGreg Roach    public function testNewWifeNames()
235c1010edaSGreg Roach    {
236323788f4SGreg Roach        $this->assertSame(
23713abd6f3SGreg Roach            ['NAME' => '// //'],
238323788f4SGreg Roach            $this->surname_tradition->newSpouseNames('Gabriel /Garcia/ /Iglesias/', 'F')
239323788f4SGreg Roach        );
240323788f4SGreg Roach    }
241323788f4SGreg Roach
242323788f4SGreg Roach    /**
243323788f4SGreg Roach     * Test new spouse names
24417d74f3aSGreg Roach     *
24515d603e7SGreg Roach     * @covers \Fisharebest\Webtrees\SurnameTradition\SpanishSurnameTradition
24652348eb8SGreg Roach     *
24752348eb8SGreg Roach     * @return void
248323788f4SGreg Roach     */
249c1010edaSGreg Roach    public function testNewSpouseNames()
250c1010edaSGreg Roach    {
251323788f4SGreg Roach        $this->assertSame(
25213abd6f3SGreg Roach            ['NAME' => '// //'],
253323788f4SGreg Roach            $this->surname_tradition->newSpouseNames('Gabriel /Garcia/ /Iglesias/', 'U')
254323788f4SGreg Roach        );
255323788f4SGreg Roach    }
256323788f4SGreg Roach}
257