diff options
Diffstat (limited to 'tests/app/SurnameTradition/MatrilinealSurnameTraditionTest.php')
| -rw-r--r-- | tests/app/SurnameTradition/MatrilinealSurnameTraditionTest.php | 172 |
1 files changed, 68 insertions, 104 deletions
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') ); } } |
