Skip to content

Commit

Permalink
ensure the collection have multiple barcodes
Browse files Browse the repository at this point in the history
  • Loading branch information
RichardPerdaan committed Mar 29, 2019
1 parent cfeba64 commit bd52eb5
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 9 deletions.
11 changes: 6 additions & 5 deletions Tests/SendConsignments/SendMuliColoConsignmentTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
namespace MyParcelNL\Sdk\tests\SendConsignments\SendOneConsignmentTest;

use MyParcelNL\Sdk\src\Helper\MyParcelCollection;
use MyParcelNL\Sdk\src\Model\MyParcelConsignment;
use MyParcelNL\Sdk\src\Model\Repository\MyParcelConsignmentRepository;


Expand Down Expand Up @@ -85,7 +86,7 @@ public function testMultiColo()
$consignment->setLabelDescription($consignmentTest['label_description']);
}

$myParcelCollection = $myParcelCollection->addMultiCollo($consignment, $consignmentTest['multi_collo_amount']);
$myParcelCollection->addMultiCollo($consignment, $consignmentTest['multi_collo_amount']);


$this->assertCount($consignmentTest['multi_collo_amount'], $myParcelCollection);
Expand All @@ -97,11 +98,11 @@ public function testMultiColo()

$this->assertEquals(true, preg_match("#^https://api.myparcel.nl/pdfs#", $myParcelCollection->getLinkOfLabels()), 'Can\'t get link of PDF');

/** @var MyParcelConsignmentRepository $consignment */
$consignment = $myParcelCollection->getConsignments()[0];
$this->assertEquals(true, preg_match("#^3SMYPA#", $consignment->getBarcode()), 'Barcode is not set');
/** @var MyParcelConsignment[] $consignments */
$consignments = $myParcelCollection->getConsignments();

/** @todo; clear consignment in MyParcelCollection */
$this->assertNotEquals($consignments[0]->getMyParcelConsignmentId(), $consignments[1]->getMyParcelConsignmentId());
$this->assertNotEquals($consignments[0]->getBarcode(), $consignments[1]->getBarcode());
}
}

Expand Down
4 changes: 2 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
{
"name": "myparcelnl/sdk",
"version": "v2.1.0-beta.1",
"version": "v2.1.0-beta.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"],
"tags": ["MyParcel", "My Parcel", "Flespakket", "Post NL", "PostNL"],
"license": "GPL-3.0-or-later",
"authors": [
{
Expand Down
2 changes: 1 addition & 1 deletion src/Helper/MyParcelCollection.php
Original file line number Diff line number Diff line change
Expand Up @@ -593,7 +593,7 @@ private function apiEncodeReturnShipment($consignment)
*/
private function getNewCollectionFromResult($result)
{
$newCollection = new MyParcelCollection();
$newCollection = new static;
foreach ($result as $shipment) {

/** @var Collection|MyParcelConsignment[] $consignments */
Expand Down
2 changes: 1 addition & 1 deletion src/Services/CollectionEncode.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ public function encode()
*/
private function groupMultiColloConsignments()
{
return $this->consignments->groupBy(function (MyParcelConsignment $consignment) {
return $this->consignments->groupBy(function(MyParcelConsignment $consignment) {
if ($consignment->isPartOfMultiCollo()) {
return $consignment->getReferenceId();
}
Expand Down

0 comments on commit bd52eb5

Please sign in to comment.