mirror of
https://github.com/opdavies/glassboxx-sdk-php.git
synced 2025-02-17 22:50:48 +00:00
Re-organise the src and tests directories
This commit is contained in:
parent
ae766763b2
commit
b238e6655a
26 changed files with 13 additions and 13 deletions
55
tests/Request/CustomerRequestTest.php
Normal file
55
tests/Request/CustomerRequestTest.php
Normal file
|
|
@ -0,0 +1,55 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Opdavies\Glassboxx\Tests\Request;
|
||||
|
||||
use Opdavies\Glassboxx\Request\AuthTokenRequestInterface;
|
||||
use Opdavies\Glassboxx\Request\CustomerRequest;
|
||||
use Opdavies\Glassboxx\Tests\TestCase;
|
||||
use Opdavies\Glassboxx\Traits\UsesCreatedAtTrait;
|
||||
use Opdavies\Glassboxx\ValueObject\CustomerInterface;
|
||||
use Symfony\Component\HttpClient\MockHttpClient;
|
||||
use Symfony\Contracts\HttpClient\ResponseInterface;
|
||||
|
||||
final class CustomerRequestTest extends TestCase
|
||||
{
|
||||
public function testThatItCreatesACustomer(): void
|
||||
{
|
||||
$authTokenRequest = $this->getMockAuthTokenRequest();
|
||||
|
||||
$response = $this->getMockBuilder(ResponseInterface::class)
|
||||
->getMock();
|
||||
$response->method('getContent')->willReturn('"Success"');
|
||||
|
||||
$client = $this->getMockBuilder(MockHttpClient::class)->getMock();
|
||||
$client->expects($this->once())
|
||||
->method('request')
|
||||
->with(
|
||||
'POST',
|
||||
CustomerRequest::ENDPOINT,
|
||||
[
|
||||
'auth_bearer' => $authTokenRequest->getToken(),
|
||||
'headers' => [
|
||||
'Content-Type' => 'application/json',
|
||||
],
|
||||
'body' => json_encode([
|
||||
'customer' => [
|
||||
'created_in' => 123,
|
||||
'email' => 'oliver@oliverdavies.uk',
|
||||
'firstname' => 'Oliver',
|
||||
'lastname' => 'Davies',
|
||||
],
|
||||
]),
|
||||
]
|
||||
)
|
||||
->willReturn($response);
|
||||
|
||||
$request = (new CustomerRequest($client))
|
||||
->forCustomer($this->getMockCustomer())
|
||||
->withAuthToken($authTokenRequest->getToken())
|
||||
->withConfig($this->config);
|
||||
|
||||
$this->assertSame('Success', $request->execute());
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue