Skip to content

Commit

Permalink
feat(consignment): add state property (#469)
Browse files Browse the repository at this point in the history
* feat: add state property

* feat: add state property
  • Loading branch information
Mark-Ernst authored Feb 1, 2024
1 parent 021f28e commit 3488251
Show file tree
Hide file tree
Showing 4 changed files with 116 additions and 1 deletion.
25 changes: 25 additions & 0 deletions src/Model/Consignment/AbstractConsignment.php
Original file line number Diff line number Diff line change
Expand Up @@ -471,6 +471,11 @@ abstract class AbstractConsignment
*/
protected $drop_off_point;

/**
* @var null|string
*/
private $state;

/**
* @throws \Exception
*/
Expand Down Expand Up @@ -840,6 +845,26 @@ public function getRegion(): ?string
return $this->region;
}

/**
* @return null|string
*/
public function getState(): ?string
{
return $this->state;
}

/**
* @param null|string $state
*
* @return self
*/
public function setState(?string $state): self
{
$this->state = $state;

return $this;
}

/**
* @param string|null $region
*
Expand Down
1 change: 1 addition & 0 deletions src/Services/ConsignmentEncode.php
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,7 @@ private function encodeBase(): self
'postal_code' => $consignment->getPostalCode(),
'city' => (string) $consignment->getCity(),
'region' => (string) $consignment->getRegion(),
'state' => (string) $consignment->getState(),
'email' => (string) $consignment->getEmail(),
'phone' => (string) $consignment->getPhone(),
],
Expand Down
89 changes: 89 additions & 0 deletions test/Model/Consignment/AbstractConsignmentTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
<?php

declare(strict_types=1);

namespace MyParcelNL\Sdk\Test\Model\Consignment;

use MyParcelNL\Sdk\src\Model\Consignment\AbstractConsignment;
use MyParcelNL\Sdk\src\Model\Consignment\PostNLConsignment;
use MyParcelNL\Sdk\Test\Bootstrap\TestCase;

class AbstractConsignmentTest extends TestCase
{
private const TEST_DATA = [
'cc' => 'NL',
'city' => 'Heerhugowaard',
'street' => 'Dorpsstraat',
'number' => '1',
'box_number' => '2',
'number_suffix' => 'b',
'region' => 'Noord-Holland',
'state' => 'NH',
'postal_code' => '1701AA',
'person' => 'Pietje Puk',
'package_type' => AbstractConsignment::PACKAGE_TYPE_PACKAGE,
'only_recipient' => true,
'signature' => true,
'return' => true,
'large_format' => true,
'age_check' => true,
'label_description' => 'Voorbeeld123',
'shop_id' => 1,
'status' => 99,
'external_identifier' => '123456789',
'barcode' => '3STOIS912345678',
];

/**
* @return void
* @throws \MyParcelNL\Sdk\src\Exception\MissingFieldException
*/
public function testAbstractConsignment(): void
{
$consignment = new PostNLConsignment();

$consignment
->setCountry(self::TEST_DATA['cc'])
->setCity(self::TEST_DATA['city'])
->setStreet(self::TEST_DATA['street'])
->setNumber(self::TEST_DATA['number'])
->setBoxNumber(self::TEST_DATA['box_number'])
->setNumberSuffix(self::TEST_DATA['number_suffix'])
->setRegion(self::TEST_DATA['region'])
->setState(self::TEST_DATA['state'])
->setPostalCode(self::TEST_DATA['postal_code'])
->setPerson(self::TEST_DATA['person'])
->setPackageType(self::TEST_DATA['package_type'])
->setOnlyRecipient(self::TEST_DATA['only_recipient'])
->setSignature(self::TEST_DATA['signature'])
->setReturn(self::TEST_DATA['return'])
->setLargeFormat(self::TEST_DATA['large_format'])
->setAgeCheck(self::TEST_DATA['age_check'])
->setLabelDescription(self::TEST_DATA['label_description'])
->setShopId(self::TEST_DATA['shop_id'])
->setStatus(self::TEST_DATA['status'])
->setExternalIdentifier(self::TEST_DATA['external_identifier'])
->setBarcode(self::TEST_DATA['barcode']);

self::assertEquals(self::TEST_DATA['cc'], $consignment->getCountry());
self::assertEquals(self::TEST_DATA['city'], $consignment->getCity());
self::assertEquals(self::TEST_DATA['street'], $consignment->getStreet());
self::assertEquals(self::TEST_DATA['number'], $consignment->getNumber());
self::assertEquals(self::TEST_DATA['box_number'], $consignment->getBoxNumber());
self::assertEquals(self::TEST_DATA['number_suffix'], $consignment->getNumberSuffix());
self::assertEquals(self::TEST_DATA['region'], $consignment->getRegion());
self::assertEquals(self::TEST_DATA['state'], $consignment->getState());
self::assertEquals(self::TEST_DATA['postal_code'], $consignment->getPostalCode());
self::assertEquals(self::TEST_DATA['person'], $consignment->getPerson());
self::assertEquals(self::TEST_DATA['only_recipient'], $consignment->isOnlyRecipient());
self::assertEquals(self::TEST_DATA['signature'], $consignment->isSignature());
self::assertEquals(self::TEST_DATA['return'], $consignment->isReturn());
self::assertEquals(self::TEST_DATA['large_format'], $consignment->isLargeFormat());
self::assertEquals(self::TEST_DATA['age_check'], $consignment->hasAgeCheck());
self::assertEquals(self::TEST_DATA['label_description'], $consignment->getLabelDescription());
self::assertEquals(self::TEST_DATA['shop_id'], $consignment->getShopId());
self::assertEquals(self::TEST_DATA['status'], $consignment->getStatus());
self::assertEquals(self::TEST_DATA['external_identifier'], $consignment->getExternalIdentifier());
self::assertEquals(self::TEST_DATA['barcode'], $consignment->getBarcode());
}
}
2 changes: 1 addition & 1 deletion test/Model/Consignment/UPSConsignmentTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public function provideUPSConsignmentsData(): array
* @throws \Exception
* @dataProvider provideUPSConsignmentsData
*/
public function testUPSForYouConsignments(array $testData): void
public function testUPSConsignments(array $testData): void
{
$this->doConsignmentTest($testData);
}
Expand Down

0 comments on commit 3488251

Please sign in to comment.