-
Notifications
You must be signed in to change notification settings - Fork 28
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Only package type 1 can have extra options
- Loading branch information
reindertvetter
committed
Feb 21, 2017
1 parent
0af2c63
commit 4c32aad
Showing
2 changed files
with
195 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,144 @@ | ||
<?php | ||
|
||
/** | ||
* Create one mailbox | ||
* | ||
* If you want to add improvements, please create a fork in our GitHub: | ||
* https://github.com/myparcelnl | ||
* | ||
* @author Reindert Vetter <[email protected]> | ||
* @copyright 2010-2017 MyParcel | ||
* @license http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US CC BY-NC-ND 3.0 NL | ||
* @link https://github.com/myparcelnl/sdk | ||
* @since File available since Release v0.1.0 | ||
*/ | ||
|
||
namespace MyParcelNL\Sdk\tests\SendConsignments; | ||
|
||
use MyParcelNL\Sdk\src\Helper\MyParcelCollection; | ||
use MyParcelNL\Sdk\src\Model\Repository\MyParcelConsignmentRepository; | ||
|
||
|
||
/** | ||
* Class SendMailboxConsignmentTest | ||
* @package MyParcelNL\Sdk\tests\SendMailboxConsignmentTest | ||
*/ | ||
class SendMailboxConsignmentTest extends \PHPUnit_Framework_TestCase | ||
{ | ||
|
||
/** | ||
* Test one shipment with createConcepts() | ||
*/ | ||
public function testSendOneConsignment() | ||
{ | ||
foreach ($this->additionProvider() as $consignmentTest) { | ||
|
||
$myParcelCollection = new MyParcelCollection(); | ||
|
||
$consignment = (new MyParcelConsignmentRepository()) | ||
->setApiKey($consignmentTest['api_key']) | ||
->setCountry($consignmentTest['cc']) | ||
->setPerson($consignmentTest['person']) | ||
->setCompany($consignmentTest['company']) | ||
->setFullStreet($consignmentTest['full_street_test']) | ||
->setPostalCode($consignmentTest['postal_code']) | ||
->setCity($consignmentTest['city']) | ||
->setEmail('[email protected]') | ||
->setPhone($consignmentTest['phone']); | ||
|
||
if (key_exists('package_type', $consignmentTest)) | ||
$consignment->setPackageType($consignmentTest['package_type']); | ||
|
||
if (key_exists('large_format', $consignmentTest)) | ||
$consignment->setLargeFormat($consignmentTest['large_format']); | ||
|
||
if (key_exists('only_recipient', $consignmentTest)) | ||
$consignment->setOnlyRecipient($consignmentTest['only_recipient']); | ||
|
||
if (key_exists('signature', $consignmentTest)) | ||
$consignment->setSignature($consignmentTest['signature']); | ||
|
||
if (key_exists('return', $consignmentTest)) | ||
$consignment->setReturn($consignmentTest['return']); | ||
|
||
if (key_exists('insurance', $consignmentTest)) | ||
$consignment->setInsurance($consignmentTest['insurance']); | ||
|
||
if (key_exists('label_description', $consignmentTest)) | ||
$consignment->setLabelDescription($consignmentTest['label_description']); | ||
|
||
$myParcelCollection->addConsignment($consignment); | ||
|
||
/** | ||
* Create concept | ||
*/ | ||
$myParcelCollection->createConcepts()->setLatestData(); | ||
|
||
$this->assertEquals(true, $consignment->getMyParcelConsignmentId() > 1, 'No id found'); | ||
$this->assertEquals($consignmentTest['api_key'], $consignment->getApiKey(), 'getApiKey()'); | ||
$this->assertEquals($consignmentTest['cc'], $consignment->getCountry(), 'getCountry()'); | ||
$this->assertEquals($consignmentTest['person'], $consignment->getPerson(), 'getPerson()'); | ||
$this->assertEquals($consignmentTest['company'], $consignment->getCompany(), 'getCompany()'); | ||
$this->assertEquals($consignmentTest['full_street'], $consignment->getFullStreet(), 'getFullStreet()'); | ||
$this->assertEquals($consignmentTest['number'], $consignment->getNumber(), 'getNumber()'); | ||
$this->assertEquals($consignmentTest['number_suffix'], $consignment->getNumberSuffix(), 'getNumberSuffix()'); | ||
$this->assertEquals($consignmentTest['postal_code'], $consignment->getPostalCode(), 'getPostalCode()'); | ||
$this->assertEquals($consignmentTest['city'], $consignment->getCity(), 'getCity()'); | ||
$this->assertEquals($consignmentTest['phone'], $consignment->getPhone(), 'getPhone()'); | ||
|
||
$this->assertEquals($consignmentTest['label_description'], $consignment->getLabelDescription(), 'getLabelDescription()'); | ||
$this->assertEquals($consignmentTest['package_type'], $consignment->getPackageType(), 'getPackageType()'); | ||
$this->assertEquals(false, $consignment->isLargeFormat(), 'isLargeFormat()'); | ||
$this->assertEquals(false, $consignment->isOnlyRecipient(), 'isOnlyRecipient()'); | ||
$this->assertEquals(false, $consignment->isSignature(), 'isSignature()'); | ||
$this->assertEquals(false, $consignment->isReturn(), 'isReturn()'); | ||
$this->assertEquals(false, $consignment->getInsurance(), 'getInsurance()'); | ||
|
||
/** | ||
* Get label | ||
*/ | ||
$myParcelCollection | ||
->setLinkOfLabels(); | ||
|
||
$this->assertEquals(true, preg_match("#^https://api.myparcel.nl/pdfs#", $myParcelCollection->getLinkOfLabels()), 'Can\'t get link of PDF'); | ||
|
||
/** @var MyParcelConsignmentRepository $consignment */ | ||
$consignment = $myParcelCollection->getOneConsignment(); | ||
$this->assertEquals(true, preg_match("#^3SMYPA#", $consignment->getBarcode()), 'Barcode is not set'); | ||
|
||
/** @todo; clear consignment in MyParcelCollection */ | ||
} | ||
} | ||
|
||
/** | ||
* Data for the test | ||
* | ||
* @return array | ||
*/ | ||
public function additionProvider() | ||
{ | ||
return [ | ||
[ | ||
'api_key' => '94a98610ab9bf67a82873196c9ca688c601c179a', | ||
'cc' => 'NL', | ||
'person' => 'The insurance man', | ||
'company' => 'Mega Store', | ||
'full_street_test' => 'Koestraat 55', | ||
'full_street' => 'Koestraat 55', | ||
'street' => 'Koestraat', | ||
'number' => 55, | ||
'number_suffix' => '', | ||
'postal_code' => '2231JE', | ||
'city' => 'Katwijk', | ||
'phone' => '123-45-235-435', | ||
'package_type' => 2, | ||
'large_format' => true, | ||
'only_recipient' => true, | ||
'signature' => true, | ||
'return' => true, | ||
'label_description' => 1234, | ||
'insurance' => 250, | ||
] | ||
]; | ||
} | ||
} |
Oops, something went wrong.