mirror of
https://github.com/opdavies/glassboxx-sdk-php.git
synced 2025-01-22 20:17:32 +00:00
42 lines
1.2 KiB
PHP
42 lines
1.2 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace Opdavies\Glassboxx\Tests\Request;
|
|
|
|
use Opdavies\Glassboxx\Request\AuthTokenRequest;
|
|
use Opdavies\Glassboxx\Tests\TestCase;
|
|
use Symfony\Component\HttpClient\MockHttpClient;
|
|
use Symfony\Contracts\HttpClient\ResponseInterface;
|
|
|
|
class AuthTokenRequestTest extends TestCase
|
|
{
|
|
public function testThatItGetsAnAuthCode(): void
|
|
{
|
|
$response = $this->getMockBuilder(ResponseInterface::class)
|
|
->getMock();
|
|
$response->method('getContent')->willReturn('"abc123"');
|
|
|
|
$client = $this->getMockBuilder(MockHttpClient::class)->getMock();
|
|
$client->expects($this->once())
|
|
->method('request')
|
|
->with(
|
|
'POST',
|
|
AuthTokenRequest::ENDPOINT,
|
|
[
|
|
'query' => [
|
|
'password' => 'secret',
|
|
'username' => 'opdavies',
|
|
],
|
|
]
|
|
)
|
|
->willReturn($response);
|
|
|
|
$token = (new AuthTokenRequest($client))
|
|
->withConfig($this->config)
|
|
->getToken();
|
|
|
|
$this->assertSame('abc123', $token);
|
|
}
|
|
}
|