Skip to content

Commit

Permalink
More tests
Browse files Browse the repository at this point in the history
  • Loading branch information
tomas-novotny committed Jul 22, 2022
1 parent e583b61 commit daa56c4
Show file tree
Hide file tree
Showing 18 changed files with 1,298 additions and 1,734 deletions.
2 changes: 1 addition & 1 deletion src/Model/BasePerCarrierCollection.php
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ private function validateCarrier(WithCarrierId $item): void
return;
}

if ($this->carrier !== $item->getCarrier()) {
if ($this->carrier->getValue() !== $item->getCarrier()->getValue()) {
throw new InvalidArgumentException(
sprintf(
'Item carrier mismatch ("%s" instead "%s")',
Expand Down
12 changes: 11 additions & 1 deletion src/Model/Status/Statuses.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ final class Statuses extends BaseCollection implements WithCarrierId
public function __construct(
private Carrier $carrier,
private string $carrierId,
array $states,
array $states = [],
) {
parent::__construct([]);

Expand Down Expand Up @@ -49,6 +49,16 @@ public function offsetAdd(mixed $value): void
*/
private function validateCarrierId(Status $item): void
{
if ($this->carrier->getValue() !== $item->getCarrier()->getValue()) {
throw new InvalidArgumentException(
sprintf(
'Item carrier mismatch ("%s" instead "%s")',
$item->getCarrier()->getValue(),
$this->carrier->getValue(),
)
);
}

if ($this->carrierId !== $item->getCarrierId()) {
throw new InvalidArgumentException(
sprintf(
Expand Down
3 changes: 3 additions & 0 deletions src/Service/DefaultSettingService.php
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,9 @@ public function getCountriesData(): CountryCollection
return $this->countryFactory->createCollection($response);
}

/**
* @return \Iterator<\Inspirum\Balikobot\Model\ZipCode\ZipCode>
*/
public function getZipCodes(Carrier $carrier, Service $service, ?string $country = null): Iterator
{
$response = $this->client->call(VersionType::V2V1, $carrier, Request::ZIP_CODES, path: sprintf('%s/%s', $service->getValue(), $country));
Expand Down
8 changes: 4 additions & 4 deletions src/Service/DefaultTrackService.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,11 @@
use Inspirum\Balikobot\Model\Status\StatusesCollection;
use OutOfBoundsException;

class DefaultTrackService implements TrackService
final class DefaultTrackService implements TrackService
{
public function __construct(
private Client $client,
private StatusFactory $packageStatusFactory,
private StatusFactory $statusFactory,
) {
}

Expand Down Expand Up @@ -51,7 +51,7 @@ public function trackPackagesByIds(Carrier $carrier, array $carrierIds): Statuse
shouldHaveStatus: false,
);

return $this->packageStatusFactory->createCollection($carrier, $carrierIds, $response);
return $this->statusFactory->createCollection($carrier, $carrierIds, $response);
}

public function trackPackageLastStatus(Package $package): Status
Expand Down Expand Up @@ -80,6 +80,6 @@ public function trackPackagesLastStatusesByIds(Carrier $carrier, array $carrierI
shouldHaveStatus: false,
);

return $this->packageStatusFactory->createLastStatusCollection($carrier, $carrierIds, $response);
return $this->statusFactory->createLastStatusCollection($carrier, $carrierIds, $response);
}
}
135 changes: 0 additions & 135 deletions tests/Unit/Balikobot/TrackPackagesLastStatusMethodTest.php

This file was deleted.

Loading

0 comments on commit daa56c4

Please sign in to comment.