diff options
| author | Greg Roach <greg@subaqua.co.uk> | 2021-06-04 09:47:31 +0100 |
|---|---|---|
| committer | Greg Roach <greg@subaqua.co.uk> | 2021-06-04 19:54:41 +0100 |
| commit | cb7a42eae1efabac96d9d7693151fe0421b6717b (patch) | |
| tree | 377965c6d7e32fea6118a4f9fda815ed5692c8b2 /tests/app/SurnameTradition/SpanishSurnameTraditionTest.php | |
| parent | 2d111ef4d7fa5c4d9d27b419b54419f20e0c57e9 (diff) | |
| download | webtrees-cb7a42eae1efabac96d9d7693151fe0421b6717b.tar.gz webtrees-cb7a42eae1efabac96d9d7693151fe0421b6717b.tar.bz2 webtrees-cb7a42eae1efabac96d9d7693151fe0421b6717b.zip | |
Update surname tradition code to use TYPE=married instead of _MARNM
Diffstat (limited to 'tests/app/SurnameTradition/SpanishSurnameTraditionTest.php')
| -rw-r--r-- | tests/app/SurnameTradition/SpanishSurnameTraditionTest.php | 201 |
1 files changed, 76 insertions, 125 deletions
diff --git a/tests/app/SurnameTradition/SpanishSurnameTraditionTest.php b/tests/app/SurnameTradition/SpanishSurnameTraditionTest.php index ac2f2937c0..ae867c03fa 100644 --- a/tests/app/SurnameTradition/SpanishSurnameTraditionTest.php +++ b/tests/app/SurnameTradition/SpanishSurnameTraditionTest.php @@ -19,7 +19,10 @@ declare(strict_types=1); namespace Fisharebest\Webtrees\SurnameTradition; +use Fisharebest\Webtrees\Fact; +use Fisharebest\Webtrees\Individual; use Fisharebest\Webtrees\TestCase; +use Illuminate\Support\Collection; /** * Test harness for the class SpanishSurnameTradition @@ -29,18 +32,6 @@ class SpanishSurnameTraditionTest extends TestCase private SurnameTraditionInterface $surname_tradition; /** - * Prepare the environment for these tests - * - * @return void - */ - protected function setUp(): void - { - parent::setUp(); - - $this->surname_tradition = new SpanishSurnameTradition(); - } - - /** * Test whether married surnames are used * * @covers \Fisharebest\Webtrees\SurnameTradition\SpanishSurnameTradition @@ -65,56 +56,39 @@ class SpanishSurnameTraditionTest extends TestCase } /** - * Test new son names + * Test new child names * * @covers \Fisharebest\Webtrees\SurnameTradition\SpanishSurnameTradition * * @return void */ - public function testNewSonNames(): void + public function testNewChildNames(): void { + $father_fact = $this->createStub(Fact::class); + $father_fact->expects(self::any())->method('value')->willReturn('Gabriel /Garcia/ /Iglesias/'); + + $father = $this->createStub(Individual::class); + $father->expects(self::any())->method('facts')->willReturn(new Collection([$father_fact])); + + $mother_fact = $this->createStub(Fact::class); + $mother_fact->expects(self::any())->method('value')->willReturn('Gabriel /Ruiz/ /Lorca/'); + + $mother = $this->createStub(Individual::class); + $mother->expects(self::any())->method('facts')->willReturn(new Collection([$mother_fact])); + self::assertSame( - [ - 'NAME' => '/Garcia/ /Ruiz/', - 'SURN' => 'Garcia,Ruiz', - ], - $this->surname_tradition->newChildNames('Gabriel /Garcia/ /Iglesias/', 'Maria /Ruiz/ /Lorca/', 'M') + ["1 NAME /Garcia/ /Ruiz/\n2 TYPE birth\n2 SURN Garcia,Ruiz"], + $this->surname_tradition->newChildNames($father, $mother, 'M') ); - } - /** - * Test new daughter names - * - * @covers \Fisharebest\Webtrees\SurnameTradition\SpanishSurnameTradition - * - * @return void - */ - public function testNewDaughterNames(): void - { self::assertSame( - [ - 'NAME' => '/Garcia/ /Ruiz/', - 'SURN' => 'Garcia,Ruiz', - ], - $this->surname_tradition->newChildNames('Gabriel /Garcia/ /Iglesias/', 'Maria /Ruiz/ /Lorca/', 'M') + ["1 NAME /Garcia/ /Ruiz/\n2 TYPE birth\n2 SURN Garcia,Ruiz"], + $this->surname_tradition->newChildNames($father, $mother, 'F') ); - } - /** - * Test new child names - * - * @covers \Fisharebest\Webtrees\SurnameTradition\SpanishSurnameTradition - * - * @return void - */ - public function testNewChildNames(): void - { self::assertSame( - [ - 'NAME' => '/Garcia/ /Ruiz/', - 'SURN' => 'Garcia,Ruiz', - ], - $this->surname_tradition->newChildNames('Gabriel /Garcia/ /Iglesias/', 'Maria /Ruiz/ /Lorca/', 'M') + ["1 NAME /Garcia/ /Ruiz/\n2 TYPE birth\n2 SURN Garcia,Ruiz"], + $this->surname_tradition->newChildNames($father, $mother, 'U') ); } @@ -128,11 +102,8 @@ class SpanishSurnameTraditionTest extends TestCase public function testNewChildNamesWithNoParentsNames(): void { self::assertSame( - [ - 'NAME' => '// //', - 'SURN' => '', - ], - $this->surname_tradition->newChildNames('', '', 'U') + ["1 NAME // //\n2 TYPE birth"], + $this->surname_tradition->newChildNames(null, null, 'U') ); } @@ -143,117 +114,97 @@ class SpanishSurnameTraditionTest extends TestCase * * @return void */ - public function testNewChildNamesCompunds(): void + public function testNewChildNamesCompound(): void { + $father_fact = $this->createStub(Fact::class); + $father_fact->expects(self::any())->method('value')->willReturn('Gabriel /Garcia/ y /Iglesias/'); + + $father = $this->createStub(Individual::class); + $father->expects(self::any())->method('facts')->willReturn(new Collection([$father_fact])); + + $mother_fact = $this->createStub(Fact::class); + $mother_fact->expects(self::any())->method('value')->willReturn('Gabriel /Ruiz/ y /Lorca/'); + + $mother = $this->createStub(Individual::class); + $mother->expects(self::any())->method('facts')->willReturn(new Collection([$mother_fact])); + self::assertSame( - [ - 'NAME' => '/Garcia/ /Ruiz/', - 'SURN' => 'Garcia,Ruiz', - ], - $this->surname_tradition->newChildNames('Gabriel /Garcia Iglesias/', 'Maria /Ruiz Lorca/', 'M') - ); - self::assertSame( - [ - 'NAME' => '/Garcia/ /Ruiz/', - 'SURN' => 'Garcia,Ruiz', - ], - $this->surname_tradition->newChildNames('Gabriel /Garcia y Iglesias/', 'Maria /Ruiz y Lorca/', 'M') + ["1 NAME /Garcia/ /Ruiz/\n2 TYPE birth\n2 SURN Garcia,Ruiz"], + $this->surname_tradition->newChildNames($father, $mother, 'M') ); } /** - * Test new father names + * Test new parent names * * @covers \Fisharebest\Webtrees\SurnameTradition\SpanishSurnameTradition * * @return void */ - public function testNewFatherNames(): void + public function testNewParentNames(): void { + $fact = $this->createStub(Fact::class); + $fact->expects(self::any())->method('value')->willReturn('Gabriel /Garcia/ /Iglesias/'); + + $individual = $this->createStub(Individual::class); + $individual->expects(self::any())->method('facts')->willReturn(new Collection([$fact])); + self::assertSame( - [ - 'NAME' => '/Garcia/ //', - 'SURN' => 'Garcia', - ], - $this->surname_tradition->newParentNames('Gabriel /Garcia/ /Iglesias/', 'M') + ["1 NAME /Garcia/ //\n2 TYPE birth\n2 SURN Garcia"], + $this->surname_tradition->newParentNames($individual, 'M') ); - } - /** - * Test new mother names - * - * @covers \Fisharebest\Webtrees\SurnameTradition\SpanishSurnameTradition - * - * @return void - */ - public function testNewMotherNames(): void - { self::assertSame( - [ - 'NAME' => '/Iglesias/ //', - 'SURN' => 'Iglesias', - ], - $this->surname_tradition->newParentNames('Gabriel /Garcia/ /Iglesias/', 'F') + ["1 NAME /Iglesias/ //\n2 TYPE birth\n2 SURN Iglesias"], + $this->surname_tradition->newParentNames($individual, 'F') ); - } - /** - * Test new parent names - * - * @covers \Fisharebest\Webtrees\SurnameTradition\SpanishSurnameTradition - * - * @return void - */ - public function testNewParentNames(): void - { self::assertSame( - ['NAME' => '// //'], - $this->surname_tradition->newParentNames('Gabriel /Garcia/ /Iglesias/', 'U') + ["1 NAME // //\n2 TYPE birth"], + $this->surname_tradition->newParentNames($individual, 'U') ); } /** - * Test new husband names + * Test new spouse names * * @covers \Fisharebest\Webtrees\SurnameTradition\SpanishSurnameTradition * * @return void */ - public function testNewHusbandNames(): void + public function testNewSpouseNames(): void { + $fact = $this->createStub(Fact::class); + $fact->expects(self::any())->method('value')->willReturn('Gabriel /Garcia/ /Iglesias/'); + + $individual = $this->createStub(Individual::class); + $individual->expects(self::any())->method('facts')->willReturn(new Collection([$fact])); + self::assertSame( - ['NAME' => '// //'], - $this->surname_tradition->newSpouseNames('Maria /Ruiz/ /Lorca/', 'M') + ["1 NAME // //\n2 TYPE birth"], + $this->surname_tradition->newSpouseNames($individual, 'M') + ); + + self::assertSame( + ["1 NAME // //\n2 TYPE birth"], + $this->surname_tradition->newSpouseNames($individual, 'F') ); - } - /** - * Test new wife names - * - * @covers \Fisharebest\Webtrees\SurnameTradition\SpanishSurnameTradition - * - * @return void - */ - public function testNewWifeNames(): void - { self::assertSame( - ['NAME' => '// //'], - $this->surname_tradition->newSpouseNames('Gabriel /Garcia/ /Iglesias/', 'F') + ["1 NAME // //\n2 TYPE birth"], + $this->surname_tradition->newSpouseNames($individual, 'U') ); } /** - * Test new spouse names - * - * @covers \Fisharebest\Webtrees\SurnameTradition\SpanishSurnameTradition + * Prepare the environment for these tests * * @return void */ - public function testNewSpouseNames(): void + protected function setUp(): void { - self::assertSame( - ['NAME' => '// //'], - $this->surname_tradition->newSpouseNames('Gabriel /Garcia/ /Iglesias/', 'U') - ); + parent::setUp(); + + $this->surname_tradition = new SpanishSurnameTradition(); } } |
