Skip to content

Commit 5802f34

Browse files
authored
Merge pull request #2 from adrorocker/develop
Merge Develop into Master
2 parents 4ff10df + 5277ed3 commit 5802f34

File tree

6 files changed

+71
-15
lines changed

6 files changed

+71
-15
lines changed

.coveralls.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
coverage_clover: build/logs/clover.xml
2+
json_path: build/logs/coveralls-upload.json

.travis.yml

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,5 +19,11 @@ before_script:
1919

2020
- wget http://getcomposer.org/composer.phar
2121
- php composer.phar install
22+
- php composer.phar require satooshi/php-coveralls
2223

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

README.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
A PHP SDK for Firebase REST API.
55

66
[![Build status][Master image]][Master]
7+
[![Coverage Status][Master covarage image]][Master covarage]
78

89
-----------------------------------
910

@@ -47,4 +48,6 @@ $get = $firebase->get('/logs')->getResponse();
4748
[Alejandro Morelos](https://github.com/adrorocker).
4849

4950
[Master]: https://travis-ci.org/adrorocker/php-firebase/
50-
[Master image]: https://travis-ci.org/adrorocker/php-firebase.svg?branch=master
51+
[Master image]: https://travis-ci.org/adrorocker/php-firebase.svg?branch=master&style=flat-square
52+
[Master covarage]: https://coveralls.io/github/adrorocker/php-firebase?branch=master
53+
[Master covarage image]: https://coveralls.io/repos/github/adrorocker/php-firebase/badge.svg?branch=master&style=flat-square

phpunit.xml.dist

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
3+
<phpunit backupGlobals="false"
4+
backupStaticAttributes="false"
5+
colors="true"
6+
convertErrorsToExceptions="true"
7+
convertNoticesToExceptions="true"
8+
convertWarningsToExceptions="true"
9+
processIsolation="false"
10+
stopOnFailure="false"
11+
syntaxCheck="false"
12+
bootstrap="./tests/bootstrap.php">
13+
<php>
14+
<ini name="error_reporting" value="E_ALL" />
15+
</php>
16+
17+
<testsuites>
18+
<testsuite name="PHP Firebase test suite">
19+
<directory>./tests/</directory>
20+
</testsuite>
21+
</testsuites>
22+
23+
<filter>
24+
<whitelist>
25+
<directory>./src</directory>
26+
<exclude>
27+
<directory>./build</directory>
28+
<directory>./composer</directory>
29+
<directory>./tests</directory>
30+
<directory>./vendor</directory>
31+
</exclude>
32+
</whitelist>
33+
</filter>
34+
<logging>
35+
<log type="coverage-clover" target="build/logs/clover.xml"/>
36+
</logging>
37+
</phpunit>

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)