Skip to content

Commit

Permalink
Person test
Browse files Browse the repository at this point in the history
  • Loading branch information
justincy committed Sep 20, 2016
1 parent 660813c commit fe4ef23
Show file tree
Hide file tree
Showing 5 changed files with 215 additions and 4 deletions.
7 changes: 6 additions & 1 deletion tests/ApiTestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,13 @@ public function tearDown()
}
}
}

protected function loadJson($filename)
{
return json_decode(file_get_contents($this->filesDir . $filename), true);
}

protected function createPerson($gender = null)
protected function createPerson($gender = null)
{
$person = PersonBuilder::buildPerson($gender);
$state = $this->collectionState()->addPerson($person);
Expand Down
187 changes: 187 additions & 0 deletions tests/files/person.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,187 @@
{
"id" : "PPPJ-MYZ",
"links" : {
"ancestry" : {
"href" : "https://familysearch.org/platform/tree/ancestry?person=PPPJ-MYZ"
},
"spouses" : {
"href" : "https://familysearch.org/platform/tree/persons/PPPJ-MYZ/spouses"
},
"parents" : {
"href" : "https://familysearch.org/platform/tree/persons/PPPJ-MYZ/parents"
},
"person" : {
"href" : "https://familysearch.org/platform/tree/persons/PPPJ-MYZ"
},
"descendancy" : {
"href" : "https://familysearch.org/platform/tree/descendancy?person=PPPJ-MYZ"
},
"person-with-relationships" : {
"href" : "https://familysearch.org/platform/tree/persons-with-relationships?person=PPPJ-MYZ"
},
"merge" : {
"template" : "https://familysearch.org/platform/tree/persons/{pid}/merges/{dpid}{?filter,access_token}",
"type" : "application/json,application/x-fs-v1+json,application/x-fs-v1+xml,application/xml,text/html",
"accept" : "application/x-fs-v1+json,application/x-fs-v1+xml",
"allow" : "GET,OPTIONS,POST",
"title" : "Person Merge"
},
"change-history" : {
"href" : "https://familysearch.org/platform/tree/persons/PPPJ-MYZ/changes"
},
"evidence-references" : {
"href" : "https://familysearch.org/platform/tree/persons/PPPJ-MYZ/memory-references"
},
"children" : {
"href" : "https://familysearch.org/platform/tree/persons/PPPJ-MYZ/children"
},
"child-relationships" : {
"href" : "https://familysearch.org/platform/tree/persons/PPPJ-MYZ/child-relationships"
},
"collection" : {
"href" : "https://familysearch.org/platform/collections/tree"
},
"ordinance-reservations" : {
"href" : "https://familysearch.org/platform/tree/persons/PPPJ-MYZ/reservations"
},
"artifacts" : {
"href" : "https://familysearch.org/platform/tree/persons/PPPJ-MYZ/memories"
},
"source-references" : {
"href" : "https://familysearch.org/platform/tree/persons/PPPJ-MYZ/source-references"
},
"matches" : {
"href" : "https://familysearch.org/platform/tree/persons/PPPJ-MYZ/matches"
},
"ordinances" : {
"href" : "https://familysearch.org/platform/tree/persons/PPPJ-MYZ/ordinances"
},
"portraits" : {
"href" : "https://familysearch.org/platform/tree/persons/PPPJ-MYZ/portraits"
},
"discussion-references" : {
"href" : "https://familysearch.org/platform/tree/persons/PPPJ-MYZ/discussion-references"
},
"spouse-relationships" : {
"href" : "https://familysearch.org/platform/tree/persons/PPPJ-MYZ/spouse-relationships"
},
"parent-relationships" : {
"href" : "https://familysearch.org/platform/tree/persons/PPPJ-MYZ/parent-relationships"
},
"portrait" : {
"href" : "https://familysearch.org/platform/tree/persons/PPPJ-MYZ/portrait"
},
"non-matches" : {
"href" : "https://familysearch.org/platform/tree/persons/PPPJ-MYZ/not-a-match"
},
"notes" : {
"href" : "https://familysearch.org/platform/tree/persons/PPPJ-MYZ/notes"
},
"source-descriptions" : {
"href" : "https://familysearch.org/platform/tree/persons/PPPJ-MYZ/sources"
}
},
"attribution" : {
"changeMessage" : "wikipedia knows"
},
"identifiers" : {
"http://gedcomx.org/Persistent" : [ "https://familysearch.org/ark:/61903/4:1:PPPJ-MYZ" ]
},
"living" : true,
"gender" : {
"type" : "http://gedcomx.org/Male"
},
"names" : [ {
"id" : "name-id",
"links" : {
"conclusion" : {
"href" : "https://familysearch.org/platform/tree/persons/PPPJ-MYZ/conclusions/name-id"
}
},
"attribution" : {
"contributor" : {
"resource" : "urn:name-attribution",
"resourceId" : "KNCV-RMZ"
}
},
"type" : "http://gedcomx.org/BirthName",
"nameForms" : [ {
"fullText" : "Alex Aleksandrova",
"parts" : [ {
"type" : "http://gedcomx.org/Given",
"value" : "Alex"
}, {
"type" : "http://gedcomx.org/Surname",
"value" : "Aleksandrova"
} ]
}, {
"fullText" : "Анастасия Александрова",
"parts" : [ {
"type" : "http://gedcomx.org/Given",
"value" : "Анастасия"
}, {
"type" : "http://gedcomx.org/Surname",
"value" : "Александрова"
} ]
} ],
"preferred" : true
} ],
"facts" : [ {
"id" : "born",
"links" : {
"conclusion" : {
"href" : "https://familysearch.org/platform/tree/persons/PPPJ-MYZ/conclusions/born"
}
},
"attribution" : {
"contributor" : {
"resource" : "urn:fact-attribution",
"resourceId" : "RMQW-LPK"
}
},
"type" : "http://gedcomx.org/Birth",
"date" : {
"original" : "3 Apr 1836",
"formal" : "+1836"
},
"place" : {
"original" : "Moscow, Russia",
"normalized" : [ {
"lang" : "en",
"value" : "Moscow, Moskva, Russia"
} ]
}
}, {
"id" : "res",
"links" : {
"conclusion" : {
"href" : "https://familysearch.org/platform/tree/persons/PPPJ-MYZ/conclusions/res"
}
},
"attribution" : {
"contributor" : {
"resource" : "https://familysearch.org/platform/users/agents/JNYR-KJP",
"resourceId" : "JNYR-KJP"
}
},
"type" : "http://gedcomx.org/Residence",
"date" : {
"original" : "13 Apr 1836",
"formal" : "+1836-04-13"
},
"place" : {
"original" : "Moscow, Russia",
"description" : "#1276974106",
"normalized" : [ {
"value" : "Moskva, Moscow, Russia"
} ]
}
} ],
"display" : {
"name" : "Alex Aleksandrova",
"gender" : "Male",
"lifespan" : "3 Apr 1836 - Dead",
"birthDate" : "3 Apr 1836",
"birthPlace" : "Moscow, Russia"
}
}
2 changes: 1 addition & 1 deletion tests/unit/GedcomxFileTests.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

namespace Gedcomx\Functional;
namespace Gedcomx\Unit;

use Gedcomx\Extensions\FamilySearch\FamilySearchPlatform;
use Gedcomx\Extensions\FamilySearch\Platform\Tree\ChildAndParentsRelationship;
Expand Down
19 changes: 19 additions & 0 deletions tests/unit/PersonTests.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<?php

namespace Gedcomx\Tests\Unit;

use Gedcomx\Tests\ApiTestCase;
use Gedcomx\Conclusion\Person;

class PersonTests extends ApiTestCase
{

public function testPerson()
{
$person = new Person($this->loadJson('person.json'));
$this->assertEquals($person->getId(), 'PPPJ-MYZ');
$this->assertEquals(count($person->getFacts()), 2);
$this->assertEquals(count($person->getNames()), 1);
}

}
4 changes: 2 additions & 2 deletions tests/unit/XMLTests.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

namespace Gedcomx\Tests\Functional;
namespace Gedcomx\Tests\Unit;

use Gedcomx\Gedcomx;
use Gedcomx\Tests\ApiTestCase;
Expand All @@ -11,7 +11,7 @@ class XMLTests extends ApiTestCase
public function testDeserializeXML()
{
$xmlReader = new \XMLReader();
$xmlReader->XML(file_get_contents($this->testRootDir.'/files/record.xml'));
$xmlReader->XML(file_get_contents($this->filesDir . 'record.xml'));
$gedcomX = new Gedcomx($xmlReader);
$extenstions = $gedcomX->getPersons()[0]->getSources()[0]->getExtensionElements();
$this->assertEquals(3, count($extenstions));
Expand Down

0 comments on commit fe4ef23

Please sign in to comment.