Skip to content

Commit 64c4278

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

File tree

5 files changed

+15
-22
lines changed

5 files changed

+15
-22
lines changed

Diff for: src/Api/Pipeline/AllPipelines.php

+4-8
Original file line numberDiff line numberDiff line change
@@ -12,25 +12,21 @@
1212
* Retrieve pipelines of a project, optionally filtered by branch.
1313
*
1414
* @author jmleroux <[email protected]>
15-
* @link https://circleci.com/docs/api/v2/#operation/listPipelinesForProject
15+
* @link https://circleci.com/docs/api/v2/#operation/listPipelinesForProject
1616
*/
1717
class AllPipelines
1818
{
1919
use ValidateClientVersionTrait;
2020

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

3026
/**
3127
* @return Pipeline[]
3228
*/
33-
public function execute(string $projectSlug, ?int $maxPipelineCount, ?string $branch): array
29+
public function execute(string $projectSlug, ?int $maxPipelineCount = null, ?string $branch = null): array
3430
{
3531
$pipelines = [];
3632

@@ -52,7 +48,7 @@ public function execute(string $projectSlug, ?int $maxPipelineCount, ?string $br
5248
unset($params['branch']);
5349
}
5450

55-
$response = json_decode((string) $this->client->get($uri, $params)->getContent());
51+
$response = json_decode((string)$this->client->get($uri, $params)->getContent());
5652
$nextPageToken = $response->next_page_token;
5753

5854
foreach ($response->items as $item) {

Diff for: tests/Integration/Api/Pipeline/AllPipelinesTest.php

+2-6
Original file line numberDiff line numberDiff line change
@@ -21,13 +21,9 @@ class AllPipelinesTest extends TestCase
2121

2222
private Client $client;
2323

24-
public static function setUpBeforeClass(): void
25-
{
26-
MockServer::startServer();
27-
}
28-
2924
public function setUp(): void
3025
{
26+
MockServer::startServer();
3127
$personaltoken = $_ENV['CIRCLECI_PERSONNAL_TOKEN'];
3228
$this->client = new TestClient(MockServer::getServerRoot(), $personaltoken, 'v2');
3329
}
@@ -69,7 +65,7 @@ public function testQueryWithBranch()
6965
$this->assertIsArray($pipelines);
7066
foreach ($pipelines as $pipeline) {
7167
$this->assertInstanceOf(Pipeline::class, $pipeline);
72-
$this->assertEquals('master', $pipeline->vcs()->branch());
68+
$this->assertEquals('feature/design-new-api', $pipeline->vcs()->branch());
7369
}
7470
}
7571
}

Diff for: tests/Integration/Api/Project/BuildSummaryForBranchTest.php

-3
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,6 @@ public function testQueryOk()
3131
$this->assertIsInt($firstBuild->buildNum());
3232
$this->assertIsString($firstBuild->branch());
3333
$this->assertIsString($firstBuild->vcsRevision());
34-
$this->assertIsString($firstBuild->committerName());
35-
$this->assertIsString($firstBuild->committerEmail());
36-
$this->assertIsString($firstBuild->body());
3734
$this->assertIsString($firstBuild->why());
3835
$this->assertNull($firstBuild->dontBuild());
3936
if (null !== $firstBuild->queuedAt()) {

Diff for: tests/Integration/Api/Project/ProjectSummaryMetricsTest.php

+1-2
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,7 @@ class ProjectSummaryMetricsTest extends TestCase
2020
{
2121
use ExecuteWithRetryTrait;
2222

23-
/** @var Client */
24-
private $client;
23+
private Client $client;
2524

2625
public function setUp(): void
2726
{

Diff for: tests/Integration/Api/Workflow/WorkflowJobsTest.php

+8-3
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44

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

7+
use Jmleroux\CircleCi\Api\Pipeline\AllPipelines;
8+
use Jmleroux\CircleCi\Api\Pipeline\PipelineWorkflows;
79
use Jmleroux\CircleCi\Api\Workflow\WorkflowJobs;
810
use Jmleroux\CircleCi\Client;
911
use Jmleroux\CircleCi\Model\Job;
@@ -15,8 +17,7 @@ class WorkflowJobsTest extends TestCase
1517
{
1618
use ExecuteWithRetryTrait;
1719

18-
/** @var Client */
19-
private $client;
20+
private Client $client;
2021

2122
public function setUp(): void
2223
{
@@ -26,8 +27,12 @@ public function setUp(): void
2627

2728
public function testQuery()
2829
{
30+
$query = new AllPipelines($this->client);
31+
$pipelines = $query->execute('gh/jmleroux/circleci-php-client', 1);
32+
$query = new PipelineWorkflows($this->client);
33+
$workflows = $query->execute($pipelines[0]->id(), 1);
2934
$query = new WorkflowJobs($this->client);
30-
$jobs = $this->executeWithRetry($query, ['78176b2f-c1e3-4c18-86e3-5a80a2f109bb']);
35+
$jobs = $this->executeWithRetry($query, [$workflows[0]->id()]);
3136
Assert::assertIsArray($jobs);
3237

3338
$firstJob = $jobs[0];

0 commit comments

Comments
 (0)