Skip to content

Commit 516f9d0

Browse files
committed
work in progress - coverage
1 parent 07337c1 commit 516f9d0

10 files changed

Lines changed: 25 additions & 38 deletions

File tree

README.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -35,30 +35,30 @@ Install ShipEngine via [Composer](https://getcomposer.org/):
3535
```bash
3636
composer require shipengine/shipengine
3737
```
38-
- The only configuration requirement is an [API key](https://www.shipengine.com/docs/auth/#api-keys).
38+
- The only configuration requirement is an [API Key](https://www.shipengine.com/docs/auth/#api-keys).
3939

40-
> The following example assumes that you have already set the `SHIPENGIEN_API_KEY` using `putenv()`.
40+
> The following example assumes that you have already set the `SHIPENGIEN_API_KEY` environment variable with your Api Key using `putenv()`.
4141
4242
Examples
4343
========
4444

4545
Methods
4646
-------
47-
- [validateAddress](./docs/addressValidateExample.md) - Indicates whether the provided address is valid. If the
47+
- [validateAddress](./docs/addressValidateExample.md "Validate Address method documentation") - Indicates whether the provided address is valid. If the
4848
address is valid, the method returns a normalized version of the address based on the standards of the country in
4949
which the address resides.
50-
- [normalizeAddress](./docs/normalizeAddressExample.md) - Returns a normalized, or standardized, version of the
50+
- [normalizeAddress](./docs/normalizeAddressExample.md "Normalize Address method documentation") - Returns a normalized, or standardized, version of the
5151
address. If the address cannot be normalized, an error is returned.
52-
- [trackPackage](./docs/trackPackageExample.md) - Track a package by `packageId` or by `carrierCode` and `trackingNumber`. This method returns
52+
- [trackPackage](./docs/trackPackageExample.md "Track Package method documentation") - Track a package by `packageId` or by `carrierCode` and `trackingNumber`. This method returns
5353
the all tracking events for a given shipment.
5454

5555
Class Objects
56-
--------------
56+
-------------
5757
- [ShipEngine]() - A configurable entry point to the ShipEngine API SDK, this class provides convenience methods
5858
for various ShipEngine API Services.
5959

6060
Instantiate ShipEngine Class
61-
------------------------------
61+
----------------------------
6262
```php
6363
<?php declare(strict_types=1);
6464

src/Model/Carriers/CarrierAccount.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,6 @@ public function __construct(array $accountInformation)
5151
$this->setCarrierAccount($accountInformation);
5252
$this->accountId = $accountInformation['accountID'];
5353
$this->accountNumber = $accountInformation['accountNumber'];
54-
$this->name = $accountInformation['name'];
5554
}
5655

5756
/**

src/Model/Package/TrackPackageResult.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ final class TrackPackageResult implements \JsonSerializable
3535
public ?array $events = array();
3636

3737
/**
38-
* This is the latest event to have occurred in the `$events` array.
38+
* Returns the latest event to have occurred in the `$events` array.
3939
*
4040
* @return TrackingEvent
4141
*/
@@ -45,30 +45,30 @@ public function getLatestEvent(): TrackingEvent
4545
}
4646

4747
/**
48-
* Returns `true` if there are any EXCEPTION events.
48+
* Returns `true` if there are any exception events.
4949
*
5050
* @return bool
5151
*/
5252
public function hasErrors(): bool
5353
{
5454
foreach ($this->events as $event) {
55-
if ($event->status === 'EXCEPTION') {
55+
if ($event->status === 'exception') {
5656
return true;
5757
}
5858
}
5959
return false;
6060
}
6161

6262
/**
63-
* Returns **only** the EXCEPTION events.
63+
* Returns **only** the exception events.
6464
*
6565
* @return array
6666
*/
6767
public function getErrors(): array
6868
{
6969
$errors = array();
7070
foreach ($this->events as $event) {
71-
if ($event->status === 'EXCEPTION') {
71+
if ($event->status === 'exception') {
7272
$errors[] = $event;
7373
}
7474
}

src/ShipEngine.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -104,9 +104,10 @@ public function normalizeAddress(Address $address, $config = null): Address
104104
}
105105

106106
/**
107+
* Fetch the carrier accounts connected to your ShipEngine Account.
108+
*
107109
* @param array|ShipEngineConfig|null $config Optional configuration overrides for this method call {apiKey:string,
108110
* baseUrl:string, pageSize:int, retries:int, timeout:int, client:HttpClient|null}
109-
*
110111
* @param string|null $carrierCode
111112
* @return array An array of **CarrierAccount** objects that correspond the to carrier accounts connected
112113
* to a given ShipEngine account.
@@ -120,7 +121,7 @@ public function getCarrierAccounts(?string $carrierCode = null, $config = null):
120121

121122
/**
122123
* Track a package by `trackingNumber` and `carrierCode` via the **TrackingQuery** object, by using just the
123-
* **packageId**, or by using a **Package** object.
124+
* **packageId**.
124125
*
125126
* @param array|ShipEngineConfig|null $config Optional configuration overrides for this method call {apiKey:string,
126127
* baseUrl:string, pageSize:int, retries:int, timeout:int, client:HttpClient|null}

src/Util/Assert.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -60,14 +60,14 @@ public function tooManyAddressLines(array $street): void
6060
}
6161

6262
/**
63-
* Asserts that city in not an empty string and is valid characters.
63+
* Asserts that city in not an empty string and contains valid characters.
6464
*
6565
* @param string $cityLocality
6666
* @throws ValidationException
6767
*/
6868
public function isCityValid(string $cityLocality): void
6969
{
70-
if (preg_match('/^[a-zA-Z0-9\s\W]*$/', $cityLocality) === false || $cityLocality === '') {
70+
if (preg_match('/^[a-zA-Z0-9\s]*$/', $cityLocality) === false || $cityLocality === '') {
7171
throw new ValidationException(
7272
'Invalid address. Either the postal code or the city/locality and state/province must be specified.',
7373
null,
@@ -86,7 +86,7 @@ public function isCityValid(string $cityLocality): void
8686
*/
8787
public function isStateValid(string $stateProvince): void
8888
{
89-
if (preg_match('/^[A-Z\W]{2}$/', $stateProvince) === false || $stateProvince === '') {
89+
if (preg_match('/^[A-Z]{2}$/', $stateProvince) === false || $stateProvince === '') {
9090
throw new ValidationException(
9191
'Invalid address. Either the postal code or the city/locality and state/province must be specified.',
9292
null,
@@ -264,7 +264,7 @@ public function isPackageIdValid(string $packageId): void
264264
$this->isPackageIdPrefixValid($packageId);
265265

266266
if (preg_match(
267-
'/^pkg_[123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz]+$/',
267+
'/^pkg_[1-9a-zA-Z]+$/',
268268
$packageId
269269
) === 0
270270
) {

src/Util/Constants/CarrierNames.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
final class CarrierNames
1313
{
1414
/**
15-
* Common name for FEDEX = FedEx
15+
* Common name for FEDEX - FedEx
1616
*/
1717
public const FEDEX = 'FedEx';
1818

tests/Message/Events/ResponseReceivedEventTest.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
use Mockery;
88
use Mockery\Adapter\Phpunit\MockeryTestCase;
99
use Psr\Http\Client\ClientExceptionInterface;
10-
use ShipEngine\Message\Events\RequestSentEvent;
1110
use ShipEngine\Message\Events\ResponseReceivedEvent;
1211
use ShipEngine\Message\ShipEngineException;
1312
use ShipEngine\Model\Address\Address;

tests/Service/Address/AddressServiceTest.php

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,7 @@ public function testAddressUnknownType(): void
202202
{
203203
$unknown_address_type = new Address(
204204
array(
205-
'street' => array('4 Jersey St', 'validate-unknown-address'),
205+
'street' => array('4 Jersey St', 'unknown'),
206206
'cityLocality' => 'Boston',
207207
'stateProvince' => 'MA',
208208
'postalCode' => '02215',
@@ -838,18 +838,6 @@ public function testNoNameCompanyPhone(): void
838838
$this->assertEquals($goodAddress->stateProvince, $validation->normalizedAddress->stateProvince);
839839
$this->assertEquals($goodAddress->postalCode, $validation->normalizedAddress->postalCode);
840840
$this->assertEquals($goodAddress->countryCode, $validation->normalizedAddress->countryCode);
841-
// $this->assertFalse(
842-
//array_key_exists($validation->normalizedAddress->name,
843-
// $validation->normalizedAddress)
844-
//);
845-
// $this->assertFalse(
846-
//array_key_exists($validation->normalizedAddress->phone,
847-
// $validation->normalizedAddress)
848-
//);
849-
// $this->assertFalse(
850-
//array_key_exists($validation->normalizedAddress['company'],
851-
// $validation->normalizedAddress)
852-
//);
853841
}
854842

855843
public function testWithNameCompanyPhone(): void

tests/Service/Carriers/CarrierAccountServiceTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ public function testFetchWithMultipleAccountsOfSameCarrier(): void
9090
$this->assertEquals('ups', $carrier_accounts[0]->carrier->code);
9191
$this->assertEquals('fedex', $carrier_accounts[1]->carrier->code);
9292
$this->assertEquals('fedex', $carrier_accounts[2]->carrier->code);
93-
$this->assertNotEquals($carrier_accounts[1]->name, $carrier_accounts[2]->name);
93+
$this->assertNotEquals($carrier_accounts[0]->name, $carrier_accounts[1]->name);
9494
foreach ($carrier_accounts as $account) {
9595
$this->assertInstanceOf(CarrierAccount::class, $account);
9696
$this->assertStringStartsWith('car_', $account->accountId);

tests/Service/Package/TrackPackageServiceTest.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -251,7 +251,7 @@ public function testOutForDeliveryTrackingEvent(): void
251251
$this->assertEquals('in_transit', $trackingResult->events[1]->status);
252252
}
253253

254-
public function testDevliveredFirstTryTrackingEvent(): void
254+
public function testDeliveredFirstTryTrackingEvent(): void
255255
{
256256
$shipengine = new ShipEngine(
257257
array(
@@ -302,7 +302,7 @@ public function testMultipleDeliveryAttemptEvents(): void
302302
$this->assertEquals('delivered', $trackingResult->events[8]->status);
303303
}
304304

305-
public function testDeliveryWithSignuatureTrackingEvent(): void
305+
public function testDeliveryWithSignatureTrackingEvent(): void
306306
{
307307
$shipengine = new ShipEngine(
308308
array(
@@ -380,7 +380,7 @@ public function testDeliveredAfterExceptionTrackingEvent(): void
380380
);
381381
}
382382

383-
public function testSignleExceptionTrackingEvent(): void
383+
public function testSingleExceptionTrackingEvent(): void
384384
{
385385
$shipengine = new ShipEngine(
386386
array(

0 commit comments

Comments
 (0)