-
Notifications
You must be signed in to change notification settings - Fork 256
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added createRequest test for XAV class
- Loading branch information
1 parent
e4b8a62
commit 281f4c9
Showing
2 changed files
with
58 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
<?php | ||
namespace Ups\Tests; | ||
|
||
use Ups; | ||
use Exception; | ||
use PHPUnit_Framework_TestCase; | ||
|
||
// @todo Include also request test | ||
class AddressValidationTest extends PHPUnit_Framework_TestCase | ||
{ | ||
public function testCreateRequest() | ||
{ | ||
$xavRequest = new \Ups\AddressValidation; | ||
$xavRequest->setRequest($request = new RequestMock); | ||
|
||
$address = new \Ups\Entity\Address; | ||
$address->setAttentionName('Test Test'); | ||
$address->setBuildingName('Building 1'); | ||
$address->setAddressLine1('Times Square 1'); | ||
$address->setAddressLine2('First Corner'); | ||
$address->setAddressLine3('Second Corner'); | ||
$address->setStateProvinceCode('NY'); | ||
$address->setCity('New York'); | ||
$address->setCountryCode('US'); | ||
$address->setPostalCode('50000'); | ||
|
||
try { | ||
// Get data | ||
$response = $xavRequest->validate($address); | ||
} catch (Exception $e) {} | ||
|
||
$this->assertEquals( | ||
$request->getRequestXml(), | ||
$request->getExpectedRequestXml('/AddressValidation/Request1.xml') | ||
); | ||
} | ||
|
||
} |
20 changes: 20 additions & 0 deletions
20
tests/Ups/Tests/_files/requests/AddressValidation/Request1.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
<?xml version="1.0"?> | ||
<AddressValidationRequest xml:lang="en-US"> | ||
<Request> | ||
<TransactionReference/> | ||
<RequestAction>XAV</RequestAction> | ||
<RequestOption>1</RequestOption> | ||
</Request> | ||
<MaximumListSize>5</MaximumListSize> | ||
<AddressKeyFormat> | ||
<ConsigneeName>Test Test</ConsigneeName> | ||
<BuildingName>Building 1</BuildingName> | ||
<AddressLine>Times Square 1</AddressLine> | ||
<AddressLine>First Corner</AddressLine> | ||
<AddressLine>Second Corner</AddressLine> | ||
<PoliticalDivision2>NY</PoliticalDivision2> | ||
<PoliticalDivision1>New York</PoliticalDivision1> | ||
<CountryCode>US</CountryCode> | ||
<PostcodePrimaryLow>50000</PostcodePrimaryLow> | ||
</AddressKeyFormat> | ||
</AddressValidationRequest> |