Skip to content

Commit b5c8f02

Browse files
authored
Switch to matrix for tests (#30)
1 parent d4780d9 commit b5c8f02

File tree

3 files changed

+34
-9
lines changed

3 files changed

+34
-9
lines changed

.github/workflows/php.yml

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,23 +4,25 @@ on: [push, pull_request]
44

55
jobs:
66
build:
7-
8-
runs-on: ubuntu-latest
9-
7+
runs-on: ${{ matrix.operating-system }}
8+
strategy:
9+
matrix:
10+
operating-system: [ubuntu-latest]
11+
php-versions: ['7.1', '7.2', '7.3']
1012
steps:
1113
- uses: actions/checkout@v1
1214
- name: Start Container
1315
run: |
1416
docker pull lkdevelopment/hetzner-cloud-api-mock
1517
docker run -d -p 127.0.0.1:4000:8080 lkdevelopment/hetzner-cloud-api-mock
1618
docker ps -a
19+
- name: Setup PHP
20+
uses: shivammathur/setup-php@v1
21+
with:
22+
php-version: ${{ matrix.php-versions }}
1723
- name: Install depdendencies
1824
run: |
1925
composer global require hirak/prestissimo
2026
composer install
21-
- name: PHP 7.1
22-
run: php7.1 vendor/bin/phpunit
23-
- name: PHP 7.2
24-
run: php7.2 vendor/bin/phpunit
25-
- name: PHP 7.3
26-
run: php7.3 vendor/bin/phpunit
27+
- name: Run phpunit
28+
run: php vendor/bin/phpunit

src/HetznerAPIClient.php

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
namespace LKDev\HetznerCloud;
44

5+
use GuzzleHttp\Client;
56
use LKDev\HetznerCloud\Clients\GuzzleClient;
67
use LKDev\HetznerCloud\Models\Actions\Actions;
78
use LKDev\HetznerCloud\Models\Datacenters\Datacenters;
@@ -110,6 +111,7 @@ public function setBaseUrl(string $baseUrl): self
110111
$this->baseUrl = $baseUrl;
111112
return $this;
112113
}
114+
113115
/**
114116
* @return GuzzleClient
115117
*/
@@ -118,6 +120,15 @@ public function getHttpClient(): GuzzleClient
118120
return $this->httpClient;
119121
}
120122

123+
/**
124+
* @return GuzzleClient
125+
*/
126+
public function setHttpClient(GuzzleClient $client): self
127+
{
128+
$this->httpClient = $client;
129+
return $this;
130+
}
131+
121132
/**
122133
* @param \Psr\Http\Message\ResponseInterface $response
123134
* @throws \LKDev\HetznerCloud\APIException

tests/Integration/BasicClientTest.php

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88

99
namespace Tests;
1010

11+
use LKDev\HetznerCloud\Clients\GuzzleClient;
1112
use LKDev\HetznerCloud\HetznerAPIClient;
1213
use LKDev\HetznerCloud\Models\Actions\Actions;
1314
use LKDev\HetznerCloud\Models\Datacenters\Datacenters;
@@ -61,6 +62,17 @@ public function testSetUserAgent()
6162
$this->assertEquals("changed", $client->getUserAgent());
6263
}
6364

65+
/**
66+
*
67+
*/
68+
public function testSetHttpClient()
69+
{
70+
$client = new HetznerAPIClient('IAmTheTestToken', '');
71+
$httpClient = new GuzzleClient($client);
72+
$client->setHttpClient($httpClient);
73+
$this->assertEquals($httpClient, $client->getHttpClient());
74+
}
75+
6476
/**
6577
*
6678
*/

0 commit comments

Comments
 (0)