-
-
Notifications
You must be signed in to change notification settings - Fork 40
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Use the event type as key of the event to not lose it and being able …
…to reconstruct it again
- Loading branch information
Showing
9 changed files
with
131 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
{"version":1,"defects":{"GedcomTest\\ParserTest::testHead":7,"GedcomTest\\FamParserTest::testFam":7,"GedcomTest\\FamParserTest::testSingleFamilyEvent":7,"GedcomTest\\FamParserTest::testFamilyEventType":7,"GedcomTest\\FamParserTest::testFamilyEventWithNoTypeIsParsed":8,"GedcomTest\\FamParserTest::testFamilyEventWithTypeIsParsed":7,"GedcomTest\\FamParserTest::test":5,"GedcomTest\\FamWriterTest::test":7,"GedcomTest\\FamWriterTest::testFamilyEventWithNoTypeIsConverted":7,"GedcomTest\\FamWriterTest::testWriteFamilyEventWithoutType":7,"GedcomTest\\FamWriterTest::testFamilyEventIsConvertedToTheOriginal":8},"times":{"GedcomTest\\ParserTest::testNoErrors":0,"GedcomTest\\ParserTest::testRecordCounts":0,"GedcomTest\\ParserTest::testHead":0.002,"GedcomTest\\ParserTest::testSubn":0,"GedcomTest\\ParserTest::testSubm":0,"GedcomTest\\ParserTest::testSour":0,"GedcomTest\\ParserTest::testNote":0,"GedcomTest\\ParserTest::testNormalizeIdentifier":0,"GedcomTest\\FamParserTest::testFam":0.001,"GedcomTest\\FamParserTest::testSingleFamilyEvent":0.004,"GedcomTest\\FamParserTest::testFamilyEventType":0.001,"GedcomTest\\FamParserTest::testFamilyEventWithNoTypeIsParsed":0.001,"GedcomTest\\FamParserTest::testFamilyEventWithTypeIsParsed":0,"GedcomTest\\FamParserTest::test":0.002,"GedcomTest\\FamWriterTest::testFamilyEventWithNoTypeIsConverted":0.001,"GedcomTest\\FamWriterTest::test":0.001,"GedcomTest\\FamWriterTest::test1":0.001,"GedcomTest\\FamWriterTest::testWriteFamilyEventWithType":0.001,"GedcomTest\\FamWriterTest::testWriteFamilyEventWithoutType":0,"GedcomTest\\FamWriterTest::testFamilyEventIsConvertedToTheOriginal":0.002,"GedcomTest\\FamWriterTest::testFamilyEventIsConvertedToTheOriginal#0":0.004,"GedcomTest\\FamWriterTest::testFamilyEventIsConvertedToTheOriginal#1":0}} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
<?php | ||
|
||
namespace GedcomTest; | ||
|
||
use Gedcom\Parser; | ||
|
||
/** | ||
* Class FamParserTest. | ||
*/ | ||
class FamParserTest extends \PHPUnit\Framework\TestCase | ||
{ | ||
/** | ||
* @var \Gedcom\Parser | ||
*/ | ||
protected $parser = null; | ||
|
||
/** | ||
* @var \Gedcom\Gedcom | ||
*/ | ||
protected $gedcom = null; | ||
|
||
public function setUp(): void | ||
{ | ||
$this->parser = new Parser(); | ||
} | ||
|
||
/** | ||
* Test a family event type with no type is parsed. | ||
*/ | ||
public function testFamilyEventWithNoTypeIsParsed() | ||
{ | ||
$this->gedcom = $this->parser->parse(\TEST_DIR . '/stresstestfiles/family/family_event_no_type.ged'); | ||
|
||
$fam = $this->gedcom->getFam('F1'); | ||
|
||
$events = $fam['F1']->getAllEven(); | ||
$this->assertCount(1, $events); | ||
|
||
$eventType = array_keys($events)[0]; | ||
$event = $events[$eventType]; | ||
|
||
$this->assertEquals('MARR', $eventType); | ||
$this->assertEquals('MARR', $event->getType()); | ||
$this->assertEquals('2007-02-11', $event->getDate()); | ||
} | ||
|
||
/** | ||
* Test a family event type with a type is parsed. | ||
*/ | ||
public function testFamilyEventWithTypeIsParsed() | ||
{ | ||
$this->gedcom = $this->parser->parse(\TEST_DIR . '/stresstestfiles/family/family_event_with_type.ged'); | ||
|
||
$fam = $this->gedcom->getFam('F1'); | ||
|
||
$events = $fam['F1']->getAllEven(); | ||
$this->assertCount(1, $events); | ||
|
||
$eventType = array_keys($events)[0]; | ||
$event = $events[$eventType]; | ||
|
||
$this->assertEquals('MARR', $eventType); | ||
$this->assertEquals('Civil marriage', $event->getType()); | ||
$this->assertEquals('2007-02-11', $event->getDate()); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
<?php | ||
|
||
namespace GedcomTest; | ||
|
||
use Gedcom\Parser; | ||
use Gedcom\Writer; | ||
use PHPUnit\Framework\Attributes\DataProvider; | ||
use PHPUnit\Framework\TestCase; | ||
|
||
/** | ||
* Class FamWriterTest. | ||
*/ | ||
class FamWriterTest extends TestCase | ||
{ | ||
/** | ||
* @var \Gedcom\Parser | ||
*/ | ||
protected $parser = null; | ||
|
||
/** | ||
* @var \Gedcom\Gedcom | ||
*/ | ||
protected $gedcom = null; | ||
|
||
public function setUp(): void | ||
{ | ||
$this->parser = new Parser(); | ||
} | ||
|
||
#[DataProvider('families')] | ||
public function testFamilyEventIsConvertedToTheOriginal($gedcomFile) | ||
{ | ||
$this->gedcom = $this->parser->parse($gedcomFile); | ||
|
||
$originalGedcom = file_get_contents($gedcomFile); | ||
$convertedGedcom = Writer::convert($this->gedcom); | ||
|
||
$this->assertEquals($originalGedcom, $convertedGedcom); | ||
} | ||
|
||
public static function families() | ||
{ | ||
return [ | ||
[\TEST_DIR . '/stresstestfiles/family/family_event_no_type.ged'], | ||
[\TEST_DIR . '/stresstestfiles/family/family_event_with_type.ged'], | ||
]; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
0 @F1@ FAM | ||
1 MARR | ||
0 TRLR |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
0 @F1@ FAM | ||
1 MARR | ||
2 TYPE Civil marriage | ||
0 TRLR |