예제 #1
0
 /**
  * @return Context
  */
 protected function makeContext()
 {
     if (!$this->apiKey) {
         die("Put your api key in the \$apiKey variable to run these functional tests!");
     }
     return Context::builder()->apiKey($this->apiKey)->priority(Priority::REALTIME())->textCase(TextCase::TITLE_CASE())->build();
 }
 public function test_parseTwoPeople()
 {
     //setup code:
     $context = Context::builder()->priority(Priority::REALTIME())->build();
     $myApiKey = 'test';
     //grab one from nameapi.org
     $serviceFactory = new ServiceFactory($myApiKey, $context, Host::http('rc50-api.nameapi.org'), '5.0');
     $personNameParser = $serviceFactory->parserServices()->personNameParser();
     //the call:
     $inputPerson = NaturalInputPerson::builder()->name(InputPersonName::westernBuilder()->fullname("Peter und Daniela Meyer")->build())->build();
     $parseResult = $personNameParser->parse($inputPerson);
     //the assertions:
     $bestMatch = $parseResult->getBestMatch();
     $this->assertEquals('MULTIPLE', (string) $bestMatch->getParsedPerson()->getPersonType());
     $people = $bestMatch->getParsedPerson()->getPeople();
     $this->assertEquals(2, sizeof($people));
     $firstPerson = $people[0];
     $this->assertEquals('Peter', $firstPerson->getAddressingGivenName());
     $this->assertEquals('Meyer', $firstPerson->getAddressingSurname());
     $this->assertEquals('MALE', (string) $firstPerson->getGender()->getGender());
     $secondPerson = $people[1];
     $this->assertEquals('Daniela', $secondPerson->getAddressingGivenName());
     $this->assertEquals('Meyer', $secondPerson->getAddressingSurname());
     $this->assertEquals('FEMALE', (string) $secondPerson->getGender()->getGender());
 }
 public function testDea()
 {
     //setup code:
     $context = Context::builder()->priority(Priority::REALTIME())->build();
     $myApiKey = 'test';
     //grab one from nameapi.org
     $serviceFactory = new ServiceFactory($myApiKey, $context, Host::http('rc50-api.nameapi.org'), '5.0');
     //the call:
     $deaDetector = $serviceFactory->emailServices()->disposableEmailAddressDetector();
     $result = $deaDetector->isDisposable("*****@*****.**");
     //the assertions:
     $this->assertEquals('YES', (string) $result->getDisposable());
 }
 public function testPing()
 {
     //setup code:
     $context = Context::builder()->priority(Priority::REALTIME())->build();
     $myApiKey = 'test';
     //grab one from nameapi.org
     $serviceFactory = new ServiceFactory($myApiKey, $context, Host::http('rc50-api.nameapi.org'), '5.0');
     //the call:
     $pingService = $serviceFactory->systemServices()->ping();
     $result = $pingService->ping();
     //the assertions:
     $this->assertEquals('pong', $result);
 }
예제 #5
0
<?php

require 'vendor/autoload.php';
use org\nameapi\ontology\input\context\Context;
use org\nameapi\ontology\input\context\Priority;
use org\nameapi\client\services\ServiceFactory;
define('API_KEY', 'your-api-key');
define('TEST_EMAIL', '*****@*****.**');
$context = Context::builder()->apiKey(API_KEY)->priority(Priority::REALTIME())->build();
$serviceFactory = new ServiceFactory($context);
$deaDetector = $serviceFactory->emailServices()->disposableEmailAddressDetector();
$result = $deaDetector->isDisposable(TEST_EMAIL);
echo $result->getDisposable();