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 | |
| 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')
9 files changed, 951 insertions, 900 deletions
diff --git a/tests/app/SurnameTradition/DefaultSurnameTraditionTest.php b/tests/app/SurnameTradition/DefaultSurnameTraditionTest.php index 00cc5f1bbc..3ea605107c 100644 --- a/tests/app/SurnameTradition/DefaultSurnameTraditionTest.php +++ b/tests/app/SurnameTradition/DefaultSurnameTraditionTest.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 DefaultSurnameTradition @@ -29,18 +32,6 @@ class DefaultSurnameTraditionTest extends TestCase private SurnameTraditionInterface $surname_tradition; /** - * Prepare the environment for these tests - * - * @return void - */ - protected function setUp(): void - { - parent::setUp(); - - $this->surname_tradition = new DefaultSurnameTradition(); - } - - /** * Test whether married surnames are used * * @covers \Fisharebest\Webtrees\SurnameTradition\DefaultSurnameTradition @@ -65,137 +56,113 @@ class DefaultSurnameTraditionTest extends TestCase } /** - * Test new son names + * Test new child names * * @covers \Fisharebest\Webtrees\SurnameTradition\DefaultSurnameTradition * * @return void */ - public function testNewSonNames(): void + public function testNewChildNames(): void { + $father_fact = $this->createStub(Fact::class); + $father_fact->expects(self::any())->method('value')->willReturn('Chris /White/'); + + $father = $this->createStub(Individual::class); + $father->expects(self::any())->method('facts')->willReturn(new Collection([$father])); + + $mother_fact = $this->createStub(Fact::class); + $mother_fact->expects(self::any())->method('value')->willReturn('Chris /White/'); + + $mother = $this->createStub(Individual::class); + $mother->expects(self::any())->method('facts')->willReturn(new Collection([$mother_fact])); + self::assertSame( - ['NAME' => '//'], - $this->surname_tradition->newChildNames('John /White/', 'Mary /Black/', 'M') + ["1 NAME //\n2 TYPE birth"], + $this->surname_tradition->newChildNames($father, $mother, 'M') ); - } - /** - * Test new daughter names - * - * @covers \Fisharebest\Webtrees\SurnameTradition\DefaultSurnameTradition - * - * @return void - */ - public function testNewDaughterNames(): void - { self::assertSame( - ['NAME' => '//'], - $this->surname_tradition->newChildNames('John /White/', 'Mary /Black/', 'F') + ["1 NAME //\n2 TYPE birth"], + $this->surname_tradition->newChildNames($father, $mother, 'F') ); - } - /** - * Test new child names - * - * @covers \Fisharebest\Webtrees\SurnameTradition\DefaultSurnameTradition - * - * @return void - */ - public function testNewChildNames(): void - { self::assertSame( - ['NAME' => '//'], - $this->surname_tradition->newChildNames('John /White/', 'Mary /Black/', 'U') + ["1 NAME //\n2 TYPE birth"], + $this->surname_tradition->newChildNames($father, $mother, 'U') ); } /** - * Test new father names + * Test new parent names * * @covers \Fisharebest\Webtrees\SurnameTradition\DefaultSurnameTradition * * @return void */ - public function testNewFatherNames(): void + public function testNewParentNames(): void { + $fact = $this->createStub(Fact::class); + $fact->expects(self::any())->method('value')->willReturn('Chris /White/'); + + $individual = $this->createStub(Individual::class); + $individual->expects(self::any())->method('facts')->willReturn(new Collection([$fact])); + self::assertSame( - ['NAME' => '//'], - $this->surname_tradition->newParentNames('John /White/', 'M') + ["1 NAME //\n2 TYPE birth"], + $this->surname_tradition->newParentNames($individual, 'M') ); - } - /** - * Test new mother names - * - * @covers \Fisharebest\Webtrees\SurnameTradition\DefaultSurnameTradition - * - * @return void - */ - public function testNewMotherNames(): void - { self::assertSame( - ['NAME' => '//'], - $this->surname_tradition->newParentNames('John /White/', 'F') + ["1 NAME //\n2 TYPE birth"], + $this->surname_tradition->newParentNames($individual, 'F') ); - } - /** - * Test new parent names - * - * @covers \Fisharebest\Webtrees\SurnameTradition\DefaultSurnameTradition - * - * @return void - */ - public function testNewParentNames(): void - { self::assertSame( - ['NAME' => '//'], - $this->surname_tradition->newParentNames('John /White/', 'U') + ["1 NAME //\n2 TYPE birth"], + $this->surname_tradition->newParentNames($individual, 'U') ); } /** - * Test new husband names + * Test new spouse names * * @covers \Fisharebest\Webtrees\SurnameTradition\DefaultSurnameTradition * * @return void */ - public function testNewHusbandNames(): void + public function testNewSpouseNames(): void { + $fact = $this->createStub(Fact::class); + $fact->expects(self::any())->method('value')->willReturn('Chris /White/'); + + $individual = $this->createStub(Individual::class); + $individual->expects(self::any())->method('facts')->willReturn(new Collection([$fact])); + self::assertSame( - ['NAME' => '//'], - $this->surname_tradition->newSpouseNames('Mary /Black/', 'M') + ["1 NAME //\n2 TYPE birth"], + $this->surname_tradition->newSpouseNames($individual, 'M') ); - } - /** - * Test new wife names - * - * @covers \Fisharebest\Webtrees\SurnameTradition\DefaultSurnameTradition - * - * @return void - */ - public function testNewWifeNames(): void - { self::assertSame( - ['NAME' => '//'], - $this->surname_tradition->newSpouseNames('John /White/', 'F') + ["1 NAME //\n2 TYPE birth"], + $this->surname_tradition->newSpouseNames($individual, 'F') + ); + + self::assertSame( + ["1 NAME //\n2 TYPE birth"], + $this->surname_tradition->newSpouseNames($individual, 'U') ); } /** - * Test new spouse names - * - * @covers \Fisharebest\Webtrees\SurnameTradition\DefaultSurnameTradition + * Prepare the environment for these tests * * @return void */ - public function testNewSpouseNames(): void + protected function setUp(): void { - self::assertSame( - ['NAME' => '//'], - $this->surname_tradition->newSpouseNames('Chris /Green/', 'U') - ); + parent::setUp(); + + $this->surname_tradition = new DefaultSurnameTradition(); } } diff --git a/tests/app/SurnameTradition/IcelandicSurnameTraditionTest.php b/tests/app/SurnameTradition/IcelandicSurnameTraditionTest.php index b42375899f..9b5ee9141e 100644 --- a/tests/app/SurnameTradition/IcelandicSurnameTraditionTest.php +++ b/tests/app/SurnameTradition/IcelandicSurnameTraditionTest.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 IcelandicSurnameTradition @@ -29,18 +32,6 @@ class IcelandicSurnameTraditionTest extends TestCase private SurnameTraditionInterface $surname_tradition; /** - * Prepare the environment for these tests - * - * @return void - */ - protected function setUp(): void - { - parent::setUp(); - - $this->surname_tradition = new IcelandicSurnameTradition(); - } - - /** * Test whether married surnames are used * * @covers \Fisharebest\Webtrees\SurnameTradition\IcelandicSurnameTradition @@ -73,9 +64,21 @@ class IcelandicSurnameTraditionTest extends TestCase */ public function testNewSonNames(): void { + $father_fact = $this->createStub(Fact::class); + $father_fact->expects(self::any())->method('value')->willReturn('Jon Einarsson'); + + $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('Eva Stefansdottir'); + + $mother = $this->createStub(Individual::class); + $mother->expects(self::any())->method('facts')->willReturn(new Collection([$mother_fact])); + self::assertSame( - ['NAME' => 'Jonsson'], - $this->surname_tradition->newChildNames('Jon Einarsson', 'Eva Stefansdottir', 'M') + ["1 NAME Jonsson\n2 TYPE birth\n2 GIVN Jonsson"], + $this->surname_tradition->newChildNames($father, $mother, 'M') ); } @@ -88,9 +91,21 @@ class IcelandicSurnameTraditionTest extends TestCase */ public function testNewDaughterNames(): void { + $father_fact = $this->createStub(Fact::class); + $father_fact->expects(self::any())->method('value')->willReturn('Jon Einarsson'); + + $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('Eva Stefansdottir'); + + $mother = $this->createStub(Individual::class); + $mother->expects(self::any())->method('facts')->willReturn(new Collection([$mother_fact])); + self::assertSame( - ['NAME' => 'Jonsdottir'], - $this->surname_tradition->newChildNames('Jon Einarsson', 'Eva Stefansdottir', 'F') + ["1 NAME Jonsdottir\n2 TYPE birth\n2 GIVN Jonsdottir"], + $this->surname_tradition->newChildNames($father, $mother, 'F') ); } @@ -103,9 +118,21 @@ class IcelandicSurnameTraditionTest extends TestCase */ public function testNewChildNames(): void { + $father_fact = $this->createStub(Fact::class); + $father_fact->expects(self::any())->method('value')->willReturn('Jon Einarsson'); + + $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('Eva Stefansdottir'); + + $mother = $this->createStub(Individual::class); + $mother->expects(self::any())->method('facts')->willReturn(new Collection([$mother_fact])); + self::assertSame( - [], - $this->surname_tradition->newChildNames('Jon Einarsson', 'Eva Stefansdottir', 'U') + ["1 NAME\n2 TYPE birth"], + $this->surname_tradition->newChildNames($father, $mother, 'U') ); } @@ -118,12 +145,15 @@ class IcelandicSurnameTraditionTest extends TestCase */ public function testNewFatherNames(): void { + $fact = $this->createStub(Fact::class); + $fact->expects(self::any())->method('value')->willReturn('Jon Einarsson'); + + $individual = $this->createStub(Individual::class); + $individual->expects(self::any())->method('facts')->willReturn(new Collection([$fact])); + self::assertSame( - [ - 'NAME' => 'Einar', - 'GIVN' => 'Einar', - ], - $this->surname_tradition->newParentNames('Jon Einarsson', 'M') + ["1 NAME Einar\n2 TYPE birth\n2 GIVN Einar"], + $this->surname_tradition->newParentNames($individual, 'M') ); } @@ -136,9 +166,15 @@ class IcelandicSurnameTraditionTest extends TestCase */ public function testNewMotherNames(): void { + $fact = $this->createStub(Fact::class); + $fact->expects(self::any())->method('value')->willReturn('Jon Evasdottir'); + + $individual = $this->createStub(Individual::class); + $individual->expects(self::any())->method('facts')->willReturn(new Collection([$fact])); + self::assertSame( - [], - $this->surname_tradition->newParentNames('Jon Einarsson', 'F') + ["1 NAME Eva\n2 TYPE birth\n2 GIVN Eva"], + $this->surname_tradition->newParentNames($individual, 'F') ); } @@ -151,54 +187,58 @@ class IcelandicSurnameTraditionTest extends TestCase */ public function testNewParentNames(): void { + $fact = $this->createStub(Fact::class); + $fact->expects(self::any())->method('value')->willReturn('Jon Einarsson'); + + $individual = $this->createStub(Individual::class); + $individual->expects(self::any())->method('facts')->willReturn(new Collection([$fact])); + self::assertSame( - [], - $this->surname_tradition->newParentNames('Jon Einarsson', 'U') + ["1 NAME\n2 TYPE birth"], + $this->surname_tradition->newParentNames($individual, 'U') ); } /** - * Test new husband names + * Test new spouse names * * @covers \Fisharebest\Webtrees\SurnameTradition\IcelandicSurnameTradition * * @return void */ - public function testNewHusbandNames(): void + public function testNewSpouseNames(): void { + $fact = $this->createStub(Fact::class); + $fact->expects(self::any())->method('value')->willReturn('Jon Einarsson'); + + $individual = $this->createStub(Individual::class); + $individual->expects(self::any())->method('facts')->willReturn(new Collection([$fact])); + self::assertSame( - [], - $this->surname_tradition->newSpouseNames('Eva Stefansdottir', 'M') + ["1 NAME\n2 TYPE birth"], + $this->surname_tradition->newSpouseNames($individual, 'M') ); - } - /** - * Test new wife names - * - * @covers \Fisharebest\Webtrees\SurnameTradition\IcelandicSurnameTradition - * - * @return void - */ - public function testNewWifeNames(): void - { self::assertSame( - [], - $this->surname_tradition->newSpouseNames('Jon Einarsson', 'F') + ["1 NAME\n2 TYPE birth"], + $this->surname_tradition->newSpouseNames($individual, 'F') + ); + + self::assertSame( + ["1 NAME\n2 TYPE birth"], + $this->surname_tradition->newSpouseNames($individual, 'U') ); } /** - * Test new spouse names - * - * @covers \Fisharebest\Webtrees\SurnameTradition\IcelandicSurnameTradition + * Prepare the environment for these tests * * @return void */ - public function testNewSpouseNames(): void + protected function setUp(): void { - self::assertSame( - [], - $this->surname_tradition->newSpouseNames('Jon Einarsson', 'U') - ); + parent::setUp(); + + $this->surname_tradition = new IcelandicSurnameTradition(); } } diff --git a/tests/app/SurnameTradition/LithuanianSurnameTraditionTest.php b/tests/app/SurnameTradition/LithuanianSurnameTraditionTest.php index 41acceda7e..f229eba96d 100644 --- a/tests/app/SurnameTradition/LithuanianSurnameTraditionTest.php +++ b/tests/app/SurnameTradition/LithuanianSurnameTraditionTest.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 LithuanianSurnameTraditionTest @@ -76,12 +79,21 @@ class LithuanianSurnameTraditionTest extends TestCase */ public function testNewSonNames(): void { + $father_fact = $this->createStub(Fact::class); + $father_fact->expects(self::any())->method('value')->willReturn('John /White/'); + + $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('Mary /Black/'); + + $mother = $this->createStub(Individual::class); + $mother->expects(self::any())->method('facts')->willReturn(new Collection([$mother_fact])); + self::assertSame( - [ - 'NAME' => '/White/', - 'SURN' => 'White', - ], - $this->surname_tradition->newChildNames('John /White/', 'Mary /Black/', 'M') + ["1 NAME /White/\n2 TYPE birth\n2 SURN White"], + $this->surname_tradition->newChildNames($father, $mother, 'M') ); } @@ -95,12 +107,21 @@ class LithuanianSurnameTraditionTest extends TestCase */ public function testNewDaughterNames(): void { + $father_fact = $this->createStub(Fact::class); + $father_fact->expects(self::any())->method('value')->willReturn('John /White/'); + + $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('Mary /Black/'); + + $mother = $this->createStub(Individual::class); + $mother->expects(self::any())->method('facts')->willReturn(new Collection([$mother_fact])); + self::assertSame( - [ - 'NAME' => '/White/', - 'SURN' => 'White', - ], - $this->surname_tradition->newChildNames('John /White/', 'Mary /Black/', 'F') + ["1 NAME /White/\n2 TYPE birth\n2 SURN White"], + $this->surname_tradition->newChildNames($father, $mother, 'F') ); } @@ -114,47 +135,76 @@ class LithuanianSurnameTraditionTest extends TestCase */ public function testNewDaughterNamesInflected(): void { + $father_fact = $this->createStub(Fact::class); + $father_fact->expects(self::any())->method('value')->willReturn('John /Whita/'); + + $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('Mary /Black/'); + + $mother = $this->createStub(Individual::class); + $mother->expects(self::any())->method('facts')->willReturn(new Collection([$mother_fact])); + self::assertSame( - [ - 'NAME' => '/Whitaitė/', - 'SURN' => 'Whita', - ], - $this->surname_tradition->newChildNames('John /Whita/', 'Mary /Black/', 'F') + ["1 NAME /Whitaitė/\n2 TYPE birth\n2 SURN Whita"], + $this->surname_tradition->newChildNames($father, $mother, 'F') ); + + $father_fact = $this->createStub(Fact::class); + $father_fact->expects(self::any())->method('value')->willReturn('John /Whitas/'); + + $father = $this->createStub(Individual::class); + $father->expects(self::any())->method('facts')->willReturn(new Collection([$father_fact])); + self::assertSame( - [ - 'NAME' => '/Whitaitė/', - 'SURN' => 'Whitas', - ], - $this->surname_tradition->newChildNames('John /Whitas/', 'Mary /Black/', 'F') + ["1 NAME /Whitaitė/\n2 TYPE birth\n2 SURN Whitas"], + $this->surname_tradition->newChildNames($father, $mother, 'F') ); + + $father_fact = $this->createStub(Fact::class); + $father_fact->expects(self::any())->method('value')->willReturn('John /Whitis/'); + + $father = $this->createStub(Individual::class); + $father->expects(self::any())->method('facts')->willReturn(new Collection([$father_fact])); + self::assertSame( - [ - 'NAME' => '/Whitytė/', - 'SURN' => 'Whitis', - ], - $this->surname_tradition->newChildNames('John /Whitis/', 'Mary /Black/', 'F') + ["1 NAME /Whitytė/\n2 TYPE birth\n2 SURN Whitis"], + $this->surname_tradition->newChildNames($father, $mother, 'F') ); + + $father_fact = $this->createStub(Fact::class); + $father_fact->expects(self::any())->method('value')->willReturn('John /Whitys/'); + + $father = $this->createStub(Individual::class); + $father->expects(self::any())->method('facts')->willReturn(new Collection([$father_fact])); + self::assertSame( - [ - 'NAME' => '/Whitytė/', - 'SURN' => 'Whitys', - ], - $this->surname_tradition->newChildNames('John /Whitys/', 'Mary /Black/', 'F') + ["1 NAME /Whitytė/\n2 TYPE birth\n2 SURN Whitys"], + $this->surname_tradition->newChildNames($father, $mother, 'F') ); + + $father_fact = $this->createStub(Fact::class); + $father_fact->expects(self::any())->method('value')->willReturn('John /Whitius/'); + + $father = $this->createStub(Individual::class); + $father->expects(self::any())->method('facts')->willReturn(new Collection([$father_fact])); + self::assertSame( - [ - 'NAME' => '/Whitiūtė/', - 'SURN' => 'Whitius', - ], - $this->surname_tradition->newChildNames('John /Whitius/', 'Mary /Black/', 'F') + ["1 NAME /Whitiūtė/\n2 TYPE birth\n2 SURN Whitius"], + $this->surname_tradition->newChildNames($father, $mother, 'F') ); + + $father_fact = $this->createStub(Fact::class); + $father_fact->expects(self::any())->method('value')->willReturn('John /Whitus/'); + + $father = $this->createStub(Individual::class); + $father->expects(self::any())->method('facts')->willReturn(new Collection([$father_fact])); + self::assertSame( - [ - 'NAME' => '/Whitutė/', - 'SURN' => 'Whitus', - ], - $this->surname_tradition->newChildNames('John /Whitus/', 'Mary /Black/', 'F') + ["1 NAME /Whitutė/\n2 TYPE birth\n2 SURN Whitus"], + $this->surname_tradition->newChildNames($father, $mother, 'F') ); } @@ -168,12 +218,21 @@ class LithuanianSurnameTraditionTest extends TestCase */ public function testNewChildNames(): void { + $father_fact = $this->createStub(Fact::class); + $father_fact->expects(self::any())->method('value')->willReturn('John /White/'); + + $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('Mary /Black/'); + + $mother = $this->createStub(Individual::class); + $mother->expects(self::any())->method('facts')->willReturn(new Collection([$mother_fact])); + self::assertSame( - [ - 'NAME' => '/White/', - 'SURN' => 'White', - ], - $this->surname_tradition->newChildNames('John /White/', 'Mary /Black/', 'U') + ["1 NAME /White/\n2 TYPE birth\n2 SURN White"], + $this->surname_tradition->newChildNames($father, $mother, 'U') ); } @@ -188,8 +247,8 @@ class LithuanianSurnameTraditionTest extends TestCase public function testNewChildNamesWithNoParentsNames(): void { self::assertSame( - ['NAME' => '//'], - $this->surname_tradition->newChildNames('', '', 'U') + ["1 NAME //\n2 TYPE birth"], + $this->surname_tradition->newChildNames(null, null, 'U') ); } @@ -203,12 +262,15 @@ class LithuanianSurnameTraditionTest extends TestCase */ public function testNewFatherNames(): void { + $fact = $this->createStub(Fact::class); + $fact->expects(self::any())->method('value')->willReturn('John /White/'); + + $individual = $this->createStub(Individual::class); + $individual->expects(self::any())->method('facts')->willReturn(new Collection([$fact])); + self::assertSame( - [ - 'NAME' => '/White/', - 'SURN' => 'White', - ], - $this->surname_tradition->newParentNames('John /White/', 'M') + ["1 NAME /White/\n2 TYPE birth\n2 SURN White"], + $this->surname_tradition->newParentNames($individual, 'M') ); } @@ -222,33 +284,48 @@ class LithuanianSurnameTraditionTest extends TestCase */ public function testNewFatherNamesInflected(): void { + $fact = $this->createStub(Fact::class); + $fact->expects(self::any())->method('value')->willReturn('Mary /Whitaitė/'); + + $individual = $this->createStub(Individual::class); + $individual->expects(self::any())->method('facts')->willReturn(new Collection([$fact])); + self::assertSame( - [ - 'NAME' => '/Whitas/', - 'SURN' => 'Whitas', - ], - $this->surname_tradition->newParentNames('Mary /Whitaitė/', 'M') + ["1 NAME /Whitas/\n2 TYPE birth\n2 SURN Whitas"], + $this->surname_tradition->newParentNames($individual, 'M') ); + + $fact = $this->createStub(Fact::class); + $fact->expects(self::any())->method('value')->willReturn('Mary /Whitytė/'); + + $individual = $this->createStub(Individual::class); + $individual->expects(self::any())->method('facts')->willReturn(new Collection([$fact])); + self::assertSame( - [ - 'NAME' => '/Whitis/', - 'SURN' => 'Whitis', - ], - $this->surname_tradition->newParentNames('Mary /Whitytė/', 'M') + ["1 NAME /Whitis/\n2 TYPE birth\n2 SURN Whitis"], + $this->surname_tradition->newParentNames($individual, 'M') ); + + $fact = $this->createStub(Fact::class); + $fact->expects(self::any())->method('value')->willReturn('Mary /Whitiūtė/'); + + $individual = $this->createStub(Individual::class); + $individual->expects(self::any())->method('facts')->willReturn(new Collection([$fact])); + self::assertSame( - [ - 'NAME' => '/Whitius/', - 'SURN' => 'Whitius', - ], - $this->surname_tradition->newParentNames('Mary /Whitiūtė/', 'M') + ["1 NAME /Whitius/\n2 TYPE birth\n2 SURN Whitius"], + $this->surname_tradition->newParentNames($individual, 'M') ); + + $fact = $this->createStub(Fact::class); + $fact->expects(self::any())->method('value')->willReturn('Mary /Whitutė/'); + + $individual = $this->createStub(Individual::class); + $individual->expects(self::any())->method('facts')->willReturn(new Collection([$fact])); + self::assertSame( - [ - 'NAME' => '/Whitus/', - 'SURN' => 'Whitus', - ], - $this->surname_tradition->newParentNames('Mary /Whitutė/', 'M') + ["1 NAME /Whitus/\n2 TYPE birth\n2 SURN Whitus"], + $this->surname_tradition->newParentNames($individual, 'M') ); } @@ -262,9 +339,15 @@ class LithuanianSurnameTraditionTest extends TestCase */ public function testNewMotherNames(): void { + $fact = $this->createStub(Fact::class); + $fact->expects(self::any())->method('value')->willReturn('John /White/'); + + $individual = $this->createStub(Individual::class); + $individual->expects(self::any())->method('facts')->willReturn(new Collection([$fact])); + self::assertSame( - ['NAME' => '//'], - $this->surname_tradition->newParentNames('John /White/', 'F') + ["1 NAME //\n2 TYPE birth"], + $this->surname_tradition->newParentNames($individual, 'F') ); } @@ -278,9 +361,15 @@ class LithuanianSurnameTraditionTest extends TestCase */ public function testNewParentNames(): void { + $fact = $this->createStub(Fact::class); + $fact->expects(self::any())->method('value')->willReturn('John /White/'); + + $individual = $this->createStub(Individual::class); + $individual->expects(self::any())->method('facts')->willReturn(new Collection([$fact])); + self::assertSame( - ['NAME' => '//'], - $this->surname_tradition->newParentNames('John /White/', 'U') + ["1 NAME //\n2 TYPE birth"], + $this->surname_tradition->newParentNames($individual, 'U') ); } @@ -294,9 +383,15 @@ class LithuanianSurnameTraditionTest extends TestCase */ public function testNewHusbandNames(): void { + $fact = $this->createStub(Fact::class); + $fact->expects(self::any())->method('value')->willReturn('Mary /Black/'); + + $individual = $this->createStub(Individual::class); + $individual->expects(self::any())->method('facts')->willReturn(new Collection([$fact])); + self::assertSame( - ['NAME' => '//'], - $this->surname_tradition->newSpouseNames('Mary /Black/', 'M') + ["1 NAME //\n2 TYPE birth"], + $this->surname_tradition->newSpouseNames($individual, 'M') ); } @@ -310,12 +405,15 @@ class LithuanianSurnameTraditionTest extends TestCase */ public function testNewWifeNames(): void { + $fact = $this->createStub(Fact::class); + $fact->expects(self::any())->method('value')->willReturn('John /White/'); + + $individual = $this->createStub(Individual::class); + $individual->expects(self::any())->method('facts')->willReturn(new Collection([$fact])); + self::assertSame( - [ - 'NAME' => '//', - '_MARNM' => '/White/', - ], - $this->surname_tradition->newSpouseNames('John /White/', 'F') + ["1 NAME //\n2 TYPE birth", "1 NAME /White/\n2 TYPE married\n2 SURN White"], + $this->surname_tradition->newSpouseNames($individual, 'F') ); } @@ -329,9 +427,15 @@ class LithuanianSurnameTraditionTest extends TestCase */ public function testNewSpouseNames(): void { + $fact = $this->createStub(Fact::class); + $fact->expects(self::any())->method('value')->willReturn('John /White/'); + + $individual = $this->createStub(Individual::class); + $individual->expects(self::any())->method('facts')->willReturn(new Collection([$fact])); + self::assertSame( - ['NAME' => '//'], - $this->surname_tradition->newSpouseNames('Chris /Green/', 'U') + ["1 NAME //\n2 TYPE birth"], + $this->surname_tradition->newSpouseNames($individual, 'U') ); } } diff --git a/tests/app/SurnameTradition/MatrilinealSurnameTraditionTest.php b/tests/app/SurnameTradition/MatrilinealSurnameTraditionTest.php index 91bbb92c44..0ec0e67ef7 100644 --- a/tests/app/SurnameTradition/MatrilinealSurnameTraditionTest.php +++ b/tests/app/SurnameTradition/MatrilinealSurnameTraditionTest.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 MatrilinenalSurnameTradition @@ -65,56 +68,39 @@ class MatrilinealSurnameTraditionTest extends TestCase } /** - * Test new son names + * Test new child names * * @covers \Fisharebest\Webtrees\SurnameTradition\MatrilinealSurnameTradition * * @return void */ - public function testNewSonNames(): void + public function testNewChildNames(): void { + $father_fact = $this->createStub(Fact::class); + $father_fact->expects(self::any())->method('value')->willReturn('John /White/'); + + $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('Mary /Black/'); + + $mother = $this->createStub(Individual::class); + $mother->expects(self::any())->method('facts')->willReturn(new Collection([$mother_fact])); + self::assertSame( - [ - 'NAME' => '/Black/', - 'SURN' => 'Black', - ], - $this->surname_tradition->newChildNames('John /White/', 'Mary /Black/', 'M') + ["1 NAME /Black/\n2 TYPE birth\n2 SURN Black"], + $this->surname_tradition->newChildNames($father, $mother, 'M') ); - } - /** - * Test new daughter names - * - * @covers \Fisharebest\Webtrees\SurnameTradition\MatrilinealSurnameTradition - * - * @return void - */ - public function testNewDaughterNames(): void - { self::assertSame( - [ - 'NAME' => '/Black/', - 'SURN' => 'Black', - ], - $this->surname_tradition->newChildNames('John /White/', 'Mary /Black/', 'F') + ["1 NAME /Black/\n2 TYPE birth\n2 SURN Black"], + $this->surname_tradition->newChildNames($father, $mother, 'F') ); - } - /** - * Test new child names - * - * @covers \Fisharebest\Webtrees\SurnameTradition\MatrilinealSurnameTradition - * - * @return void - */ - public function testNewChildNames(): void - { self::assertSame( - [ - 'NAME' => '/Black/', - 'SURN' => 'Black', - ], - $this->surname_tradition->newChildNames('John /White/', 'Mary /Black/', 'U') + ["1 NAME /Black/\n2 TYPE birth\n2 SURN Black"], + $this->surname_tradition->newChildNames($father, $mother, 'U') ); } @@ -127,13 +113,21 @@ class MatrilinealSurnameTraditionTest extends TestCase */ public function testNewChildNamesWithSpfx(): void { + $father_fact = $this->createStub(Fact::class); + $father_fact->expects(self::any())->method('value')->willReturn('John /de White/'); + + $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('Mary /van Black/'); + + $mother = $this->createStub(Individual::class); + $mother->expects(self::any())->method('facts')->willReturn(new Collection([$mother_fact])); + self::assertSame( - [ - 'NAME' => '/van Black/', - 'SPFX' => 'van', - 'SURN' => 'Black', - ], - $this->surname_tradition->newChildNames('John /de White/', 'Mary /van Black/', 'U') + ["1 NAME /van Black/\n2 TYPE birth\n2 SPFX van\n2 SURN Black"], + $this->surname_tradition->newChildNames($father, $mother, 'U') ); } @@ -147,101 +141,71 @@ class MatrilinealSurnameTraditionTest extends TestCase public function testNewChildNamesWithNoParentsNames(): void { self::assertSame( - ['NAME' => '//'], - $this->surname_tradition->newChildNames('', '', 'U') + ["1 NAME //\n2 TYPE birth"], + $this->surname_tradition->newChildNames(null, null, 'U') ); } /** - * Test new father names + * Test new parent names * * @covers \Fisharebest\Webtrees\SurnameTradition\MatrilinealSurnameTradition * * @return void */ - public function testNewFatherNames(): void + public function testNewParentNames(): void { + $fact = $this->createStub(Fact::class); + $fact->expects(self::any())->method('value')->willReturn('Chris /White/'); + + $individual = $this->createStub(Individual::class); + $individual->expects(self::any())->method('facts')->willReturn(new Collection([$fact])); + + self::assertSame( - ['NAME' => '//'], - $this->surname_tradition->newParentNames('John /White/', 'M') + ["1 NAME //\n2 TYPE birth"], + $this->surname_tradition->newParentNames($individual, 'M') ); - } - /** - * Test new mother names - * - * @covers \Fisharebest\Webtrees\SurnameTradition\MatrilinealSurnameTradition - * - * @return void - */ - public function testNewMotherNames(): void - { self::assertSame( - [ - 'NAME' => '/White/', - 'SURN' => 'White', - ], - $this->surname_tradition->newParentNames('John /White/', 'F') + ["1 NAME /White/\n2 TYPE birth\n2 SURN White"], + $this->surname_tradition->newParentNames($individual, 'F') ); - } - /** - * Test new parent names - * - * @covers \Fisharebest\Webtrees\SurnameTradition\MatrilinealSurnameTradition - * - * @return void - */ - public function testNewParentNames(): void - { self::assertSame( - ['NAME' => '//'], - $this->surname_tradition->newParentNames('John /White/', 'U') + ["1 NAME //\n2 TYPE birth"], + $this->surname_tradition->newParentNames($individual, 'U') ); } /** - * Test new husband names + * Test new spouse names * * @covers \Fisharebest\Webtrees\SurnameTradition\MatrilinealSurnameTradition * * @return void */ - public function testNewHusbandNames(): void + public function testNewSpouseNames(): void { + $fact = $this->createStub(Fact::class); + $fact->expects(self::any())->method('value')->willReturn('Chris /White/'); + + $individual = $this->createStub(Individual::class); + $individual->expects(self::any())->method('facts')->willReturn(new Collection([$fact])); + self::assertSame( - ['NAME' => '//'], - $this->surname_tradition->newSpouseNames('Mary /Black/', 'M') + ["1 NAME //\n2 TYPE birth"], + $this->surname_tradition->newSpouseNames($individual, 'M') ); - } - /** - * Test new wife names - * - * @covers \Fisharebest\Webtrees\SurnameTradition\MatrilinealSurnameTradition - * - * @return void - */ - public function testNewWifeNames(): void - { self::assertSame( - ['NAME' => '//'], - $this->surname_tradition->newSpouseNames('John /White/', 'F') + ["1 NAME //\n2 TYPE birth"], + $this->surname_tradition->newSpouseNames($individual, 'F') ); - } - /** - * Test new spouse names - * - * @covers \Fisharebest\Webtrees\SurnameTradition\MatrilinealSurnameTradition - * - * @return void - */ - public function testNewSpouseNames(): void - { self::assertSame( - ['NAME' => '//'], - $this->surname_tradition->newSpouseNames('Chris /Green/', 'U') + ["1 NAME //\n2 TYPE birth"], + $this->surname_tradition->newSpouseNames($individual, 'U') ); } } diff --git a/tests/app/SurnameTradition/PaternalSurnameTraditionTest.php b/tests/app/SurnameTradition/PaternalSurnameTraditionTest.php index 998c8fb42a..c4efe279bc 100644 --- a/tests/app/SurnameTradition/PaternalSurnameTraditionTest.php +++ b/tests/app/SurnameTradition/PaternalSurnameTraditionTest.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 PaternalSurnameTradition @@ -29,18 +32,6 @@ class PaternalSurnameTraditionTest extends TestCase private SurnameTraditionInterface $surname_tradition; /** - * Prepare the environment for these tests - * - * @return void - */ - protected function setUp(): void - { - parent::setUp(); - - $this->surname_tradition = new PaternalSurnameTradition(); - } - - /** * Test whether married surnames are used * * @covers \Fisharebest\Webtrees\SurnameTradition\PaternalSurnameTradition @@ -65,56 +56,39 @@ class PaternalSurnameTraditionTest extends TestCase } /** - * Test new son names + * Test new child names * * @covers \Fisharebest\Webtrees\SurnameTradition\PaternalSurnameTradition * * @return void */ - public function testNewSonNames(): void + public function testNewChildNames(): void { + $father_fact = $this->createStub(Fact::class); + $father_fact->expects(self::any())->method('value')->willReturn('John /White/'); + + $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('Mary /Black/'); + + $mother = $this->createStub(Individual::class); + $mother->expects(self::any())->method('facts')->willReturn(new Collection([$mother_fact])); + self::assertSame( - [ - 'NAME' => '/White/', - 'SURN' => 'White', - ], - $this->surname_tradition->newChildNames('John /White/', 'Mary /Black/', 'M') + ["1 NAME /White/\n2 TYPE birth\n2 SURN White"], + $this->surname_tradition->newChildNames($father, $mother, 'M') ); - } - /** - * Test new daughter names - * - * @covers \Fisharebest\Webtrees\SurnameTradition\PaternalSurnameTradition - * - * @return void - */ - public function testNewDaughterNames(): void - { self::assertSame( - [ - 'NAME' => '/White/', - 'SURN' => 'White', - ], - $this->surname_tradition->newChildNames('John /White/', 'Mary /Black/', 'F') + ["1 NAME /White/\n2 TYPE birth\n2 SURN White"], + $this->surname_tradition->newChildNames($father, $mother, 'F') ); - } - /** - * Test new child names - * - * @covers \Fisharebest\Webtrees\SurnameTradition\PaternalSurnameTradition - * - * @return void - */ - public function testNewChildNames(): void - { self::assertSame( - [ - 'NAME' => '/White/', - 'SURN' => 'White', - ], - $this->surname_tradition->newChildNames('John /White/', 'Mary /Black/', 'U') + ["1 NAME /White/\n2 TYPE birth\n2 SURN White"], + $this->surname_tradition->newChildNames($father, $mother, 'U') ); } @@ -127,13 +101,21 @@ class PaternalSurnameTraditionTest extends TestCase */ public function testNewChildNamesWithSpfx(): void { + $father_fact = $this->createStub(Fact::class); + $father_fact->expects(self::any())->method('value')->willReturn('John /de White/'); + + $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('Mary /van Black/'); + + $mother = $this->createStub(Individual::class); + $mother->expects(self::any())->method('facts')->willReturn(new Collection([$mother_fact])); + self::assertSame( - [ - 'NAME' => '/de White/', - 'SPFX' => 'de', - 'SURN' => 'White', - ], - $this->surname_tradition->newChildNames('John /de White/', 'Mary /van Black/', 'U') + ["1 NAME /de White/\n2 TYPE birth\n2 SPFX de\n2 SURN White"], + $this->surname_tradition->newChildNames($father, $mother, 'U') ); } @@ -146,13 +128,21 @@ class PaternalSurnameTraditionTest extends TestCase */ public function testNewChildNamesWithMultipleSpfx(): void { + $father_fact = $this->createStub(Fact::class); + $father_fact->expects(self::any())->method('value')->willReturn('John /van der White/'); + + $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('Mary /van Black/'); + + $mother = $this->createStub(Individual::class); + $mother->expects(self::any())->method('facts')->willReturn(new Collection([$mother_fact])); + self::assertSame( - [ - 'NAME' => '/van der White/', - 'SPFX' => 'van der', - 'SURN' => 'White', - ], - $this->surname_tradition->newChildNames('John /van der White/', 'Mary /van Black/', 'U') + ["1 NAME /van der White/\n2 TYPE birth\n2 SPFX van der\n2 SURN White"], + $this->surname_tradition->newChildNames($father, $mother, 'U') ); } @@ -165,21 +155,21 @@ class PaternalSurnameTraditionTest extends TestCase */ public function testNewChildNamesWithDutchSpfx(): void { + $father_fact = $this->createStub(Fact::class); + $father_fact->expects(self::any())->method('value')->willReturn('John /\'t White/'); + + $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('Mary /van Black/'); + + $mother = $this->createStub(Individual::class); + $mother->expects(self::any())->method('facts')->willReturn(new Collection([$mother_fact])); + self::assertSame( - [ - 'NAME' => '/\'t White/', - 'SPFX' => '\'t', - 'SURN' => 'White', - ], - $this->surname_tradition->newChildNames('John /\'t White/', 'Mary /van Black/', 'U') - ); - self::assertSame( - [ - 'NAME' => '/’t White/', - 'SPFX' => '’t', - 'SURN' => 'White', - ], - $this->surname_tradition->newChildNames('John /’t White/', 'Mary /van Black/', 'U') + ["1 NAME /'t White/\n2 TYPE birth\n2 SPFX 't\n2 SURN White"], + $this->surname_tradition->newChildNames($father, $mother, 'U') ); } @@ -192,21 +182,21 @@ class PaternalSurnameTraditionTest extends TestCase */ public function testNewChildNamesWithMultipleDutchSpfx(): void { + $father_fact = $this->createStub(Fact::class); + $father_fact->expects(self::any())->method('value')->willReturn('John /van \'t White/'); + + $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('Mary /van Black/'); + + $mother = $this->createStub(Individual::class); + $mother->expects(self::any())->method('facts')->willReturn(new Collection([$mother_fact])); + self::assertSame( - [ - 'NAME' => '/van \'t White/', - 'SPFX' => 'van \'t', - 'SURN' => 'White', - ], - $this->surname_tradition->newChildNames('John /van \'t White/', 'Mary /van Black/', 'U') - ); - self::assertSame( - [ - 'NAME' => '/van ’t White/', - 'SPFX' => 'van ’t', - 'SURN' => 'White', - ], - $this->surname_tradition->newChildNames('John /van ’t White/', 'Mary /van Black/', 'U') + ["1 NAME /van 't White/\n2 TYPE birth\n2 SPFX van 't\n2 SURN White"], + $this->surname_tradition->newChildNames($father, $mother, 'U') ); } @@ -219,12 +209,15 @@ class PaternalSurnameTraditionTest extends TestCase */ public function testNewFatherNames(): void { + $fact = $this->createStub(Fact::class); + $fact->expects(self::any())->method('value')->willReturn('Chris /White/'); + + $individual = $this->createStub(Individual::class); + $individual->expects(self::any())->method('facts')->willReturn(new Collection([$fact])); + self::assertSame( - [ - 'NAME' => '/White/', - 'SURN' => 'White', - ], - $this->surname_tradition->newParentNames('John /White/', 'M') + ["1 NAME /White/\n2 TYPE birth\n2 SURN White"], + $this->surname_tradition->newParentNames($individual, 'M') ); } @@ -237,12 +230,15 @@ class PaternalSurnameTraditionTest extends TestCase */ public function testNewMotherNames(): void { + $fact = $this->createStub(Fact::class); + $fact->expects(self::any())->method('value')->willReturn('Chris /White/'); + + $individual = $this->createStub(Individual::class); + $individual->expects(self::any())->method('facts')->willReturn(new Collection([$fact])); + self::assertSame( - [ - 'NAME' => '//', - '_MARNM' => '/White/', - ], - $this->surname_tradition->newParentNames('John /White/', 'F') + ["1 NAME //\n2 TYPE birth", "1 NAME /White/\n2 TYPE married\n2 SURN White"], + $this->surname_tradition->newParentNames($individual, 'F') ); } @@ -255,9 +251,15 @@ class PaternalSurnameTraditionTest extends TestCase */ public function testNewParentNames(): void { + $fact = $this->createStub(Fact::class); + $fact->expects(self::any())->method('value')->willReturn('Chris /White/'); + + $individual = $this->createStub(Individual::class); + $individual->expects(self::any())->method('facts')->willReturn(new Collection([$fact])); + self::assertSame( - ['NAME' => '//'], - $this->surname_tradition->newParentNames('John /White/', 'U') + ["1 NAME //\n2 TYPE birth"], + $this->surname_tradition->newParentNames($individual, 'U') ); } @@ -270,9 +272,15 @@ class PaternalSurnameTraditionTest extends TestCase */ public function testNewHusbandNames(): void { + $fact = $this->createStub(Fact::class); + $fact->expects(self::any())->method('value')->willReturn('Chris /White/'); + + $individual = $this->createStub(Individual::class); + $individual->expects(self::any())->method('facts')->willReturn(new Collection([$fact])); + self::assertSame( - ['NAME' => '//'], - $this->surname_tradition->newSpouseNames('Mary /Black/', 'M') + ["1 NAME //\n2 TYPE birth"], + $this->surname_tradition->newSpouseNames($individual, 'M') ); } @@ -285,12 +293,15 @@ class PaternalSurnameTraditionTest extends TestCase */ public function testNewWifeNames(): void { + $fact = $this->createStub(Fact::class); + $fact->expects(self::any())->method('value')->willReturn('Chris /White/'); + + $individual = $this->createStub(Individual::class); + $individual->expects(self::any())->method('facts')->willReturn(new Collection([$fact])); + self::assertSame( - [ - 'NAME' => '//', - '_MARNM' => '/White/', - ], - $this->surname_tradition->newSpouseNames('John /White/', 'F') + ["1 NAME //\n2 TYPE birth", "1 NAME /White/\n2 TYPE married\n2 SURN White"], + $this->surname_tradition->newSpouseNames($individual, 'F') ); } @@ -303,12 +314,15 @@ class PaternalSurnameTraditionTest extends TestCase */ public function testNewWifeNamesWithSpfx(): void { + $fact = $this->createStub(Fact::class); + $fact->expects(self::any())->method('value')->willReturn('Chris /van der White/'); + + $individual = $this->createStub(Individual::class); + $individual->expects(self::any())->method('facts')->willReturn(new Collection([$fact])); + self::assertSame( - [ - 'NAME' => '//', - '_MARNM' => '/van der White/', - ], - $this->surname_tradition->newSpouseNames('John /van der White/', 'F') + ["1 NAME //\n2 TYPE birth", "1 NAME /van der White/\n2 TYPE married\n2 SPFX van der\n2 SURN White"], + $this->surname_tradition->newSpouseNames($individual, 'F') ); } @@ -321,9 +335,27 @@ class PaternalSurnameTraditionTest extends TestCase */ public function testNewSpouseNames(): void { + $fact = $this->createStub(Fact::class); + $fact->expects(self::any())->method('value')->willReturn('Chris /White/'); + + $individual = $this->createStub(Individual::class); + $individual->expects(self::any())->method('facts')->willReturn(new Collection([$fact])); + self::assertSame( - ['NAME' => '//'], - $this->surname_tradition->newSpouseNames('Chris /Green/', 'U') + ["1 NAME //\n2 TYPE birth"], + $this->surname_tradition->newSpouseNames($individual, 'U') ); } + + /** + * Prepare the environment for these tests + * + * @return void + */ + protected function setUp(): void + { + parent::setUp(); + + $this->surname_tradition = new PaternalSurnameTradition(); + } } diff --git a/tests/app/SurnameTradition/PatrilinealSurnameTraditionTest.php b/tests/app/SurnameTradition/PatrilinealSurnameTraditionTest.php index f21e14b6eb..51be302986 100644 --- a/tests/app/SurnameTradition/PatrilinealSurnameTraditionTest.php +++ b/tests/app/SurnameTradition/PatrilinealSurnameTraditionTest.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 PatrilinenalSurnameTradition @@ -65,56 +68,39 @@ class PatrilinealSurnameTraditionTest extends TestCase } /** - * Test new son names + * Test new child names * * @covers \Fisharebest\Webtrees\SurnameTradition\PatrilinealSurnameTradition * * @return void */ - public function testNewSonNames(): void + public function testNewChildNames(): void { + $father_fact = $this->createStub(Fact::class); + $father_fact->expects(self::any())->method('value')->willReturn('John /White/'); + + $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('Mary /Black/'); + + $mother = $this->createStub(Individual::class); + $mother->expects(self::any())->method('facts')->willReturn(new Collection([$mother_fact])); + self::assertSame( - [ - 'NAME' => '/White/', - 'SURN' => 'White', - ], - $this->surname_tradition->newChildNames('John /White/', 'Mary /Black/', 'M') + ["1 NAME /White/\n2 TYPE birth\n2 SURN White"], + $this->surname_tradition->newChildNames($father, $mother, 'M') ); - } - /** - * Test new daughter names - * - * @covers \Fisharebest\Webtrees\SurnameTradition\PatrilinealSurnameTradition - * - * @return void - */ - public function testNewDaughterNames(): void - { self::assertSame( - [ - 'NAME' => '/White/', - 'SURN' => 'White', - ], - $this->surname_tradition->newChildNames('John /White/', 'Mary /Black/', 'F') + ["1 NAME /White/\n2 TYPE birth\n2 SURN White"], + $this->surname_tradition->newChildNames($father, $mother, 'F') ); - } - /** - * Test new child names - * - * @covers \Fisharebest\Webtrees\SurnameTradition\PatrilinealSurnameTradition - * - * @return void - */ - public function testNewChildNames(): void - { self::assertSame( - [ - 'NAME' => '/White/', - 'SURN' => 'White', - ], - $this->surname_tradition->newChildNames('John /White/', 'Mary /Black/', 'U') + ["1 NAME /White/\n2 TYPE birth\n2 SURN White"], + $this->surname_tradition->newChildNames($father, $mother, 'U') ); } @@ -127,13 +113,21 @@ class PatrilinealSurnameTraditionTest extends TestCase */ public function testNewChildNamesWithSpfx(): void { + $father_fact = $this->createStub(Fact::class); + $father_fact->expects(self::any())->method('value')->willReturn('John /de White/'); + + $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('Mary /van Black/'); + + $mother = $this->createStub(Individual::class); + $mother->expects(self::any())->method('facts')->willReturn(new Collection([$mother_fact])); + self::assertSame( - [ - 'NAME' => '/de White/', - 'SPFX' => 'de', - 'SURN' => 'White', - ], - $this->surname_tradition->newChildNames('John /de White/', 'Mary /van Black/', 'U') + ["1 NAME /de White/\n2 TYPE birth\n2 SPFX de\n2 SURN White"], + $this->surname_tradition->newChildNames($father, $mother, 'U') ); } @@ -147,101 +141,70 @@ class PatrilinealSurnameTraditionTest extends TestCase public function testNewChildNamesWithNoParentsNames(): void { self::assertSame( - ['NAME' => '//'], - $this->surname_tradition->newChildNames('', '', 'U') + ["1 NAME //\n2 TYPE birth"], + $this->surname_tradition->newChildNames(null, null, 'U') ); } /** - * Test new father names + * Test new parent names * * @covers \Fisharebest\Webtrees\SurnameTradition\PatrilinealSurnameTradition * * @return void */ - public function testNewFatherNames(): void + public function testNewParentNames(): void { + $fact = $this->createStub(Fact::class); + $fact->expects(self::any())->method('value')->willReturn('Chris /White/'); + + $individual = $this->createStub(Individual::class); + $individual->expects(self::any())->method('facts')->willReturn(new Collection([$fact])); + self::assertSame( - [ - 'NAME' => '/White/', - 'SURN' => 'White', - ], - $this->surname_tradition->newParentNames('John /White/', 'M') + ["1 NAME /White/\n2 TYPE birth\n2 SURN White"], + $this->surname_tradition->newParentNames($individual, 'M') ); - } - /** - * Test new mother names - * - * @covers \Fisharebest\Webtrees\SurnameTradition\PatrilinealSurnameTradition - * - * @return void - */ - public function testNewMotherNames(): void - { self::assertSame( - ['NAME' => '//'], - $this->surname_tradition->newParentNames('John /White/', 'F') + ["1 NAME //\n2 TYPE birth"], + $this->surname_tradition->newParentNames($individual, 'F') ); - } - /** - * Test new parent names - * - * @covers \Fisharebest\Webtrees\SurnameTradition\PatrilinealSurnameTradition - * - * @return void - */ - public function testNewParentNames(): void - { self::assertSame( - ['NAME' => '//'], - $this->surname_tradition->newParentNames('John /White/', 'U') + ["1 NAME //\n2 TYPE birth"], + $this->surname_tradition->newParentNames($individual, 'U') ); } /** - * Test new husband names + * Test new spouse names * * @covers \Fisharebest\Webtrees\SurnameTradition\PatrilinealSurnameTradition * * @return void */ - public function testNewHusbandNames(): void + public function testNewSpouseNames(): void { + $fact = $this->createStub(Fact::class); + $fact->expects(self::any())->method('value')->willReturn('Chris /White/'); + + $individual = $this->createStub(Individual::class); + $individual->expects(self::any())->method('facts')->willReturn(new Collection([$fact])); + self::assertSame( - ['NAME' => '//'], - $this->surname_tradition->newSpouseNames('Mary /Black/', 'M') + ["1 NAME //\n2 TYPE birth"], + $this->surname_tradition->newSpouseNames($individual, 'M') ); - } - /** - * Test new wife names - * - * @covers \Fisharebest\Webtrees\SurnameTradition\PatrilinealSurnameTradition - * - * @return void - */ - public function testNewWifeNames(): void - { self::assertSame( - ['NAME' => '//'], - $this->surname_tradition->newSpouseNames('John /White/', 'F') + ["1 NAME //\n2 TYPE birth"], + $this->surname_tradition->newSpouseNames($individual, 'F') ); - } - /** - * Test new spouse names - * - * @covers \Fisharebest\Webtrees\SurnameTradition\PatrilinealSurnameTradition - * - * @return void - */ - public function testNewSpouseNames(): void - { self::assertSame( - ['NAME' => '//'], - $this->surname_tradition->newSpouseNames('Chris /Green/', 'U') + ["1 NAME //\n2 TYPE birth"], + $this->surname_tradition->newSpouseNames($individual, 'U') ); } } diff --git a/tests/app/SurnameTradition/PolishSurnameTraditionTest.php b/tests/app/SurnameTradition/PolishSurnameTraditionTest.php index e219bdd2b8..f49b884836 100644 --- a/tests/app/SurnameTradition/PolishSurnameTraditionTest.php +++ b/tests/app/SurnameTradition/PolishSurnameTraditionTest.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 PolishSurnameTradition @@ -29,18 +32,6 @@ class PolishSurnameTraditionTest extends TestCase private SurnameTraditionInterface $surname_tradition; /** - * Prepare the environment for these tests - * - * @return void - */ - protected function setUp(): void - { - parent::setUp(); - - $this->surname_tradition = new PolishSurnameTradition(); - } - - /** * Test whether married surnames are used * * @covers \Fisharebest\Webtrees\SurnameTradition\PolishSurnameTradition @@ -76,12 +67,21 @@ class PolishSurnameTraditionTest extends TestCase */ public function testNewSonNames(): void { + $father_fact = $this->createStub(Fact::class); + $father_fact->expects(self::any())->method('value')->willReturn('John /White/'); + + $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('Mary /Black/'); + + $mother = $this->createStub(Individual::class); + $mother->expects(self::any())->method('facts')->willReturn(new Collection([$mother_fact])); + self::assertSame( - [ - 'NAME' => '/White/', - 'SURN' => 'White', - ], - $this->surname_tradition->newChildNames('John /White/', 'Mary /Black/', 'M') + ["1 NAME /White/\n2 TYPE birth\n2 SURN White"], + $this->surname_tradition->newChildNames($father, $mother, 'M') ); } @@ -95,12 +95,21 @@ class PolishSurnameTraditionTest extends TestCase */ public function testNewDaughterNames(): void { + $father_fact = $this->createStub(Fact::class); + $father_fact->expects(self::any())->method('value')->willReturn('John /White/'); + + $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('Mary /Black/'); + + $mother = $this->createStub(Individual::class); + $mother->expects(self::any())->method('facts')->willReturn(new Collection([$mother_fact])); + self::assertSame( - [ - 'NAME' => '/White/', - 'SURN' => 'White', - ], - $this->surname_tradition->newChildNames('John /White/', 'Mary /Black/', 'F') + ["1 NAME /White/\n2 TYPE birth\n2 SURN White"], + $this->surname_tradition->newChildNames($father, $mother, 'F') ); } @@ -114,33 +123,72 @@ class PolishSurnameTraditionTest extends TestCase */ public function testNewDaughterNamesInflected(): void { + $father_fact = $this->createStub(Fact::class); + $father_fact->expects(self::any())->method('value')->willReturn('John /Whitecki/'); + + $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('Mary /Black/'); + + $mother = $this->createStub(Individual::class); + $mother->expects(self::any())->method('facts')->willReturn(new Collection([$mother_fact])); + self::assertSame( - [ - 'NAME' => '/Whitecka/', - 'SURN' => 'Whitecki', - ], - $this->surname_tradition->newChildNames('John /Whitecki/', 'Mary /Black/', 'F') + ["1 NAME /Whitecka/\n2 TYPE birth\n2 SURN Whitecki"], + $this->surname_tradition->newChildNames($father, $mother, 'F') ); + + $father_fact = $this->createStub(Fact::class); + $father_fact->expects(self::any())->method('value')->willReturn('John /Whitedzki/'); + + $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('Mary /Black/'); + + $mother = $this->createStub(Individual::class); + $mother->expects(self::any())->method('facts')->willReturn(new Collection([$mother_fact])); + self::assertSame( - [ - 'NAME' => '/Whitedzka/', - 'SURN' => 'Whitedzki', - ], - $this->surname_tradition->newChildNames('John /Whitedzki/', 'Mary /Black/', 'F') + ["1 NAME /Whitedzka/\n2 TYPE birth\n2 SURN Whitedzki"], + $this->surname_tradition->newChildNames($father, $mother, 'F') ); + + $father_fact = $this->createStub(Fact::class); + $father_fact->expects(self::any())->method('value')->willReturn('John /Whiteski/'); + + $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('Mary /Black/'); + + $mother = $this->createStub(Individual::class); + $mother->expects(self::any())->method('facts')->willReturn(new Collection([$mother_fact])); + self::assertSame( - [ - 'NAME' => '/Whiteska/', - 'SURN' => 'Whiteski', - ], - $this->surname_tradition->newChildNames('John /Whiteski/', 'Mary /Black/', 'F') + ["1 NAME /Whiteska/\n2 TYPE birth\n2 SURN Whiteski"], + $this->surname_tradition->newChildNames($father, $mother, 'F') ); + + $father_fact = $this->createStub(Fact::class); + $father_fact->expects(self::any())->method('value')->willReturn('John /Whiteżki/'); + + $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('Mary /Black/'); + + $mother = $this->createStub(Individual::class); + $mother->expects(self::any())->method('facts')->willReturn(new Collection([$mother_fact])); + self::assertSame( - [ - 'NAME' => '/Whiteżka/', - 'SURN' => 'Whiteżki', - ], - $this->surname_tradition->newChildNames('John /Whiteżki/', 'Mary /Black/', 'F') + ["1 NAME /Whiteżka/\n2 TYPE birth\n2 SURN Whiteżki"], + $this->surname_tradition->newChildNames($father, $mother, 'F') ); } @@ -154,12 +202,21 @@ class PolishSurnameTraditionTest extends TestCase */ public function testNewChildNames(): void { + $father_fact = $this->createStub(Fact::class); + $father_fact->expects(self::any())->method('value')->willReturn('John /White/'); + + $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('Mary /Black/'); + + $mother = $this->createStub(Individual::class); + $mother->expects(self::any())->method('facts')->willReturn(new Collection([$mother_fact])); + self::assertSame( - [ - 'NAME' => '/White/', - 'SURN' => 'White', - ], - $this->surname_tradition->newChildNames('John /White/', 'Mary /Black/', 'U') + ["1 NAME /White/\n2 TYPE birth\n2 SURN White"], + $this->surname_tradition->newChildNames($father, $mother, 'U') ); } @@ -174,8 +231,8 @@ class PolishSurnameTraditionTest extends TestCase public function testNewChildNamesWithNoParentsNames(): void { self::assertSame( - ['NAME' => '//'], - $this->surname_tradition->newChildNames('', '', 'U') + ["1 NAME //\n2 TYPE birth"], + $this->surname_tradition->newChildNames(null, null, 'U') ); } @@ -189,12 +246,15 @@ class PolishSurnameTraditionTest extends TestCase */ public function testNewFatherNames(): void { + $fact = $this->createStub(Fact::class); + $fact->expects(self::any())->method('value')->willReturn('Chris /White/'); + + $individual = $this->createStub(Individual::class); + $individual->expects(self::any())->method('facts')->willReturn(new Collection([$fact])); + self::assertSame( - [ - 'NAME' => '/White/', - 'SURN' => 'White', - ], - $this->surname_tradition->newParentNames('John /White/', 'M') + ["1 NAME /White/\n2 TYPE birth\n2 SURN White"], + $this->surname_tradition->newParentNames($individual, 'M') ); } @@ -208,33 +268,48 @@ class PolishSurnameTraditionTest extends TestCase */ public function testNewFatherNamesInflected(): void { + $fact = $this->createStub(Fact::class); + $fact->expects(self::any())->method('value')->willReturn('Chris /Whitecka/'); + + $individual = $this->createStub(Individual::class); + $individual->expects(self::any())->method('facts')->willReturn(new Collection([$fact])); + self::assertSame( - [ - 'NAME' => '/Whitecki/', - 'SURN' => 'Whitecki', - ], - $this->surname_tradition->newParentNames('Mary /Whitecka/', 'M') + ["1 NAME /Whitecki/\n2 TYPE birth\n2 SURN Whitecki"], + $this->surname_tradition->newParentNames($individual, 'M') ); + + $fact = $this->createStub(Fact::class); + $fact->expects(self::any())->method('value')->willReturn('Chris /Whitedzka/'); + + $individual = $this->createStub(Individual::class); + $individual->expects(self::any())->method('facts')->willReturn(new Collection([$fact])); + self::assertSame( - [ - 'NAME' => '/Whitedzki/', - 'SURN' => 'Whitedzki', - ], - $this->surname_tradition->newParentNames('Mary /Whitedzka/', 'M') + ["1 NAME /Whitedzki/\n2 TYPE birth\n2 SURN Whitedzki"], + $this->surname_tradition->newParentNames($individual, 'M') ); + + $fact = $this->createStub(Fact::class); + $fact->expects(self::any())->method('value')->willReturn('Chris /Whiteska/'); + + $individual = $this->createStub(Individual::class); + $individual->expects(self::any())->method('facts')->willReturn(new Collection([$fact])); + self::assertSame( - [ - 'NAME' => '/Whiteski/', - 'SURN' => 'Whiteski', - ], - $this->surname_tradition->newParentNames('Mary /Whiteska/', 'M') + ["1 NAME /Whiteski/\n2 TYPE birth\n2 SURN Whiteski"], + $this->surname_tradition->newParentNames($individual, 'M') ); + + $fact = $this->createStub(Fact::class); + $fact->expects(self::any())->method('value')->willReturn('Chris /Whiteżka/'); + + $individual = $this->createStub(Individual::class); + $individual->expects(self::any())->method('facts')->willReturn(new Collection([$fact])); + self::assertSame( - [ - 'NAME' => '/Whiteżki/', - 'SURN' => 'Whiteżki', - ], - $this->surname_tradition->newParentNames('Mary /Whiteżka/', 'M') + ["1 NAME /Whiteżki/\n2 TYPE birth\n2 SURN Whiteżki"], + $this->surname_tradition->newParentNames($individual, 'M') ); } @@ -248,9 +323,15 @@ class PolishSurnameTraditionTest extends TestCase */ public function testNewMotherNames(): void { + $fact = $this->createStub(Fact::class); + $fact->expects(self::any())->method('value')->willReturn('Chris /White/'); + + $individual = $this->createStub(Individual::class); + $individual->expects(self::any())->method('facts')->willReturn(new Collection([$fact])); + self::assertSame( - ['NAME' => '//'], - $this->surname_tradition->newParentNames('John /White/', 'F') + ["1 NAME //\n2 TYPE birth"], + $this->surname_tradition->newParentNames($individual, 'F') ); } @@ -264,60 +345,59 @@ class PolishSurnameTraditionTest extends TestCase */ public function testNewParentNames(): void { + $fact = $this->createStub(Fact::class); + $fact->expects(self::any())->method('value')->willReturn('Chris /White/'); + + $individual = $this->createStub(Individual::class); + $individual->expects(self::any())->method('facts')->willReturn(new Collection([$fact])); + self::assertSame( - ['NAME' => '//'], - $this->surname_tradition->newParentNames('John /White/', 'U') + ["1 NAME //\n2 TYPE birth"], + $this->surname_tradition->newParentNames($individual, 'U') ); } /** - * Test new husband names + * Test new spouse names * * @covers \Fisharebest\Webtrees\SurnameTradition\PolishSurnameTradition * @covers \Fisharebest\Webtrees\SurnameTradition\PatrilinealSurnameTradition * * @return void */ - public function testNewHusbandNames(): void + public function testNewSpouseNames(): void { + $fact = $this->createStub(Fact::class); + $fact->expects(self::any())->method('value')->willReturn('Chris /White/'); + + $individual = $this->createStub(Individual::class); + $individual->expects(self::any())->method('facts')->willReturn(new Collection([$fact])); + self::assertSame( - ['NAME' => '//'], - $this->surname_tradition->newSpouseNames('Mary /Black/', 'M') + ["1 NAME //\n2 TYPE birth"], + $this->surname_tradition->newSpouseNames($individual, 'M') ); - } - /** - * Test new wife names - * - * @covers \Fisharebest\Webtrees\SurnameTradition\PolishSurnameTradition - * @covers \Fisharebest\Webtrees\SurnameTradition\PatrilinealSurnameTradition - * - * @return void - */ - public function testNewWifeNames(): void - { self::assertSame( - [ - 'NAME' => '//', - '_MARNM' => '/White/', - ], - $this->surname_tradition->newSpouseNames('John /White/', 'F') + ["1 NAME //\n2 TYPE birth", "1 NAME /White/\n2 TYPE married\n2 SURN White"], + $this->surname_tradition->newSpouseNames($individual, 'F') + ); + + self::assertSame( + ["1 NAME //\n2 TYPE birth"], + $this->surname_tradition->newSpouseNames($individual, 'U') ); } /** - * Test new spouse names - * - * @covers \Fisharebest\Webtrees\SurnameTradition\PolishSurnameTradition - * @covers \Fisharebest\Webtrees\SurnameTradition\PatrilinealSurnameTradition + * Prepare the environment for these tests * * @return void */ - public function testNewSpouseNames(): void + protected function setUp(): void { - self::assertSame( - ['NAME' => '//'], - $this->surname_tradition->newSpouseNames('Chris /Green/', 'U') - ); + parent::setUp(); + + $this->surname_tradition = new PolishSurnameTradition(); } } diff --git a/tests/app/SurnameTradition/PortugueseSurnameTraditionTest.php b/tests/app/SurnameTradition/PortugueseSurnameTraditionTest.php index 80d997a8c1..51d8d3752f 100644 --- a/tests/app/SurnameTradition/PortugueseSurnameTraditionTest.php +++ b/tests/app/SurnameTradition/PortugueseSurnameTraditionTest.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 PortugueseSurnameTradition @@ -65,56 +68,39 @@ class PortugueseSurnameTraditionTest extends TestCase } /** - * Test new son names + * Test new child names * * @covers \Fisharebest\Webtrees\SurnameTradition\PortugueseSurnameTradition * * @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('Maria /Ruiz/ /Lorca/'); + + $mother = $this->createStub(Individual::class); + $mother->expects(self::any())->method('facts')->willReturn(new Collection([$mother_fact])); + self::assertSame( - [ - 'NAME' => '/Iglesias/ /Lorca/', - 'SURN' => 'Iglesias,Lorca', - ], - $this->surname_tradition->newChildNames('Gabriel /Garcia/ /Iglesias/', 'Maria /Ruiz/ /Lorca/', 'M') + ["1 NAME /Iglesias/ /Lorca/\n2 TYPE birth\n2 SURN Iglesias,Lorca"], + $this->surname_tradition->newChildNames($father, $mother, 'M') ); - } - /** - * Test new daughter names - * - * @covers \Fisharebest\Webtrees\SurnameTradition\PortugueseSurnameTradition - * - * @return void - */ - public function testNewDaughterNames(): void - { self::assertSame( - [ - 'NAME' => '/Iglesias/ /Lorca/', - 'SURN' => 'Iglesias,Lorca', - ], - $this->surname_tradition->newChildNames('Gabriel /Garcia/ /Iglesias/', 'Maria /Ruiz/ /Lorca/', 'M') + ["1 NAME /Iglesias/ /Lorca/\n2 TYPE birth\n2 SURN Iglesias,Lorca"], + $this->surname_tradition->newChildNames($father, $mother, 'F') ); - } - /** - * Test new child names - * - * @covers \Fisharebest\Webtrees\SurnameTradition\PortugueseSurnameTradition - * - * @return void - */ - public function testNewChildNames(): void - { self::assertSame( - [ - 'NAME' => '/Iglesias/ /Lorca/', - 'SURN' => 'Iglesias,Lorca', - ], - $this->surname_tradition->newChildNames('Gabriel /Garcia/ /Iglesias/', 'Maria /Ruiz/ /Lorca/', 'M') + ["1 NAME /Iglesias/ /Lorca/\n2 TYPE birth\n2 SURN Iglesias,Lorca"], + $this->surname_tradition->newChildNames($father, $mother, 'U') ); } @@ -128,11 +114,8 @@ class PortugueseSurnameTraditionTest 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') ); } @@ -145,55 +128,21 @@ class PortugueseSurnameTraditionTest extends TestCase */ public function testNewChildNamesCompunds(): void { - self::assertSame( - [ - 'NAME' => '/Iglesias/ /Lorca/', - 'SURN' => 'Iglesias,Lorca', - ], - $this->surname_tradition->newChildNames('Gabriel /Garcia Iglesias/', 'Maria /Ruiz Lorca/', 'M') - ); - self::assertSame( - [ - 'NAME' => '/Iglesias/ /Lorca/', - 'SURN' => 'Iglesias,Lorca', - ], - $this->surname_tradition->newChildNames('Gabriel /Garcia y Iglesias/', 'Maria /Ruiz y Lorca/', 'M') - ); - } + $father_fact = $this->createStub(Fact::class); + $father_fact->expects(self::any())->method('value')->willReturn('Gabriel /Garcia/ y /Iglesias/'); - /** - * Test new father names - * - * @covers \Fisharebest\Webtrees\SurnameTradition\PortugueseSurnameTradition - * - * @return void - */ - public function testNewFatherNames(): void - { - self::assertSame( - [ - 'NAME' => '// /Garcia/', - 'SURN' => 'Garcia', - ], - $this->surname_tradition->newParentNames('Gabriel /Garcia/ /Iglesias/', 'M') - ); - } + $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('Maria /Ruiz/ y /Lorca/'); + + $mother = $this->createStub(Individual::class); + $mother->expects(self::any())->method('facts')->willReturn(new Collection([$mother_fact])); - /** - * Test new mother names - * - * @covers \Fisharebest\Webtrees\SurnameTradition\PortugueseSurnameTradition - * - * @return void - */ - public function testNewMotherNames(): void - { self::assertSame( - [ - 'NAME' => '// /Iglesias/', - 'SURN' => 'Iglesias', - ], - $this->surname_tradition->newParentNames('Gabriel /Garcia/ /Iglesias/', 'F') + ["1 NAME /Iglesias/ /Lorca/\n2 TYPE birth\n2 SURN Iglesias,Lorca"], + $this->surname_tradition->newChildNames($father, $mother, 'M') ); } @@ -206,39 +155,24 @@ class PortugueseSurnameTraditionTest extends TestCase */ 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' => '// //'], - $this->surname_tradition->newParentNames('Gabriel /Garcia/ /Iglesias/', 'U') + ["1 NAME // /Garcia/\n2 TYPE birth\n2 SURN Garcia"], + $this->surname_tradition->newParentNames($individual, 'M') ); - } - - /** - * Test new husband names - * - * @covers \Fisharebest\Webtrees\SurnameTradition\PortugueseSurnameTradition - * - * @return void - */ - public function testNewHusbandNames(): void - { self::assertSame( - ['NAME' => '// //'], - $this->surname_tradition->newSpouseNames('Maria /Ruiz/ /Lorca/', 'M') + ["1 NAME // /Iglesias/\n2 TYPE birth\n2 SURN Iglesias"], + $this->surname_tradition->newParentNames($individual, 'F') ); - } - /** - * Test new wife names - * - * @covers \Fisharebest\Webtrees\SurnameTradition\PortugueseSurnameTradition - * - * @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->newParentNames($individual, 'U') ); } @@ -251,9 +185,25 @@ class PortugueseSurnameTraditionTest extends TestCase */ 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( + ["1 NAME // //\n2 TYPE birth"], + $this->surname_tradition->newSpouseNames($individual, 'M') + ); + + self::assertSame( + ["1 NAME // //\n2 TYPE birth"], + $this->surname_tradition->newSpouseNames($individual, 'F') + ); + self::assertSame( - ['NAME' => '// //'], - $this->surname_tradition->newSpouseNames('Gabriel /Garcia/ /Iglesias/', 'U') + ["1 NAME // //\n2 TYPE birth"], + $this->surname_tradition->newSpouseNames($individual, 'U') ); } } 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(); } } |
