Skip to content

Commit

Permalink
Merge pull request #27 from myparcelnl/develop
Browse files Browse the repository at this point in the history
Develop
  • Loading branch information
Reindert authored Sep 29, 2017
2 parents 5dcc9a5 + ec343f5 commit 5466783
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 39 deletions.
3 changes: 2 additions & 1 deletion Tests/SendConsignments/SendOneConsignmentTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@ class SendOneConsignmentTest extends \PHPUnit_Framework_TestCase
{

/**
* Test one shipment with createConcepts()
* Test one shipment
* @covers \MyParcelNL\Sdk\src\Helper\MyParcelCollection::createConcepts
*/
public function testSendOneConsignment()
{
Expand Down
16 changes: 7 additions & 9 deletions Tests/SplitStreet/InternationalFullStreetTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,18 +28,16 @@ class InternationalFullStreetTest extends \PHPUnit_Framework_TestCase
{

/**
* Test setFullStreet()
* @covers \MyParcelNL\Sdk\src\Model\Repository\MyParcelConsignmentRepository::getFullStreet
* @dataProvider additionProvider()
*/
public function testSplitStreet()
public function testSplitStreet($cc, $fullStreet)
{
foreach ($this->additionProvider() as $consignmentTest) {
$consignment = (new MyParcelConsignmentRepository())
->setCountry($cc)
->setFullStreet($fullStreet);

$consignment = (new MyParcelConsignmentRepository())
->setCountry($consignmentTest['cc'])
->setFullStreet($consignmentTest['full_street']);

$this->assertEquals($consignmentTest['full_street'], $consignment->getFullStreet(), 'Full street: ' . $consignmentTest['full_street']);
}
$this->assertEquals($fullStreet, $consignment->getFullStreet(), 'Full street: ' . $fullStreet);
}

/**
Expand Down
22 changes: 10 additions & 12 deletions Tests/SplitStreet/SplitStreetTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,21 +26,19 @@ class SplitStreetTest extends \PHPUnit_Framework_TestCase
{

/**
* Test setFullStreet()
* @covers \MyParcelNL\Sdk\src\Model\Repository\MyParcelConsignmentRepository::setFullStreet
* @dataProvider additionProvider()
*/
public function testSplitStreet()
public function testSplitStreet($fullStreetTest, $fullStreet, $street, $number, $numberSuffix)
{
foreach ($this->additionProvider() as $consignmentTest) {
$consignment = (new MyParcelConsignmentRepository())
->setCountry('NL')
->setFullStreet($fullStreetTest);

$consignment = (new MyParcelConsignmentRepository())
->setCountry('NL')
->setFullStreet($consignmentTest['full_street_test']);

$this->assertEquals($consignmentTest['number_suffix'], $consignment->getNumberSuffix(), 'Number suffix from: ' . $consignmentTest['full_street_test']);
$this->assertEquals($consignmentTest['number'], $consignment->getNumber(), 'Number from: ' . $consignmentTest['full_street_test']);
$this->assertEquals($consignmentTest['street'], $consignment->getStreet(), 'Street: ' . $consignmentTest['full_street_test']);
$this->assertEquals($consignmentTest['full_street'], $consignment->getFullStreet(), 'Full street: ' . $consignmentTest['full_street_test']);
}
$this->assertEquals($fullStreet, $consignment->getFullStreet(), 'Full street: ' . $fullStreetTest);
$this->assertEquals($street, $consignment->getStreet(), 'Street: ' . $fullStreetTest);
$this->assertEquals($number, $consignment->getNumber(), 'Number from: ' . $fullStreetTest);
$this->assertEquals($numberSuffix, $consignment->getNumberSuffix(), 'Number suffix from: ' . $fullStreetTest);
}

/**
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "myparcelnl/sdk",
"version": "v1.2.1",
"version": "v1.2.2",
"description": "This package is designed to send and receive data from MyParcel by means of an API.",
"homepage": "https://www.myparcel.nl",
"tags": ["MyParcel", "My Parcel", "Post NL", "PostNL"],
Expand Down
2 changes: 1 addition & 1 deletion src/Helper/MyParcelCollection.php
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@ public function addConsignment(MyParcelConsignmentRepository $consignment)
/**
* Create concepts in MyParcel
*
* @todo Later, when the api supports a reference ID, we can produce all the items in one time.
* @todo Produce all the items in one time with reference ID.
*
* @return $this
* @throws \Exception
Expand Down
18 changes: 3 additions & 15 deletions src/Model/MyParcelRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -159,8 +159,10 @@ public function sendRequest($method = 'POST', $uri = self::REQUEST_TYPE_SHIPMENT
} else {
$this->result = json_decode($response, true);

if ($response === false) {
$this->error = $request->getError();
}
$this
->checkCurlErrors($request)
->checkMyParcelErrors();
}

Expand All @@ -174,20 +176,6 @@ public function sendRequest($method = 'POST', $uri = self::REQUEST_TYPE_SHIPMENT
return $this;
}

/**
* Check if there are curl-errors
*
* @return $this
*/
private function checkCurlErrors($request)
{
if ($request->read() === false) {
$this->error = $request->getError();
}

return $this;
}

/**
* Check if MyParcel gives an error
*
Expand Down

0 comments on commit 5466783

Please sign in to comment.