Skip to content

Commit

Permalink
add xml deserialization test
Browse files Browse the repository at this point in the history
  • Loading branch information
justincy committed Sep 13, 2016
1 parent db2340e commit 53b5900
Show file tree
Hide file tree
Showing 4 changed files with 163 additions and 2 deletions.
4 changes: 2 additions & 2 deletions tests/Functional/GedcomxFileTests.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ class GedcomxFileTests extends ApiTestCase

public function testReadGedcomxFile()
{
$gedcomx = new GedcomxFile($this->testRootDir.'sample.gedx');
$gedcomx = new GedcomxFile($this->testRootDir.'/files/sample.gedx');

$this->assertEquals(
'FamilySearch Platform API 0.1',
Expand Down Expand Up @@ -71,7 +71,7 @@ public function testXMLDeserialization()
{
$resources = array();

$gedcomx = new GedcomxFile($this->testRootDir.'sample.gedx');
$gedcomx = new GedcomxFile($this->testRootDir.'/files/sample.gedx');
$entries = $gedcomx->getEntries();

foreach($entries as $entry){
Expand Down
20 changes: 20 additions & 0 deletions tests/Functional/XMLTests.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<?php

namespace Gedcomx\Tests\Functional;

use Gedcomx\Gedcomx;
use Gedcomx\Tests\ApiTestCase;

class XMLTests extends ApiTestCase
{

public function testDeserializeXML()
{
$xmlReader = new \XMLReader();
$xmlReader->XML(file_get_contents($this->testRootDir.'/files/record.xml'));
$gedcomX = new Gedcomx($xmlReader);
$extenstions = $gedcomX->getPersons()[0]->getSources()[0]->getExtensionElements();
$this->assertEquals(3, count($extenstions));
}

}
141 changes: 141 additions & 0 deletions tests/files/record.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,141 @@
<record xmlns="http://gedcomx.org/v1/" description="#SD-L2KF-NLB" id="http://familysearch.org/platform/tree/persons-with-relationships?person=L2KF-NLB">
<person sortKey="0000000000" id="L2KF-NLB">
<source description="http://familysearch.org/platform/sources/descriptions/9XC2-MW3" id="24ee625a-1465-48dd-887d-e11a662bb8f7">
<fs:tag xmlns:atom="http://www.w3.org/2005/Atom" xmlns:fs="http://familysearch.org/v1/" resource="http://gedcomx.org/Gender"/>
<fs:tag xmlns:atom="http://www.w3.org/2005/Atom" xmlns:fs="http://familysearch.org/v1/" resource="http://gedcomx.org/Name"/>
<fs:tag xmlns:atom="http://www.w3.org/2005/Atom" xmlns:fs="http://familysearch.org/v1/" resource="http://gedcomx.org/Birth"/>
<attribution>
<contributor resource="http://familysearch.org/platform/users/agents/MMXX-M7Q" resourceId="MMXX-M7Q"/>
<modified>2016-03-12T03:23:01.569Z</modified>
<changeMessage>same</changeMessage>
</attribution>
</source>
<identifier type="http://gedcomx.org/Persistent">https://familysearch.org/ark:/61903/4:1:L2KF-NLB</identifier>
<living>false</living>
<gender type="http://gedcomx.org/Female" id="4d6d2211-2c19-4c86-8954-8c2061de445b">
<link rel="conclusion" href="http://familysearch.org/platform/tree/persons/L2KF-NLB/conclusions/4d6d2211-2c19-4c86-8954-8c2061de445b"/>
<attribution>
<contributor resource="http://familysearch.org/platform/users/agents/MMXX-M7Q" resourceId="MMXX-M7Q"/>
<modified>2016-03-12T03:22:44.419Z</modified>
</attribution>
</gender>
<name type="http://gedcomx.org/BirthName" id="ddfa08c7-905a-4cbf-b994-9d4514d2af50">
<link rel="conclusion" href="http://familysearch.org/platform/tree/persons/L2KF-NLB/conclusions/ddfa08c7-905a-4cbf-b994-9d4514d2af50"/>
<attribution>
<contributor resource="http://familysearch.org/platform/users/agents/MM7Y-G9J" resourceId="MM7Y-G9J"/>
<modified>2016-05-18T23:28:33.853Z</modified>
<changeMessage>Middle name used in Ancestry Family Tree</changeMessage>
</attribution>
<preferred>true</preferred>
<nameForm>
<fullText>Dora Iucho Morrell</fullText>
<part type="http://gedcomx.org/Given" value="Dora Iucho"/>
<part type="http://gedcomx.org/Surname" value="Morrell"/>
</nameForm>
</name>
<fact type="http://gedcomx.org/Birth" id="ebe0d4fe-20f8-4dad-b4b8-c69c03d0f100">
<link rel="conclusion" href="http://familysearch.org/platform/tree/persons/L2KF-NLB/conclusions/ebe0d4fe-20f8-4dad-b4b8-c69c03d0f100"/>
<attribution>
<contributor resource="http://familysearch.org/platform/users/agents/MM7Y-G9J" resourceId="MM7Y-G9J"/>
<modified>2016-05-18T23:29:58.013Z</modified>
<changeMessage>Age in 1860 New York City census</changeMessage>
</attribution>
<date>
<original>1856</original>
<formal>+1856</formal>
<normalized xml:lang="en-US">1856</normalized>
<normalized>1856</normalized>
</date>
<place description="#1024916608">
<original>New York, United States</original>
<normalized xml:lang="en-US">New York, United States</normalized>
<normalized xml:lang="und">New York, United States</normalized>
</place>
</fact>
<fact type="http://gedcomx.org/Death" id="f1e514fe-d22c-45c0-ae4b-c14cb21b15a0">
<link rel="conclusion" href="http://familysearch.org/platform/tree/persons/L2KF-NLB/conclusions/f1e514fe-d22c-45c0-ae4b-c14cb21b15a0"/>
<attribution>
<contributor resource="http://familysearch.org/platform/users/agents/MM7Y-G9J" resourceId="MM7Y-G9J"/>
<modified>2016-05-20T01:56:16.996Z</modified>
<changeMessage>Ancestry Family Tree; New York, New York City Municipal Deaths</changeMessage>
</attribution>
<date>
<original>27 December 1899</original>
<formal>+1899-12-27</formal>
<normalized xml:lang="en-US">27 December 1899</normalized>
<normalized>27 December 1899</normalized>
</date>
<place description="#1375628896">
<original>Manhattan, New York County, New York, United States</original>
<normalized xml:lang="en-US">Manhattan, New York County, New York, United States</normalized>
<normalized xml:lang="und">Manhattan, New York County, New York, United States</normalized>
</place>
</fact>
<fact type="http://gedcomx.org/Residence" id="272688ba-9db5-4a83-94df-1744d94ed9fd">
<link rel="conclusion" href="http://familysearch.org/platform/tree/persons/L2KF-NLB/conclusions/272688ba-9db5-4a83-94df-1744d94ed9fd"/>
<attribution>
<contributor resource="http://familysearch.org/platform/users/agents/MMXX-M7Q" resourceId="MMXX-M7Q"/>
<modified>2016-03-12T03:23:05.419Z</modified>
<changeMessage>same</changeMessage>
</attribution>
<date>
<original>1880</original>
<formal>+1880</formal>
<normalized xml:lang="en-US">1880</normalized>
<normalized>1880</normalized>
</date>
<place description="#1879384345">
<original>New York, New York, New York, United States</original>
<normalized xml:lang="en-US">New York City, New York County, New York, United States</normalized>
<normalized xml:lang="und">New York, New York, New York, United States</normalized>
</place>
</fact>
<display>
<ascendancyNumber>1</ascendancyNumber>
<birthDate>1856</birthDate>
<birthPlace>New York, United States</birthPlace>
<deathDate>27 December 1899</deathDate>
<deathPlace>Manhattan, New York County, New York, United States</deathPlace>
<descendancyNumber>1</descendancyNumber>
<familyAsChild>
<parent1 resource="https://familysearch.org/ark:/61903/4:1:KCQM-418" resourceId="KCQM-418"/>
<parent2 resource="https://familysearch.org/ark:/61903/4:1:KCJV-Z4S" resourceId="KCJV-Z4S"/>
<child resource="#L2KF-NLB" resourceId="L2KF-NLB"/>
</familyAsChild>
<gender>Female</gender>
<lifespan>1856-1899</lifespan>
<name>Dora Iucho Morrell</name>
</display>
</person>
<relationship type="http://gedcomx.org/ParentChild" id="FMT5B-VYX">
<identifier type="http://familysearch.org/v1/ChildAndParentsRelationship">http://familysearch.org/platform/tree/child-and-parents-relationships/MT5B-VYX</identifier>
<person1 resource="https://familysearch.org/ark:/61903/4:1:KCQM-418" resourceId="KCQM-418"/>
<person2 resource="#L2KF-NLB" resourceId="L2KF-NLB"/>
</relationship>
<relationship type="http://gedcomx.org/ParentChild" id="MMT5B-VYX">
<identifier type="http://familysearch.org/v1/ChildAndParentsRelationship">http://familysearch.org/platform/tree/child-and-parents-relationships/MT5B-VYX</identifier>
<person1 resource="https://familysearch.org/ark:/61903/4:1:KCJV-Z4S" resourceId="KCJV-Z4S"/>
<person2 resource="#L2KF-NLB" resourceId="L2KF-NLB"/>
</relationship>
<sourceDescription about="#L2KF-NLB" resourceType="http://gedcomx.org/Person" version="136870634522800000" id="SD-L2KF-NLB">
<citation xml:lang="en">
<value>"Family Tree," database, &lt;i&gt;FamilySearch&lt;/i&gt; (http://familysearch.org : modified 06 July 2016, 02:04), entry for Dora Iucho Morrell(PID https://familysearch.org/ark:/61903/4:1:L2KF-NLB); contributed by various users.</value>
</citation>
<componentOf description="http://familysearch.org/platform/collections/tree"/>
<title>Dora Iucho Morrell</title>
<identifier type="http://gedcomx.org/Persistent">https://familysearch.org/ark:/61903/4:1:L2KF-NLB</identifier>
<modified>2016-07-06T02:04:12Z</modified>
</sourceDescription>
<place id="1024916608">
<name xml:lang="en-US">New York, United States</name>
<name xml:lang="und">New York, United States</name>
</place>
<place id="1375628896">
<name xml:lang="en-US">Manhattan, New York County, New York, United States</name>
<name xml:lang="und">Manhattan, New York County, New York, United States</name>
</place>
<place id="1879384345">
<name xml:lang="en-US">New York City, New York County, New York, United States</name>
<name xml:lang="und">New York, New York, New York, United States</name>
</place>
</record>
File renamed without changes.

0 comments on commit 53b5900

Please sign in to comment.