Skip to content

Commit 5c90b25

Browse files
committed
Replace Guzzle with Symfony HTTP client
1 parent e9b3751 commit 5c90b25

File tree

7 files changed

+13
-23
lines changed

7 files changed

+13
-23
lines changed

src/Api/Job/JobTestMetadata.php

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,9 @@ class JobTestMetadata
1919
{
2020
use ValidateClientVersionTrait;
2121

22-
/** @var Client */
23-
private $client;
24-
25-
public function __construct(Client $client)
22+
public function __construct(private readonly Client $client)
2623
{
27-
$this->validateClientVersion($client, ['v2']);
28-
$this->client = $client;
24+
$this->validateClientVersion($this->client, ['v2']);
2925
}
3026

3127
/**

src/Api/Workflow/CancelWorkflow.php

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,9 @@ class CancelWorkflow
1717
{
1818
use ValidateClientVersionTrait;
1919

20-
/** @var Client */
21-
private $client;
22-
23-
public function __construct(Client $client)
20+
public function __construct(private Client $client)
2421
{
2522
$this->validateClientVersion($client, ['v2']);
26-
$this->client = $client;
2723
}
2824

2925
public function execute(string $workflowId): void

src/Client.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

1111
class Client
1212
{
13-
protected readonly HttpClientInterface $client;
13+
protected HttpClientInterface $client;
1414

1515
public function __construct(private readonly string $token, private readonly ?string $version = 'v1.1')
1616
{

src/ValidateClientVersionTrait.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
trait ValidateClientVersionTrait
1313
{
1414
/**
15-
* @param Client $client
1615
* @param string[] $supportedVersions
1716
*/
1817
private function validateClientVersion(Client $client, array $supportedVersions): void

tests/Integration/Api/Project/BuildSummaryForBranchTest.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -60,13 +60,13 @@ public function testMaxResults()
6060
$personalToken = $_ENV['CIRCLECI_PERSONNAL_TOKEN'];
6161
$client = new Client($personalToken, 'v1.1');
6262
$query = new BuildSummaryForBranch($client);
63-
$builds = $this->executeWithRetry($query, ['github', 'jmleroux', 'circleci-php-client', 'master', [], 8]);
64-
$this->assertCount(8, $builds);
63+
$builds = $this->executeWithRetry($query, ['github', 'jmleroux', 'circleci-php-client', 'master', [], 2]);
64+
$this->assertCount(2, $builds);
6565

66-
$builds = $query->execute('github', 'jmleroux', 'circleci-php-client', 'master', [], 50);
67-
$this->assertCount(50, $builds);
66+
$builds = $query->execute('github', 'jmleroux', 'circleci-php-client', 'master', [], 8);
67+
$this->assertCount(8, $builds);
6868

69-
$builds = $query->execute('github', 'jmleroux', 'circleci-php-client', 'master', ['limit' => 6], 22);
70-
$this->assertCount(22, $builds);
69+
$builds = $query->execute('github', 'jmleroux', 'circleci-php-client', 'master', ['limit' => 6], 8);
70+
$this->assertCount(8, $builds);
7171
}
7272
}

tests/Integration/Api/Workflow/CancelWorkflowTest.php

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,10 @@
44

55
namespace Jmleroux\CircleCi\Tests\Integration\Api\Workflow;
66

7-
use GuzzleHttp\Exception\RequestException;
87
use Jmleroux\CircleCi\Api\Workflow\CancelWorkflow;
98
use Jmleroux\CircleCi\Client;
109
use PHPUnit\Framework\TestCase;
10+
use Symfony\Component\HttpClient\Exception\ClientException;
1111

1212
class CancelWorkflowTest extends TestCase
1313
{
@@ -22,9 +22,8 @@ public function setUp(): void
2222

2323
public function testQueryKo()
2424
{
25-
$this->expectException(RequestException::class);
25+
$this->expectException(ClientException::class);
2626
$this->expectExceptionCode(404);
27-
$this->expectExceptionMessage('{"message":"Workflow not found"}');
2827

2928
$query = new CancelWorkflow($this->client);
3029
$query->execute('foobar');

tests/Integration/TestClient.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@ public function __construct(
1717
string $token,
1818
?string $version = 'v1.1'
1919
) {
20+
parent::__construct($token, $version);
2021
$baseUri = sprintf('%s/api/%s/', $mockServerBaseUrl, $version);
2122
$this->client = HttpClient::create(['base_uri' => $baseUri]);
22-
$this->token = $token;
2323
}
2424
}

0 commit comments

Comments
 (0)