File tree Expand file tree Collapse file tree 4 files changed +63
-0
lines changed
tests/integration/guzzle/6 Expand file tree Collapse file tree 4 files changed +63
-0
lines changed Original file line number Diff line number Diff 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
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
Original file line number Diff line number Diff line change 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+ }
Original file line number Diff line number Diff line change 1+ {
2+ "require" : {
3+ "guzzlehttp/guzzle" : " ~6.0"
4+ }
5+ }
Original file line number Diff line number Diff line change 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 >
You can’t perform that action at this time.
0 commit comments