From 820f4a76875c2fcae64012abc180d91710c297e1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=C3=A1=C5=A1=20Novotn=C3=BD?= Date: Sat, 7 Sep 2019 23:03:52 +0200 Subject: [PATCH] Reformat code --- tests/Unit/Balikobot/GetAdrUnitsTest.php | 8 ++--- .../Balikobot/GetBranchesForLocationTest.php | 4 +-- tests/Unit/Balikobot/GetBranchesTest.php | 4 +-- tests/Unit/Balikobot/GetLabelsTest.php | 2 +- .../Balikobot/GetManipulationUnitsTest.php | 8 ++--- tests/Unit/Balikobot/OrderB2AShipmentTest.php | 16 ++++----- tests/Unit/BranchTest.php | 6 ++-- .../Client/Requests/AdrUnitsRequestTest.php | 8 ++--- .../Requests/BranchLocatorRequestTest.php | 8 ++--- .../Client/Requests/BranchesRequestTest.php | 8 ++--- .../Client/Requests/LabelsRequestTest.php | 2 +- .../Requests/ManipulationUnitsRequestTest.php | 6 ++-- .../Unit/Client/Requests/TrackRequestTest.php | 2 +- tests/Unit/OrderedPackageTest.php | 36 +++++++++++++------ tests/Unit/OrderedShipmentTest.php | 20 +++++------ 15 files changed, 77 insertions(+), 61 deletions(-) diff --git a/tests/Unit/Balikobot/GetAdrUnitsTest.php b/tests/Unit/Balikobot/GetAdrUnitsTest.php index a0ac556..ec65980 100644 --- a/tests/Unit/Balikobot/GetAdrUnitsTest.php +++ b/tests/Unit/Balikobot/GetAdrUnitsTest.php @@ -35,12 +35,12 @@ public function testResponseData() 'units' => [ [ 'code' => 1, - 'name' => "KM", + 'name' => 'KM', 'attr' => 4, ], [ 'code' => 876, - 'name' => "M", + 'name' => 'M', ], ], ]); @@ -51,8 +51,8 @@ public function testResponseData() $this->assertEquals( [ - 1 => "KM", - 876 => "M", + 1 => 'KM', + 876 => 'M', ], $units ); diff --git a/tests/Unit/Balikobot/GetBranchesForLocationTest.php b/tests/Unit/Balikobot/GetBranchesForLocationTest.php index 915b905..8b027a9 100644 --- a/tests/Unit/Balikobot/GetBranchesForLocationTest.php +++ b/tests/Unit/Balikobot/GetBranchesForLocationTest.php @@ -83,11 +83,11 @@ public function testResponseData() 'branches' => [ [ 'id' => 1, - 'zip' => "11000", + 'zip' => '11000', ], [ 'id' => 876, - 'zip' => "12000", + 'zip' => '12000', ], ], ]); diff --git a/tests/Unit/Balikobot/GetBranchesTest.php b/tests/Unit/Balikobot/GetBranchesTest.php index c630102..efd0a34 100644 --- a/tests/Unit/Balikobot/GetBranchesTest.php +++ b/tests/Unit/Balikobot/GetBranchesTest.php @@ -150,11 +150,11 @@ public function testResponseData() 'branches' => [ [ 'id' => 1, - 'zip' => "11000", + 'zip' => '11000', ], [ 'id' => 876, - 'zip' => "12000", + 'zip' => '12000', ], ], ]); diff --git a/tests/Unit/Balikobot/GetLabelsTest.php b/tests/Unit/Balikobot/GetLabelsTest.php index 8171287..2af26ee 100644 --- a/tests/Unit/Balikobot/GetLabelsTest.php +++ b/tests/Unit/Balikobot/GetLabelsTest.php @@ -12,7 +12,7 @@ public function testMakeRequest() { $requester = $this->newRequesterWithMockedRequestMethod(200, [ 'status' => 200, - 'labels_url' => "http://pdf.balikobot.cz/dpd/eNorMdY1NFwwXDAELgE2", + 'labels_url' => 'http://pdf.balikobot.cz/dpd/eNorMdY1NFwwXDAELgE2', ]); $service = new Balikobot($requester); diff --git a/tests/Unit/Balikobot/GetManipulationUnitsTest.php b/tests/Unit/Balikobot/GetManipulationUnitsTest.php index 6d6e990..3950fb6 100644 --- a/tests/Unit/Balikobot/GetManipulationUnitsTest.php +++ b/tests/Unit/Balikobot/GetManipulationUnitsTest.php @@ -35,12 +35,12 @@ public function testResponseData() 'units' => [ [ 'code' => 1, - 'name' => "KM", + 'name' => 'KM', 'attr' => 4, ], [ 'code' => 876, - 'name' => "M", + 'name' => 'M', ], ], ]); @@ -51,8 +51,8 @@ public function testResponseData() $this->assertEquals( [ - 1 => "KM", - 876 => "M", + 1 => 'KM', + 876 => 'M', ], $units ); diff --git a/tests/Unit/Balikobot/OrderB2AShipmentTest.php b/tests/Unit/Balikobot/OrderB2AShipmentTest.php index ce5285c..d1af902 100644 --- a/tests/Unit/Balikobot/OrderB2AShipmentTest.php +++ b/tests/Unit/Balikobot/OrderB2AShipmentTest.php @@ -15,8 +15,8 @@ public function testMakeRequest() 0 => [ 'carrier_id' => 'NP1504102246M', 'package_id' => 21, - 'track_url' => 'https://www.geis-group.cz/cs/sledovani-zasilky/?p=NP1504102246M"', - 'status_message' => 'OK, přeprava byla objednána."', + 'track_url' => 'https://www.geis-group.cz/cs/sledovani-zasilky/?p=NP1504102246M', + 'status_message' => 'OK, přeprava byla objednána.', 'status' => '200', ], ]); @@ -61,15 +61,15 @@ public function testResponseData() 0 => [ 'carrier_id' => 'NP1504102246M', 'package_id' => 21, - 'track_url' => 'https://www.geis-group.cz/cs/sledovani-zasilky/?p=NP1504102246M"', - 'status_message' => 'OK, přeprava byla objednána."', + 'track_url' => 'https://www.geis-group.cz/cs/sledovani-zasilky/?p=NP1504102246M', + 'status_message' => 'OK, přeprava byla objednána.', 'status' => '200', ], 1 => [ 'carrier_id' => 'NP1504102247M', 'package_id' => 22, - 'track_url' => 'https://www.geis-group.cz/cs/sledovani-zasilky/?p=NP1504102247M"', - 'status_message' => 'OK, přeprava byla objednána."', + 'track_url' => 'https://www.geis-group.cz/cs/sledovani-zasilky/?p=NP1504102247M', + 'status_message' => 'OK, přeprava byla objednána.', 'status' => '200', ], ]); @@ -92,12 +92,12 @@ public function testResponseDataWithoutCarrierId() 'status' => 200, 0 => [ 'package_id' => 21, - 'status_message' => 'OK, přeprava byla objednána."', + 'status_message' => 'OK, přeprava byla objednána.', 'status' => '200', ], 1 => [ 'package_id' => 22, - 'status_message' => 'OK, přeprava byla objednána."', + 'status_message' => 'OK, přeprava byla objednána.', 'status' => '200', ], ]); diff --git a/tests/Unit/BranchTest.php b/tests/Unit/BranchTest.php index 96caa84..9aee57f 100644 --- a/tests/Unit/BranchTest.php +++ b/tests/Unit/BranchTest.php @@ -11,9 +11,9 @@ public function testStaticConstructor() { $branch = Branch::newInstanceFromData('cp', 'NP', [ 'id' => '1234', - 'type' => "type", - 'name' => "name", - 'city' => "city", + 'type' => 'type', + 'name' => 'name', + 'city' => 'city', 'street' => 'street', 'zip' => 'zip', 'country' => 'country', diff --git a/tests/Unit/Client/Requests/AdrUnitsRequestTest.php b/tests/Unit/Client/Requests/AdrUnitsRequestTest.php index 51c237d..e4be8f4 100644 --- a/tests/Unit/Client/Requests/AdrUnitsRequestTest.php +++ b/tests/Unit/Client/Requests/AdrUnitsRequestTest.php @@ -85,12 +85,12 @@ public function testOnlyUnitsDataAreReturned() 'units' => [ [ 'code' => 1, - 'name' => "KM", + 'name' => 'KM', 'attr' => 4, ], [ 'code' => 876, - 'name' => "M", + 'name' => 'M', ], ], ]); @@ -101,8 +101,8 @@ public function testOnlyUnitsDataAreReturned() $this->assertEquals( [ - 1 => "KM", - 876 => "M", + 1 => 'KM', + 876 => 'M', ], $units ); diff --git a/tests/Unit/Client/Requests/BranchLocatorRequestTest.php b/tests/Unit/Client/Requests/BranchLocatorRequestTest.php index b345dec..2be74e9 100644 --- a/tests/Unit/Client/Requests/BranchLocatorRequestTest.php +++ b/tests/Unit/Client/Requests/BranchLocatorRequestTest.php @@ -94,11 +94,11 @@ public function testOnlyBranchesDataAreReturned() 'branches' => [ [ 'code' => 1, - 'name' => "AAA", + 'name' => 'AAA', ], [ 'code' => 876, - 'name' => "BBB", + 'name' => 'BBB', ], ], ]); @@ -111,11 +111,11 @@ public function testOnlyBranchesDataAreReturned() [ [ 'code' => 1, - 'name' => "AAA", + 'name' => 'AAA', ], [ 'code' => 876, - 'name' => "BBB", + 'name' => 'BBB', ], ], $branches diff --git a/tests/Unit/Client/Requests/BranchesRequestTest.php b/tests/Unit/Client/Requests/BranchesRequestTest.php index 4d703b1..cc734e8 100644 --- a/tests/Unit/Client/Requests/BranchesRequestTest.php +++ b/tests/Unit/Client/Requests/BranchesRequestTest.php @@ -123,11 +123,11 @@ public function testOnlyBranchesDataAreReturned() 'branches' => [ [ 'code' => 1, - 'name' => "AAA", + 'name' => 'AAA', ], [ 'code' => 876, - 'name' => "BBB", + 'name' => 'BBB', ], ], ]); @@ -140,11 +140,11 @@ public function testOnlyBranchesDataAreReturned() [ [ 'code' => 1, - 'name' => "AAA", + 'name' => 'AAA', ], [ 'code' => 876, - 'name' => "BBB", + 'name' => 'BBB', ], ], $branches diff --git a/tests/Unit/Client/Requests/LabelsRequestTest.php b/tests/Unit/Client/Requests/LabelsRequestTest.php index d71bd42..5071840 100644 --- a/tests/Unit/Client/Requests/LabelsRequestTest.php +++ b/tests/Unit/Client/Requests/LabelsRequestTest.php @@ -49,7 +49,7 @@ public function testMakeRequest() { $requester = $this->newRequesterWithMockedRequestMethod(200, [ 'status' => 200, - 'labels_url' => "http://pdf.balikobot.cz/dpd/eNorMdY1NFwwXDAELgE2", + 'labels_url' => 'http://pdf.balikobot.cz/dpd/eNorMdY1NFwwXDAELgE2', ]); $client = new Client($requester); diff --git a/tests/Unit/Client/Requests/ManipulationUnitsRequestTest.php b/tests/Unit/Client/Requests/ManipulationUnitsRequestTest.php index 724bded..7d75e17 100644 --- a/tests/Unit/Client/Requests/ManipulationUnitsRequestTest.php +++ b/tests/Unit/Client/Requests/ManipulationUnitsRequestTest.php @@ -85,12 +85,12 @@ public function testOnlyUnitsDataAreReturned() 'units' => [ [ 'code' => 1, - 'name' => "KM", + 'name' => 'KM', 'attr' => 4, ], [ 'code' => 876, - 'name' => "M", + 'name' => 'M', ], ], ]); @@ -99,6 +99,6 @@ public function testOnlyUnitsDataAreReturned() $units = $client->getManipulationUnits('cp'); - $this->assertEquals([1 => "KM", 876 => "M"], $units); + $this->assertEquals([1 => 'KM', 876 => 'M'], $units); } } diff --git a/tests/Unit/Client/Requests/TrackRequestTest.php b/tests/Unit/Client/Requests/TrackRequestTest.php index ae208d8..b1e2961 100644 --- a/tests/Unit/Client/Requests/TrackRequestTest.php +++ b/tests/Unit/Client/Requests/TrackRequestTest.php @@ -33,7 +33,7 @@ public function testRequestShouldHaveStatus() [ 'date' => '2018-07-02 00:00:00', 'status_id' => 1, - 'name' => '"Doručování zásilky. 10003 Depo Praha 701', + 'name' => 'Doručování zásilky. 10003 Depo Praha 701', ], ], ]); diff --git a/tests/Unit/OrderedPackageTest.php b/tests/Unit/OrderedPackageTest.php index 55e59b6..d38b9da 100644 --- a/tests/Unit/OrderedPackageTest.php +++ b/tests/Unit/OrderedPackageTest.php @@ -11,9 +11,9 @@ public function testStaticConstructor() { $orderedPackage = OrderedPackage::newInstanceFromData('cp', '0001', [ 'package_id' => 1234, - 'carrier_id' => "02IID", - 'track_url' => "/track", - 'label_url' => "/labels", + 'carrier_id' => '02IID', + 'track_url' => '/track', + 'label_url' => '/labels', 'carrier_id_swap' => 23, 'pieces' => [1, 2], ]); @@ -21,9 +21,9 @@ public function testStaticConstructor() $this->assertEquals('cp', $orderedPackage->getShipper()); $this->assertEquals('0001', $orderedPackage->getBatchId()); $this->assertEquals(1234, $orderedPackage->getPackageId()); - $this->assertEquals("02IID", $orderedPackage->getCarrierId()); - $this->assertEquals("/track", $orderedPackage->getTrackUrl()); - $this->assertEquals("/labels", $orderedPackage->getLabelUrl()); + $this->assertEquals('02IID', $orderedPackage->getCarrierId()); + $this->assertEquals('/track', $orderedPackage->getTrackUrl()); + $this->assertEquals('/labels', $orderedPackage->getLabelUrl()); $this->assertEquals(23, $orderedPackage->getCarrierIdSwap()); $this->assertEquals([1, 2], $orderedPackage->getPieces()); } @@ -32,16 +32,32 @@ public function testStaticConstructorWithMissingData() { $orderedPackage = OrderedPackage::newInstanceFromData('cp', '0001', [ 'package_id' => 1234, - 'carrier_id' => "02IID", - 'label_url' => "/labels", + 'carrier_id' => '02IID', + 'label_url' => '/labels', ]); $this->assertEquals('cp', $orderedPackage->getShipper()); $this->assertEquals('0001', $orderedPackage->getBatchId()); $this->assertEquals(1234, $orderedPackage->getPackageId()); - $this->assertEquals("02IID", $orderedPackage->getCarrierId()); + $this->assertEquals('02IID', $orderedPackage->getCarrierId()); $this->assertEquals(null, $orderedPackage->getTrackUrl()); - $this->assertEquals("/labels", $orderedPackage->getLabelUrl()); + $this->assertEquals('/labels', $orderedPackage->getLabelUrl()); + $this->assertEquals(null, $orderedPackage->getCarrierIdSwap()); + $this->assertEquals([], $orderedPackage->getPieces()); + } + + public function testStaticConstructorWithMissingCarrierId() + { + $orderedPackage = OrderedPackage::newInstanceFromData('cp', '0001', [ + 'package_id' => 1234, + ]); + + $this->assertEquals('cp', $orderedPackage->getShipper()); + $this->assertEquals('0001', $orderedPackage->getBatchId()); + $this->assertEquals(1234, $orderedPackage->getPackageId()); + $this->assertEquals('', $orderedPackage->getCarrierId()); + $this->assertEquals(null, $orderedPackage->getTrackUrl()); + $this->assertEquals(null, $orderedPackage->getLabelUrl()); $this->assertEquals(null, $orderedPackage->getCarrierIdSwap()); $this->assertEquals([], $orderedPackage->getPieces()); } diff --git a/tests/Unit/OrderedShipmentTest.php b/tests/Unit/OrderedShipmentTest.php index 405965c..d8afab3 100644 --- a/tests/Unit/OrderedShipmentTest.php +++ b/tests/Unit/OrderedShipmentTest.php @@ -15,18 +15,18 @@ public function testStaticConstructor() [1, 67], [ 'order_id' => 1234, - 'handover_url' => "/handover", - 'labels_url' => "/labels", - 'file_url' => "/file", + 'handover_url' => '/handover', + 'labels_url' => '/labels', + 'file_url' => '/file', ], new DateTime('2018-10-10 14:00:00') ); $this->assertEquals('cp', $orderedShipment->getShipper()); $this->assertEquals(1234, $orderedShipment->getOrderId()); - $this->assertEquals("/handover", $orderedShipment->getHandoverUrl()); - $this->assertEquals("/labels", $orderedShipment->getLabelsUrl()); - $this->assertEquals("/file", $orderedShipment->getFileUrl()); + $this->assertEquals('/handover', $orderedShipment->getHandoverUrl()); + $this->assertEquals('/labels', $orderedShipment->getLabelsUrl()); + $this->assertEquals('/file', $orderedShipment->getFileUrl()); $this->assertEquals([1, 67], $orderedShipment->getPackageIds()); $this->assertEquals(new \DateTime('2018-10-10 14:00:00'), $orderedShipment->getDate()); } @@ -38,15 +38,15 @@ public function testStaticConstructorWithMissingData() [1, 67], [ 'order_id' => 1234, - 'handover_url' => "/handover", - 'labels_url' => "/labels", + 'handover_url' => '/handover', + 'labels_url' => '/labels', ] ); $this->assertEquals('cp', $orderedShipment->getShipper()); $this->assertEquals(1234, $orderedShipment->getOrderId()); - $this->assertEquals("/handover", $orderedShipment->getHandoverUrl()); - $this->assertEquals("/labels", $orderedShipment->getLabelsUrl()); + $this->assertEquals('/handover', $orderedShipment->getHandoverUrl()); + $this->assertEquals('/labels', $orderedShipment->getLabelsUrl()); $this->assertEquals(null, $orderedShipment->getFileUrl()); $this->assertEquals([1, 67], $orderedShipment->getPackageIds()); $this->assertEquals(null, $orderedShipment->getDate());