summaryrefslogtreecommitdiff
path: root/tests/app/SurnameTradition/PatrilinealSurnameTraditionTest.php
diff options
context:
space:
mode:
Diffstat (limited to 'tests/app/SurnameTradition/PatrilinealSurnameTraditionTest.php')
-rw-r--r--tests/app/SurnameTradition/PatrilinealSurnameTraditionTest.php171
1 files changed, 67 insertions, 104 deletions
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')
);
}
}