Skip to content

Commit d9217df

Browse files
committed
Added formatter test. Some cleanup.
1 parent 08fe7f5 commit d9217df

File tree

9 files changed

+57
-37
lines changed

9 files changed

+57
-37
lines changed

src/org/nameapi/client/services/formatter/FormatterProperties.php

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,13 @@ public function __construct() {
2323
}
2424

2525

26-
public function setFormatUnknownInput($bool) {
26+
/**
27+
* @param $bool
28+
* @return FormatterProperties
29+
*/
30+
public function formatUnknownInput($bool) {
2731
$this->formatUnknownInput = $bool;
32+
return $this;
2833
}
2934

3035
/**

src/org/nameapi/client/services/formatter/FormatterServiceFactory.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,11 @@
33
namespace org\nameapi\client\services\formatter;
44

55
use org\nameapi\ontology\input\context\Context;
6+
use org\nameapi\client\services\formatter\personnameformatter\PersonNameFormatterService;
7+
use org\nameapi\client\services\formatter\namefieldformatter\NameFieldFormatterService;
68

7-
require_once('PersonNameFormatterService.php');
8-
require_once('NameFieldFormatterService.php');
9+
require_once('personnameformatter\PersonNameFormatterService.php');
10+
require_once('namefieldformatter\NameFieldFormatterService.php');
911

1012

1113
/**

src/org/nameapi/client/services/formatter/NameFieldFormatterService.php renamed to src/org/nameapi/client/services/formatter/namefieldformatter/NameFieldFormatterService.php

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
<?php
22

3-
namespace org\nameapi\client\services\formatter;
3+
namespace org\nameapi\client\services\formatter\namefieldformatter;
44

55
use org\nameapi\ontology\input\context\Context;
66
use org\nameapi\ontology\input\entities\person\name\NameField;
7-
use org\nameapi\ontology\input\entities\person\name\InputPersonName;
7+
use org\nameapi\client\services\formatter\FormatterProperties;
8+
use org\nameapi\client\services\formatter\FormatterResult;
89

910
require_once('wsdl/SoapNameFieldFormatterService.php');
1011

@@ -17,9 +18,6 @@ class NameFieldFormatterService {
1718
private $context;
1819
private $soapNameFieldFormatterService;
1920

20-
/**
21-
* @access public
22-
*/
2321
public function __construct(Context $context) {
2422
$this->context = $context;
2523
$this->soapNameFieldFormatterService = new wsdl\SoapNameFieldFormatterService();

src/org/nameapi/client/services/formatter/wsdl/FormatNameFieldArguments.php renamed to src/org/nameapi/client/services/formatter/namefieldformatter/wsdl/FormatNameFieldArguments.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?php
22

3-
namespace org\nameapi\client\services\formatter\wsdl;
3+
namespace org\nameapi\client\services\formatter\namefieldformatter\wsdl;
44

55
use org\nameapi\ontology\input\context\Context;
66
use org\nameapi\ontology\input\entities\person\name\NameField;

src/org/nameapi/client/services/formatter/wsdl/SoapNameFieldFormatterService.php renamed to src/org/nameapi/client/services/formatter/namefieldformatter/wsdl/SoapNameFieldFormatterService.php

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
<?php
22

3-
namespace org\nameapi\client\services\formatter\wsdl;
3+
namespace org\nameapi\client\services\formatter\namefieldformatter\wsdl;
44

55
use org\nameapi\client\services\BaseSoapClient;
66

7-
require_once(__DIR__ . '/../../Util.php');
7+
require_once(__DIR__ . '/../../../Util.php');
88
require_once('FormatNameFieldArguments.php');
9-
require_once('SoapFormatterProperties.php');
10-
require_once(__DIR__ . '/../../BaseSoapClient.php');
9+
require_once(__DIR__ . '/../../wsdl/SoapFormatterProperties.php');
10+
require_once(__DIR__ . '/../../../BaseSoapClient.php');
1111

1212

1313
/**
@@ -20,14 +20,10 @@ class SoapNameFieldFormatterService extends BaseSoapClient {
2020

2121
/**
2222
*/
23-
public function __construct(array $options = array(), $wsdl = 'http://api.nameapi.org/soap/v4.0/formatter/namefield?wsdl') {
23+
public function __construct(array $options = array(), $wsdl = 'http://api.nameapi.org/soap/v4.0/formatter/namefieldformatter?wsdl') {
2424
parent::__construct($wsdl, self::$classmap, $options);
2525
}
2626

27-
/**
28-
* @param FormatNameFieldArguments $parameters
29-
* @access public
30-
*/
3127
public function formatNameField(FormatNameFieldArguments $parameters) {
3228
return $this->__soapCall('formatNameField', array($parameters));
3329
}

src/org/nameapi/client/services/formatter/PersonNameFormatterService.php renamed to src/org/nameapi/client/services/formatter/personnameformatter/PersonNameFormatterService.php

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,31 @@
11
<?php
22

3-
namespace org\nameapi\client\services\formatter;
3+
namespace org\nameapi\client\services\formatter\personnameformatter;
44

55
use org\nameapi\ontology\input\context\Context;
66
use org\nameapi\ontology\input\entities\person\NaturalInputPerson;
7+
use org\nameapi\client\services\formatter\FormatterProperties;
8+
use org\nameapi\client\services\formatter\FormatterResult;
79

810
require_once('wsdl/SoapPersonNameFormatterService.php');
9-
require_once('FormatterResult.php');
10-
require_once('FormatterProperties.php');
11+
require_once(__DIR__.'/../FormatterResult.php');
12+
require_once(__DIR__.'/../FormatterProperties.php');
1113

1214

1315

1416
/**
1517
* This is the service class for the web service offered at
16-
* http://api.nameapi.org/soap/v4.0/formatter/personname?wsdl
18+
* http://api.nameapi.org/soap/v4.0/formatter/personnameformatter?wsdl
1719
*
1820
* HOW TO USE:
19-
* $personNameFormatter = $myServiceFactory->nameFormatterServiceFactory()->personNameFormatter();
21+
* $personNameFormatter = $myServiceFactory->formatterServices()->personNameFormatter();
2022
* $formatterResult = $personNameFormatter->format($myInputPerson, $myParams);
2123
*/
2224
class PersonNameFormatterService {
2325

2426
private $context;
2527
private $soapPersonNameFormatterService;
2628

27-
/**
28-
* @access public
29-
*/
3029
public function __construct(Context $context) {
3130
$this->context = $context;
3231
$this->soapPersonNameFormatterService = new wsdl\SoapPersonNameFormatterService();

src/org/nameapi/client/services/formatter/wsdl/FormatPersonNameArguments.php renamed to src/org/nameapi/client/services/formatter/personnameformatter/wsdl/FormatPersonNameArguments.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
<?php
22

3-
namespace org\nameapi\client\services\formatter\wsdl;
3+
namespace org\nameapi\client\services\formatter\personnameformatter\wsdl;
44

55
use org\nameapi\ontology\input\context\Context;
66
use org\nameapi\ontology\input\entities\person\NaturalInputPerson;
7+
use org\nameapi\client\services\formatter\wsdl\SoapFormatterProperties;
78

89
/**
910
* The input to SoapPersonNameFormatterService.

src/org/nameapi/client/services/formatter/wsdl/SoapPersonNameFormatterService.php renamed to src/org/nameapi/client/services/formatter/personnameformatter/wsdl/SoapPersonNameFormatterService.php

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
<?php
22

3-
namespace org\nameapi\client\services\formatter\wsdl;
3+
namespace org\nameapi\client\services\formatter\personnameformatter\wsdl;
44

55
use org\nameapi\client\services\BaseSoapClient;
66

7-
require_once(__DIR__ . '/../../Util.php');
7+
require_once(__DIR__ . '/../../../Util.php');
88
require_once('FormatPersonNameArguments.php');
9-
require_once('SoapFormatterProperties.php');
10-
require_once(__DIR__ . '/../../BaseSoapClient.php');
9+
require_once(__DIR__ . '/../../wsdl/SoapFormatterProperties.php');
10+
require_once(__DIR__ . '/../../../BaseSoapClient.php');
1111

1212

1313
/**
@@ -18,16 +18,10 @@ class SoapPersonNameFormatterService extends BaseSoapClient {
1818
private static $classmap = array(
1919
);
2020

21-
/**
22-
*/
2321
public function __construct(array $options = array(), $wsdl = 'http://api.nameapi.org/soap/v4.0/formatter/personnameformatter?wsdl') {
2422
parent::__construct($wsdl, self::$classmap, $options);
2523
}
2624

27-
/**
28-
* @param FormatPersonNameArguments $parameters
29-
* @access public
30-
*/
3125
public function format(FormatPersonNameArguments $parameters) {
3226
return $this->__soapCall('format', array($parameters));
3327
}
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
<?php
2+
3+
namespace org\nameapi\client\services\formatter\personnameformatter;
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\client\services\formatter\FormatterProperties;
11+
12+
class PersonNameFormatterServiceTest extends BaseServiceTest {
13+
14+
public function testFormat() {
15+
$personNameFormatter = $this->makeServiceFactory()->formatterServices()->personNameFormatter();
16+
$inputPerson = NaturalInputPerson::builder()
17+
->name(InputPersonName::westernBuilder()
18+
->fullname( "john kennedy" )
19+
->build())
20+
->build();
21+
$formatterResult = $personNameFormatter->format($inputPerson, new FormatterProperties());
22+
$this->assertEquals('John Kennedy', $formatterResult->getFormatted());
23+
}
24+
25+
}

0 commit comments

Comments
 (0)