diff --git a/tests/Dummy/StringStream.php b/tests/Dummy/StringStream.php new file mode 100644 index 00000000..6219f0a3 --- /dev/null +++ b/tests/Dummy/StringStream.php @@ -0,0 +1,81 @@ +value = $value; + } + + public function __toString(): string + { + return $this->value; + } + + public function close(): void + { + } + + public function detach() + { + } + + public function getSize(): ?int + { + } + + public function tell(): int + { + } + + public function eof(): bool + { + } + + public function isSeekable(): bool + { + } + + public function seek(int $offset, int $whence = SEEK_SET): void + { + } + + public function rewind(): void + { + } + + public function isWritable(): bool + { + } + + public function write(string $string): int + { + } + + public function isReadable(): bool + { + } + + public function read(int $length): string + { + } + + public function getContents(): string + { + } + + public function getMetadata(?string $key = null) + { + } +} \ No newline at end of file diff --git a/tests/UnitTests/Secure/Provider/OAuthProviderTest.php b/tests/UnitTests/Secure/Provider/OAuthProviderTest.php index 29def3e2..71a90efa 100644 --- a/tests/UnitTests/Secure/Provider/OAuthProviderTest.php +++ b/tests/UnitTests/Secure/Provider/OAuthProviderTest.php @@ -2,6 +2,7 @@ namespace PhpTwinfield\Secure\Provider; +use Dummy\StringStream; use GuzzleHttp\ClientInterface; use League\OAuth2\Client\Provider\Exception\IdentityProviderException; use League\OAuth2\Client\Token\AccessToken; @@ -77,7 +78,7 @@ public function testGetAccessToken() $response = $this->createMock(ResponseInterface::class); $response->expects($this->any()) ->method("getBody") - ->willReturn('{"access_token":"mock_access_token", "token_type":"bearer"}'); + ->willReturn(new StringStream('{"access_token":"mock_access_token", "token_type":"bearer"}')); $response->expects($this->any()) ->method("getHeader") ->willReturn(['content-type' => 'json']); @@ -102,7 +103,7 @@ public function testExceptionThrownWhenErrorObjectReceived() $response = $this->createMock(ResponseInterface::class); $response->expects($this->any()) ->method("getBody") - ->willReturn('{"error":{"type":"request","message":"someErrorMessage"}}'); + ->willReturn(new StringStream('{"error":{"type":"request","message":"someErrorMessage"}}')); $response->expects($this->any()) ->method("getHeader") ->willReturn(['content-type' => 'json']); @@ -125,7 +126,7 @@ public function testGetResourceOwnerDetails() $response = $this->createMock(ResponseInterface::class); $response->expects($this->any()) ->method("getBody") - ->willReturn('{"sub": "someId", "twf.organisationId": "someOrganisationId"}'); + ->willReturn(new StringStream('{"sub": "someId", "twf.organisationId": "someOrganisationId"}')); $response->expects($this->any()) ->method("getHeader") ->willReturn(['content-type' => 'json']);