Skip to content
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"myclabs/php-enum": "^1.5",
"php-http/discovery": "^1.5",
"php-http/httplug": ">=1.1",
"psr/http-message": "^1.0",
"psr/http-message": "^1.0 || ^2.0",
"psr/simple-cache": "^1.0",
"symfony/cache": ">=5.0",
"setasign/fpdf": "^1.8",
Expand Down
18 changes: 9 additions & 9 deletions src/Resources/Proxy/FileStreamProxy.php
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ public function detach()
*
* @return int|null Returns the size in bytes if known, or null if unknown.
*/
public function getSize()
public function getSize(): ?int
{
return $this->getStream()->getSize();
}
Expand All @@ -90,7 +90,7 @@ public function getSize()
* @return int Position of the file pointer
* @throws \RuntimeException on error.
*/
public function tell()
public function tell(): int
{
return $this->getStream()->tell();
}
Expand Down Expand Up @@ -123,9 +123,9 @@ public function isSeekable(): bool
* SEEK_END: Set position to end-of-stream plus offset.
* @throws \RuntimeException on failure.
*/
public function seek($offset, $whence = SEEK_SET)
public function seek($offset, $whence = SEEK_SET): void
{
return $this->getStream()->seek($offset, $whence);
$this->getStream()->seek($offset, $whence);
}

/**
Expand All @@ -138,9 +138,9 @@ public function seek($offset, $whence = SEEK_SET)
* @link http://www.php.net/manual/en/function.fseek.php
* @see seek()
*/
public function rewind()
public function rewind(): void
{
return $this->getStream()->rewind();
$this->getStream()->rewind();
}

/**
Expand All @@ -158,7 +158,7 @@ public function isWritable(): bool
* @return int Returns the number of bytes written to the stream.
* @throws \RuntimeException on failure.
*/
public function write($string)
public function write($string): int
{
return $this->getStream()->write($string);
}
Expand All @@ -181,7 +181,7 @@ public function isReadable(): bool
* if no bytes are available.
* @throws \RuntimeException if an error occurs.
*/
public function read($length)
public function read($length): string
{
return $this->getStream()->read($length);
}
Expand All @@ -193,7 +193,7 @@ public function read($length)
* @throws \RuntimeException if unable to read or an error occurs while
* reading.
*/
public function getContents()
public function getContents(): string
{
return $this->getStream()->getContents();
}
Expand Down
8 changes: 4 additions & 4 deletions src/Resources/Shipment.php
Original file line number Diff line number Diff line change
Expand Up @@ -171,10 +171,10 @@ public function getData(): array
$data = $this->jsonSerialize();

// Remove read-only relationships.
unset($data['relationships']['colli']);
unset($data['relationships']['files']);
unset($data['relationships']['shipment_status']);
unset($data['relationships']['shipment_surcharges']);
unset($data['relationships'][self::RELATIONSHIP_COLLI]);
unset($data['relationships'][self::RELATIONSHIP_FILES]);
unset($data['relationships'][self::RELATIONSHIP_STATUS]);
unset($data['relationships'][self::RELATIONSHIP_SHIPMENT_SURCHARGES]);

return $data;
}
Expand Down
8 changes: 6 additions & 2 deletions tests/Unit/Authentication/ClientCredentialsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
use Psr\Http\Client\ClientInterface;
use Psr\Http\Message\RequestInterface;
use Psr\Http\Message\ResponseInterface;
use Psr\Http\Message\StreamInterface;

class ClientCredentialsTest extends TestCase
{
Expand Down Expand Up @@ -41,11 +42,14 @@ protected function setUp(): void
->getMock();
$this->response->method('getBody')
->willReturnCallback(function () {
return json_encode([
$streamMock = $this->createMock(StreamInterface::class);
$streamMock->method('__toString')->willReturn(json_encode([
'token_type' => 'Bearer',
'expires_in' => 86400,
'access_token' => 'an-access-token-for-the-myparcelcom-api-' . $this->tokenSuffix,
]);
]));

return $streamMock;
});
$this->response->method('getStatusCode')
->willReturn(200);
Expand Down
5 changes: 4 additions & 1 deletion tests/Unit/Collection/RequestCollectionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
use MyParcelCom\ApiSdk\Resources\Interfaces\ResourceInterface;
use PHPUnit\Framework\TestCase;
use Psr\Http\Message\ResponseInterface;
use Psr\Http\Message\StreamInterface;

class RequestCollectionTest extends TestCase
{
Expand All @@ -29,8 +30,10 @@ protected function setUp(): void
$this->pageNumber = $pageNumber;
$this->pageSize = $pageSize;

$streamMock = $this->createMock(StreamInterface::class);
$streamMock->method('__toString')->willReturn('{"data": "something something", "meta": {"total_records": 123}}');
$response = $this->createMock(ResponseInterface::class);
$response->method('getBody')->willReturn('{"data": "something something", "meta": {"total_records": 123}}');
$response->method('getBody')->willReturn($streamMock);

return $response;
};
Expand Down