Skip to content

Commit

Permalink
✅ Created tests for customs and updated other tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Shady Khattab committed Dec 5, 2017
1 parent 55d8a09 commit 972780d
Show file tree
Hide file tree
Showing 7 changed files with 602 additions and 5 deletions.
228 changes: 224 additions & 4 deletions tests/Feature/ResourceFactoryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -157,10 +157,6 @@ public function testCreateContract()
], $contract->jsonSerialize());
}

// TODO
const TYPE_FILE = 'files';


/** @test */
public function testCreateEmptyPickUpDropOffLocation()
{
Expand Down Expand Up @@ -624,6 +620,230 @@ public function testCreateShipment()
], $shipment->jsonSerialize());
}

/** @test */
public function testCreateShipmentWitCustoms()
{
$resourceFactory = new ResourceFactory();
$shipment = $resourceFactory->create('shipments', [
'barcode' => 'S3BARCODE',
'description' => 'order #012ASD',
'price' => 99,
'currency' => 'USD',
'insurance_amount' => 50,
'weight' => 8000,
'physical_properties' => [
'weight' => 1000,
'length' => 1100,
'volume' => 1200,
'height' => 1300,
'width' => 1400,
],
'recipient_address' => [
'street_1' => 'Diagonally',
'street_2' => 'Apartment 4',
'street_number' => '1',
'street_number_suffix' => 'A',
'postal_code' => '1AR BR2',
'city' => 'London',
'country_code' => 'GB',
'first_name' => 'Robert',
'last_name' => 'Drop Tables',
'company' => 'ACME co.',
'email' => '[email protected]',
'phone_number' => '+31 (0)234 567 890',
],
'sender_address' => [
'street_1' => 'Diagonally',
'street_2' => 'Apartment 9',
'street_number' => '4',
'street_number_suffix' => 'A',
'postal_code' => '1AR BR2',
'city' => 'London',
'country_code' => 'NL',
'first_name' => 'Robert',
'last_name' => 'Drop Tables',
'company' => 'ACME co.',
'email' => '[email protected]',
'phone_number' => '+31 (0)234 567 890',
],
'pickup_location_code' => 'CODE123',
'pickup_location_address' => [
'street_1' => 'Diagonally',
'street_2' => 'Apartment 41',
'street_number' => '2',
'street_number_suffix' => 'A',
'postal_code' => '1AR BR2',
'city' => 'London',
'country_code' => 'GB',
'first_name' => 'Robert',
'last_name' => 'Drop Tables',
'company' => 'ACME co.',
'email' => '[email protected]',
'phone_number' => '+31 (0)234 567 890',
],
'customs' => [
'content_type' => 'documents',
'invoice_number' => 'NO.5',
'items' => [
[
'sku' => '123456789',
'description' => 'OnePlus X',
'item_value' => 100,
'currency' => 'GBP',
'quantity' => 2,
'hs_code' => '8517.12.00',
'origin_country_code' => 'GB',
],
[
'sku' => '213425',
'description' => 'OnePlus One',
'item_value' => 200,
'currency' => 'GBP',
'quantity' => 3,
'hs_code' => '8517.12.00',
'origin_country_code' => 'GB',
],
[
'sku' => '6876',
'description' => 'OnePlus Two',
'item_value' => 300,
'currency' => 'GBP',
'quantity' => 1,
'hs_code' => '8517.12.00',
'origin_country_code' => 'GB',
],
],
'non_delivery' => 'return',
'incoterm' => 'DDU',
],
'shop' => ['id' => 'shop-id-1', 'type' => 'shops'],
'service' => ['id' => 'service-id-1', 'type' => 'services'],
'contract' => ['id' => 'contract-id-1', 'type' => 'contracts'],
'status' => ['id' => 'status-id-1', 'type' => 'statuses'],
'options' => [['id' => 'option-id-1', 'type' => 'service-options']],
'files' => [['id' => 'file-id-1', 'type' => 'files']],
]);

$this->assertInstanceOf(ShipmentInterface::class, $shipment);
$this->assertEquals([
'type' => 'shipments',
'attributes' => [
'barcode' => 'S3BARCODE',
'description' => 'order #012ASD',
'price' => [
'amount' => 99,
'currency' => 'USD',
],
'insurance' => [
'amount' => 50,
'currency' => 'USD',
],
'weight' => 8000,
'physical_properties' => [
'weight' => 1000,
'length' => 1100,
'volume' => 1200,
'height' => 1300,
'width' => 1400,
],
'recipient_address' => [
'street_1' => 'Diagonally',
'street_2' => 'Apartment 4',
'street_number' => '1',
'street_number_suffix' => 'A',
'postal_code' => '1AR BR2',
'city' => 'London',
'country_code' => 'GB',
'first_name' => 'Robert',
'last_name' => 'Drop Tables',
'company' => 'ACME co.',
'email' => '[email protected]',
'phone_number' => '+31 (0)234 567 890',
],
'sender_address' => [
'street_1' => 'Diagonally',
'street_2' => 'Apartment 9',
'street_number' => '4',
'street_number_suffix' => 'A',
'postal_code' => '1AR BR2',
'city' => 'London',
'country_code' => 'NL',
'first_name' => 'Robert',
'last_name' => 'Drop Tables',
'company' => 'ACME co.',
'email' => '[email protected]',
'phone_number' => '+31 (0)234 567 890',
],
'pickup_location' => [
'code' => 'CODE123',
'address' => [
'street_1' => 'Diagonally',
'street_2' => 'Apartment 41',
'street_number' => '2',
'street_number_suffix' => 'A',
'postal_code' => '1AR BR2',
'city' => 'London',
'country_code' => 'GB',
'first_name' => 'Robert',
'last_name' => 'Drop Tables',
'company' => 'ACME co.',
'email' => '[email protected]',
'phone_number' => '+31 (0)234 567 890',
],
],
'customs' => [
'content_type' => 'documents',
'invoice_number' => 'NO.5',
'items' => [
[
'sku' => '123456789',
'description' => 'OnePlus X',
'item_value' => [
'amount' => 100,
'currency' => 'GBP',
],
'quantity' => 2,
'hs_code' => '8517.12.00',
'origin_country_code' => 'GB',
],
[
'sku' => '213425',
'description' => 'OnePlus One',
'item_value' => [
'amount' => 200,
'currency' => 'GBP',
],
'quantity' => 3,
'hs_code' => '8517.12.00',
'origin_country_code' => 'GB',
],
[
'sku' => '6876',
'description' => 'OnePlus Two',
'item_value' => [
'amount' => 300,
'currency' => 'GBP',
],
'quantity' => 1,
'hs_code' => '8517.12.00',
'origin_country_code' => 'GB',
],
],
'non_delivery' => 'return',
'incoterm' => 'DDU',
],
],
'relationships' => [
'shop' => ['data' => ['id' => 'shop-id-1', 'type' => 'shops']],
'service' => ['data' => ['id' => 'service-id-1', 'type' => 'services']],
'contract' => ['data' => ['id' => 'contract-id-1', 'type' => 'contracts']],
'status' => ['data' => ['id' => 'status-id-1', 'type' => 'statuses']],
'options' => ['data' => [['id' => 'option-id-1', 'type' => 'service-options']]],
'files' => ['data' => [['id' => 'file-id-1', 'type' => 'files']]],
],
], $shipment->jsonSerialize());
}

/** @test */
public function testCreateEmptyShop()
{
Expand Down
41 changes: 41 additions & 0 deletions tests/Stubs/get/https---api-v1-shipments-shipment-id-1.json
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,47 @@
"volume": 50,
"weight": 24
},
"customs": {
"content_type": "documents",
"invoice_number": "NO.5",
"items": [
{
"sku": "123456789",
"description": "OnePlus X",
"item_value": {
"amount": 100,
"currency": "GBP"
},
"quantity": 2,
"hs_code": "8517.12.00",
"origin_country_code": "GB"
},
{
"sku": "213425",
"description": "OnePlus One",
"item_value": {
"amount": 200,
"currency": "GBP"
},
"quantity": 3,
"hs_code": "8517.12.00",
"origin_country_code": "GB"
},
{
"sku": "6876",
"description": "OnePlus Two",
"item_value": {
"amount": 300,
"currency": "GBP"
},
"quantity": 1,
"hs_code": "8517.12.00",
"origin_country_code": "GB"
}
],
"non_delivery": "return",
"incoterm": "DDU"
},
"created_at": 1504801719,
"updated_at": 1504801719,
"synced_at": 1504801719
Expand Down
41 changes: 41 additions & 0 deletions tests/Stubs/get/https---api-v1-shipments.json
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,47 @@
"phone_number": "+31 234 567 890"
}
},
"customs": {
"content_type": "documents",
"invoice_number": "NO.5",
"items": [
{
"sku": "123456789",
"description": "OnePlus X",
"item_value": {
"amount": 100,
"currency": "GBP"
},
"quantity": 2,
"hs_code": "8517.12.00",
"origin_country_code": "GB"
},
{
"sku": "213425",
"description": "OnePlus One",
"item_value": {
"amount": 200,
"currency": "GBP"
},
"quantity": 3,
"hs_code": "8517.12.00",
"origin_country_code": "GB"
},
{
"sku": "6876",
"description": "OnePlus Two",
"item_value": {
"amount": 300,
"currency": "GBP"
},
"quantity": 1,
"hs_code": "8517.12.00",
"origin_country_code": "GB"
}
],
"non_delivery": "return",
"incoterm": "DDU"
},
"description": "order #8008135",
"price": {
"amount": 100,
Expand Down
Loading

0 comments on commit 972780d

Please sign in to comment.