Skip to content

Commit

Permalink
Add test for set language.
Browse files Browse the repository at this point in the history
  • Loading branch information
dersam committed Dec 10, 2015
1 parent 7e4d1da commit 764c199
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/LinusShops/CanadaPost/Service.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ public function __construct($baseUrl, $userid, $password)
public function setLanguage($value)
{
$this->setHeader('Accept-language', $value);
return $this;
}

public function setHeader($name, $value)
Expand Down
23 changes: 23 additions & 0 deletions tests/GetNearestPostOfficeTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -90,4 +90,27 @@ public function testSetMaximumOffices()
$children = $doc->firstChild->childNodes;
$this->assertEquals(5, $children->length);
}

public function testSetLanguage()
{
$factory = new \LinusShops\CanadaPost\ServiceFactory(
CP_SANDBOX_ENDPOINT,
CP_USER,
CP_PASSWORD
);

/** @var \LinusShops\CanadaPost\Services\GetNearestPostOffice $service */
$service = $factory->getService('GetNearestPostOffice');
$response = $service
->setLanguage('fr-CA')
->setParameter('d2po', 'true')
->setParameter('longitude', LOOKUP_LONG)
->setParameter('latitude', LOOKUP_LAT)
->send();

$doc = new DOMDocument();
$this->assertTrue($doc->loadXML($response->getBody()), "Response not valid XML");
$children = $doc->firstChild->childNodes;
$this->assertEquals(10, $children->length);
}
}

0 comments on commit 764c199

Please sign in to comment.