diff --git a/Tests/SendConsignments/SendOneConsignmentTest.php b/Tests/SendConsignments/SendOneConsignmentTest.php index 29871526..c63677e4 100755 --- a/Tests/SendConsignments/SendOneConsignmentTest.php +++ b/Tests/SendConsignments/SendOneConsignmentTest.php @@ -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() { diff --git a/Tests/SplitStreet/InternationalFullStreetTest.php b/Tests/SplitStreet/InternationalFullStreetTest.php index 36dc5239..33b3b4cc 100755 --- a/Tests/SplitStreet/InternationalFullStreetTest.php +++ b/Tests/SplitStreet/InternationalFullStreetTest.php @@ -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); } /** diff --git a/Tests/SplitStreet/SplitStreetTest.php b/Tests/SplitStreet/SplitStreetTest.php index 3d573f6b..c1232569 100755 --- a/Tests/SplitStreet/SplitStreetTest.php +++ b/Tests/SplitStreet/SplitStreetTest.php @@ -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); } /** diff --git a/composer.json b/composer.json index 2add309d..7da2fd52 100755 --- a/composer.json +++ b/composer.json @@ -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"], diff --git a/src/Helper/MyParcelCollection.php b/src/Helper/MyParcelCollection.php index 7733b229..662bb8f8 100644 --- a/src/Helper/MyParcelCollection.php +++ b/src/Helper/MyParcelCollection.php @@ -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 diff --git a/src/Model/MyParcelRequest.php b/src/Model/MyParcelRequest.php index 57a3a4b9..c8cf0585 100644 --- a/src/Model/MyParcelRequest.php +++ b/src/Model/MyParcelRequest.php @@ -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(); } @@ -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 *