Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test: refactor tests #34

Merged
merged 2 commits into from Aug 30, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
53 changes: 36 additions & 17 deletions tests/Api/Response/AccountResponse.php
Expand Up @@ -4,25 +4,44 @@

namespace MyParcelNL\Pdk\Tests\Api\Response;

use GuzzleHttp\Psr7\Utils;
use Psr\Http\Message\StreamInterface;

class AccountResponse extends JsonResponse
{
public function getBody(): StreamInterface
{
return Utils::streamFor(
json_encode([
'data' => [
'accounts' => [
[
'platform_id' => 3,
'id' => 3,
'shops' => [['id' => 3, 'name' => 'bloemkool']],
],
],
private const DEFAULT_ACCOUNTS = [
[
'platform_id' => 3,
'id' => 3,
'shops' => [
[
'id' => 3,
'name' => 'bloemkool',
],
])
);
],
],
];

/**
* @var array
*/
private $accounts;

public function __construct(
array $accounts = self::DEFAULT_ACCOUNTS,
int $status = 200,
array $headers = [],
$body = null,
string $version = '1.1',
string $reason = null
) {
parent::__construct($status, $headers, $body, $version, $reason);
$this->accounts = $accounts;
}

public function getContent(): array
{
return [
'data' => [
'accounts' => $this->accounts,
],
];
}
}
266 changes: 129 additions & 137 deletions tests/Api/Response/GetShipmentsResponse.php

Large diffs are not rendered by default.

231 changes: 112 additions & 119 deletions tests/Api/Response/GetShipmentsResponseWithDropOffPoint.php
Expand Up @@ -4,130 +4,123 @@

namespace MyParcelNL\Pdk\Tests\Api\Response;

use GuzzleHttp\Psr7\Utils;
use Psr\Http\Message\StreamInterface;

class GetShipmentsResponseWithDropOffPoint extends JsonResponse
{
public function getBody(): StreamInterface
public function getContent(): array
{
return Utils::streamFor(
json_encode(
[
'data' => [
'shipments' => [
[
'id' => 136510070,
'parent_id' => null,
'account_id' => 170402,
'shop_id' => 93683,
'shipment_type' => 1,
'recipient' => [
'cc' => 'NL',
'postal_code' => '7345AB',
'city' => 'Wenum Wiesel',
'street' => 'Wieselsedwarsweg',
'street_additional_info' => '',
'number' => '12',
'number_suffix' => 'c',
'person' => 'Epke Zonderland',
'email' => 'test@webshopje.nl',
'phone' => '0172765435',
],
'sender' => [
'phone' => '0606607834',
'company' => 'MyParcel',
'cc' => 'NL',
'postal_code' => '2132JE',
'number' => '31',
'street' => 'Antareslaan',
'city' => 'Hoofddorp',
'email' => 'mrparcel@myparcel.nl',
'street_additional_info' => '',
'person' => 'Mister Parcel',
'number_suffix' => '',
],
'status' => 1,
'options' => [
'package_type' => 1,
'collect' => 0,
'only_recipient' => 1,
'signature' => 0,
'return' => 1,
'insurance' => [
'amount' => 0,
'currency' => 'EUR',
],
'large_format' => 1,
'same_day_delivery' => 1,
'age_check' => 1,
'saturday_delivery' => 0,
'drop_off_at_postal_point' => 0,
'label_description' => 'Vliegtuig',
'delivery_type' => 2,
],
'general_settings' => [
'save_recipient_address' => 1,
'tracktrace' => [
'delivery_notification' => 0,
'send_track_trace_emails' => 0,
'email_on_handed_to_courier' => 1,
'carrier_email_basic_notification' => 1,
'bcc' => 0,
'from_address_email' => 'mark+testaccount@myparcel.nl',
'from_address_company' => 'Mark-test',
'bcc_email' => '',
],
],
'pickup' => null,
'customs_declaration' => null,
'physical_properties' => [
'weight' => 5000,
],
'created' => '2022-07-13 11:56:18',
'modified' => '2022-07-13 11:56:18',
'reference_identifier' => '',
'created_by' => 82444,
'modified_by' => 82444,
'transaction_status' => 'unpaid',
'drop_off_point' => [
'postal_code' => '2321 TD',
'location_name' => 'Instabox',
'city' => 'Leiden',
'street' => 'Telderskade',
'number' => '2',
'number_suffix' => 'H',
'cc' => 'NL',
'location_code' => 'ed14eb91-7374-4dcc-a41d-34c0d3e45c01',
],
'hidden' => 0,
'price' => [
'amount' => 1920,
'currency' => 'EUR',
],
'barcode' => '',
'region' => 'NL',
'external_provider' => null,
'external_provider_id' => null,
'payment_status' => 'unpaid',
'carrier_id' => 5,
'contract_id' => null,
'platform_id' => 1,
'origin' => 'backoffice_shipment_form',
'user_agent' => 'ShipmentForm/',
'secondary_shipments' => [],
'collection_contact' => null,
'multi_collo_main_shipment_id' => null,
'external_identifier' => null,
'delayed' => false,
'delivered' => false,
'link_consumer_portal' => null,
'partner_tracktraces' => [],
return [
'data' => [
'shipments' => [
[
'id' => 136510070,
'parent_id' => null,
'account_id' => 170402,
'shop_id' => 93683,
'shipment_type' => 1,
'recipient' => [
'cc' => 'NL',
'postal_code' => '7345AB',
'city' => 'Wenum Wiesel',
'street' => 'Wieselsedwarsweg',
'street_additional_info' => '',
'number' => '12',
'number_suffix' => 'c',
'person' => 'Epke Zonderland',
'email' => 'test@webshopje.nl',
'phone' => '0172765435',
],
'sender' => [
'phone' => '0606607834',
'company' => 'MyParcel',
'cc' => 'NL',
'postal_code' => '2132JE',
'number' => '31',
'street' => 'Antareslaan',
'city' => 'Hoofddorp',
'email' => 'mrparcel@myparcel.nl',
'street_additional_info' => '',
'person' => 'Mister Parcel',
'number_suffix' => '',
],
'status' => 1,
'options' => [
'package_type' => 1,
'collect' => 0,
'only_recipient' => 1,
'signature' => 0,
'return' => 1,
'insurance' => [
'amount' => 0,
'currency' => 'EUR',
],
'large_format' => 1,
'same_day_delivery' => 1,
'age_check' => 1,
'saturday_delivery' => 0,
'drop_off_at_postal_point' => 0,
'label_description' => 'Vliegtuig',
'delivery_type' => 2,
],
'general_settings' => [
'save_recipient_address' => 1,
'tracktrace' => [
'delivery_notification' => 0,
'send_track_trace_emails' => 0,
'email_on_handed_to_courier' => 1,
'carrier_email_basic_notification' => 1,
'bcc' => 0,
'from_address_email' => 'mark+testaccount@myparcel.nl',
'from_address_company' => 'Mark-test',
'bcc_email' => '',
],
],
'pickup' => null,
'customs_declaration' => null,
'physical_properties' => [
'weight' => 5000,
],
'created' => '2022-07-13 11:56:18',
'modified' => '2022-07-13 11:56:18',
'reference_identifier' => '',
'created_by' => 82444,
'modified_by' => 82444,
'transaction_status' => 'unpaid',
'drop_off_point' => [
'postal_code' => '2321 TD',
'location_name' => 'Instabox',
'city' => 'Leiden',
'street' => 'Telderskade',
'number' => '2',
'number_suffix' => 'H',
'cc' => 'NL',
'location_code' => 'ed14eb91-7374-4dcc-a41d-34c0d3e45c01',
],
'hidden' => 0,
'price' => [
'amount' => 1920,
'currency' => 'EUR',
],
'barcode' => '',
'region' => 'NL',
'external_provider' => null,
'external_provider_id' => null,
'payment_status' => 'unpaid',
'carrier_id' => 5,
'contract_id' => null,
'platform_id' => 1,
'origin' => 'backoffice_shipment_form',
'user_agent' => 'ShipmentForm/',
'secondary_shipments' => [],
'collection_contact' => null,
'multi_collo_main_shipment_id' => null,
'external_identifier' => null,
'delayed' => false,
'delivered' => false,
'link_consumer_portal' => null,
'partner_tracktraces' => [],
],
]
)
);
],
],
];
}
}