|
| 1 | +<?php |
| 2 | + |
| 3 | +namespace org\nameapi\client\services\matcher\personmatcher; |
| 4 | + |
| 5 | +require_once(__DIR__.'/../../BaseServiceTest.php'); |
| 6 | + |
| 7 | +use org\nameapi\client\services\BaseServiceTest; |
| 8 | +use org\nameapi\ontology\input\entities\person\NaturalInputPerson; |
| 9 | +use org\nameapi\ontology\input\entities\person\name\InputPersonName; |
| 10 | +use org\nameapi\ontology\input\entities\person\age\AgeInfoFactory; |
| 11 | + |
| 12 | +class PersonMatcherServiceTest extends BaseServiceTest { |
| 13 | + |
| 14 | + public function testMatch_matching() { |
| 15 | + $personMatcher = $this->makeServiceFactory()->matcherServices()->personMatcher(); |
| 16 | + $inputPerson1 = NaturalInputPerson::builder() |
| 17 | + ->name(InputPersonName::westernBuilder() |
| 18 | + ->fullname( "John F. Kennedy" ) |
| 19 | + ->build()) |
| 20 | + ->build(); |
| 21 | + $inputPerson2 = NaturalInputPerson::builder() |
| 22 | + ->name(InputPersonName::westernBuilder() |
| 23 | + ->fullname( "Jack Kennedy" ) |
| 24 | + ->build()) |
| 25 | + ->build(); |
| 26 | + $personMatchResult = $personMatcher->match($inputPerson1, $inputPerson2); |
| 27 | + $this->assertEquals('MATCHING', $personMatchResult->getPersonMatchType()->toString()); |
| 28 | + } |
| 29 | + |
| 30 | + public function testMatch_similar() { |
| 31 | + $personMatcher = $this->makeServiceFactory()->matcherServices()->personMatcher(); |
| 32 | + $inputPerson1 = NaturalInputPerson::builder() |
| 33 | + ->name(InputPersonName::westernBuilder() |
| 34 | + ->fullname( "John F. Kennedy" ) |
| 35 | + ->build()) |
| 36 | + ->ageInfo( AgeInfoFactory::forDate(1917,5,29) ) |
| 37 | + ->build(); |
| 38 | + $inputPerson2 = NaturalInputPerson::builder() |
| 39 | + ->name(InputPersonName::westernBuilder() |
| 40 | + ->fullname( "Jack Kennedy" ) |
| 41 | + ->build()) |
| 42 | + ->ageInfo( AgeInfoFactory::forDate(1990,12,31) ) |
| 43 | + ->build(); |
| 44 | + $personMatchResult = $personMatcher->match($inputPerson1, $inputPerson2); |
| 45 | + $this->assertEquals('SIMILAR', $personMatchResult->getPersonMatchType()->toString()); |
| 46 | + } |
| 47 | + |
| 48 | + public function testMatch_different() { |
| 49 | + $personMatcher = $this->makeServiceFactory()->matcherServices()->personMatcher(); |
| 50 | + $inputPerson1 = NaturalInputPerson::builder() |
| 51 | + ->name(InputPersonName::westernBuilder() |
| 52 | + ->fullname( "John F. Kennedy" ) |
| 53 | + ->build()) |
| 54 | + ->ageInfo( AgeInfoFactory::forDate(1917,5,29) ) |
| 55 | + ->build(); |
| 56 | + $inputPerson2 = NaturalInputPerson::builder() |
| 57 | + ->name(InputPersonName::westernBuilder() |
| 58 | + ->fullname( "John Doe" ) |
| 59 | + ->build()) |
| 60 | + ->ageInfo( AgeInfoFactory::forDate(1990,12,31) ) |
| 61 | + ->build(); |
| 62 | + $personMatchResult = $personMatcher->match($inputPerson1, $inputPerson2); |
| 63 | + $this->assertEquals('DIFFERENT', $personMatchResult->getPersonMatchType()->toString()); |
| 64 | + } |
| 65 | + |
| 66 | +} |
0 commit comments