Skip to content

Commit 985eb4e

Browse files
committed
Test coveralls
1 parent 4ff10df commit 985eb4e

File tree

4 files changed

+29
-15
lines changed

4 files changed

+29
-15
lines changed

.travis.yml

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,4 +20,9 @@ before_script:
2020
- wget http://getcomposer.org/composer.phar
2121
- php composer.phar install
2222

23-
script: phpunit --bootstrap tests/bootstrap.php tests
23+
script:
24+
- mkdir -p build/logs
25+
- phpunit --coverage-clover build/logs/clover.xml --bootstrap tests/bootstrap.php tests
26+
27+
after_script:
28+
- php vendor/bin/coveralls -v

composer.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,8 @@
1717
"guzzlehttp/guzzle": "~6.0"
1818
},
1919
"require-dev": {
20-
"phpunit/phpunit": "5.6.*"
20+
"phpunit/phpunit": "5.6.*",
21+
"satooshi/php-coveralls": "^v1.0.1"
2122
},
2223
"autoload": {
2324
"psr-4": {

tests/Clients/FakeClient.php

Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -45,48 +45,44 @@ public function __construct()
4545

4646
public function get($endpoint, $query = [])
4747
{
48-
$request = new Request('GET',$this->buildUri($endpoint), $this->buildHeaders());
49-
50-
$response = $this->guzzle->send($request);
48+
$response = $this->guzzle->request('GET',$endpoint);
5149

5250
return $this->handle($response);
5351
}
5452

5553
public function post($endpoint, $data, $query = [])
5654
{
55+
$response = $this->guzzle->request('POST',$endpoint);
5756

57+
return $this->handle($response);
5858
}
5959

6060
public function put($endpoint, $data, $query = [])
6161
{
62+
$response = $this->guzzle->request('PUT',$endpoint);
6263

64+
return $this->handle($response);
6365
}
6466

6567
public function patch($endpoint, $data, $query = [])
6668
{
69+
$response = $this->guzzle->request('PATCH',$endpoint);
6770

71+
return $this->handle($response);
6872
}
6973

7074
public function delete($endpoint, $query = [])
7175
{
76+
$response = $this->guzzle->request('DELETE',$endpoint);
7277

78+
return $this->handle($response);
7379
}
7480

7581
protected function buildUri($endpoint, $options = [], $query = [])
7682
{
7783
return 'http://example.com/' . ltrim($endpoint, '/') . '.json?' . http_build_query($options, '', '&');
7884
}
7985

80-
protected function buildHeaders($extraHeaders = [])
81-
{
82-
$headers = [
83-
'Accept' => 'application/json',
84-
'Content-Type: application/json',
85-
];
86-
87-
return array_merge($headers, $extraHeaders);
88-
}
89-
9086
private function handle(Response $response, $default = null)
9187
{
9288
$stream = stream_for($response->getBody());

tests/FirebaseTest.php

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,18 @@ public function testFirebaseClient()
4141
$response = $me->getResponse();
4242

4343
$this->assertNull($response);
44+
45+
$response = $me->post('/',['key'=>'value'])->getResponse();
46+
47+
$this->assertNull($response);
48+
49+
$response = $me->put('/',['key'=>'value'])->getResponse();
50+
51+
$this->assertNull($response);
52+
53+
$response = $me->patch('/',['key'=>'value'])->getResponse();
54+
55+
$this->assertNull($response);
4456
}
4557

4658
public function testBaseException()

0 commit comments

Comments
 (0)