Skip to content

Commit 7501430

Browse files
authored
Merge pull request php-vcr#246 from moufmouf/guzzle6-integration-tests
Adding integration tests for Guzzle 6
2 parents 98c6057 + e619f2d commit 7501430

File tree

4 files changed

+63
-0
lines changed

4 files changed

+63
-0
lines changed

.travis.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,8 @@ matrix:
3030
php: 5.6
3131
- env: TEST_DIR=tests/integration/guzzle/5
3232
php: 5.6
33+
- env: TEST_DIR=tests/integration/guzzle/6
34+
php: 5.6
3335
- env: TEST_DIR=tests/integration/soap
3436
php: 5.6
3537

@@ -56,4 +58,5 @@ cache:
5658
- tests/integration/guzzle/3/vendor
5759
- tests/integration/guzzle/4/vendor
5860
- tests/integration/guzzle/5/vendor
61+
- tests/integration/guzzle/6/vendor
5962
- $HOME/.composer/cache
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
<?php
2+
3+
namespace VCR\Example;
4+
5+
use GuzzleHttp\Client;
6+
use GuzzleHttp\Exception\ClientException;
7+
8+
class ExampleHttpClient
9+
{
10+
public function get($url)
11+
{
12+
$client = new Client();
13+
14+
try {
15+
$response = $client->get($url);
16+
return json_decode($response->getBody(), true);
17+
} catch (ClientException $e) {
18+
if ($e->getCode() !== 404) {
19+
throw $e;
20+
}
21+
}
22+
23+
return null;
24+
}
25+
26+
public function post($url, $body)
27+
{
28+
$client = new Client();
29+
30+
try {
31+
$response = $client->post($url, array('body' => $body));
32+
return json_decode($response->getBody(), true);
33+
} catch (ClientException $e) {
34+
if ($e->getCode() !== 404) {
35+
throw $e;
36+
}
37+
}
38+
39+
return null;
40+
}
41+
}
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"require": {
3+
"guzzlehttp/guzzle": "~6.0"
4+
}
5+
}
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
<phpunit bootstrap="../test/bootstrap.php"
2+
colors="true"
3+
convertErrorsToExceptions="true"
4+
convertNoticesToExceptions="true"
5+
convertWarningsToExceptions="true"
6+
>
7+
8+
<testsuites>
9+
<testsuite>
10+
<directory>../test</directory>
11+
</testsuite>
12+
</testsuites>
13+
14+
</phpunit>

0 commit comments

Comments
 (0)