Skip to content

Commit 2a967c6

Browse files
authored
chore(CI): configure Travis and Codecov (#324)
* Create .travis.yml * Update .travis.yml * Update .travis.yml * Update .travis.yml * Calling nvm in 'before_install' * using string instead of 'class' property for php 5.4 * Utilizing customary method for accessing json_last_error_msg, in case it doesn't exist (php 5.4) * Forced installation of 'process-nextick-args' for travis * Additional comments + force travis to rebuild * Local install only * Added missing 'isarray' module * Shifted travis related dependencies into package.json * Added 'buffer-shims' module * Testing with new parse-server-test * Updated package.json, added slight delay after server boot * Adds coverage report * Update README.md
1 parent 9bdbd71 commit 2a967c6

17 files changed

+96
-42
lines changed

.travis.yml

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
language: php
2+
php:
3+
- '5.4'
4+
- '5.5'
5+
- '5.6'
6+
- '7.0'
7+
- '7.1'
8+
# - hhvm # on Trusty only
9+
# - nightly
10+
before_install:
11+
- nvm install 6.11
12+
install:
13+
- composer install
14+
- npm install
15+
before_script:
16+
- npm start 1>&2
17+
- sleep 3
18+
script:
19+
- ./vendor/bin/phpunit --coverage-clover=coverage.xml
20+
21+
after_success:
22+
- bash <(curl -s https://codecov.io/bash)

README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
Parse PHP SDK
22
-------------
33

4+
[![codecov](https://codecov.io/gh/parse-community/parse-php-sdk/branch/master/graph/badge.svg)](https://codecov.io/gh/parse-community/parse-php-sdk)
5+
[![Build Status](https://travis-ci.org/parse-community/parse-php-sdk.svg?branch=master)](https://travis-ci.org/parse-community/parse-php-sdk)
6+
47
The Parse PHP SDK gives you access to the powerful Parse cloud platform
58
from your PHP app or script. Updated to work with the self-hosted Parse Server: https://github.com/parse-community/parse-server
69

src/Parse/ParseClient.php

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -497,7 +497,7 @@ public static function _request(
497497
if(!isset($decoded) && $response !== '') {
498498
throw new ParseException(
499499
'Bad Request. Could not decode Response: '.
500-
'('.json_last_error().') '.json_last_error_msg(),
500+
'('.json_last_error().') '.self::getLastJSONErrorMsg(),
501501
-1
502502
);
503503

@@ -522,6 +522,35 @@ public static function _request(
522522

523523
}
524524

525+
/**
526+
* Returns the last error message from a failed json_decode call
527+
*
528+
* @return string
529+
*/
530+
private static function getLastJSONErrorMsg()
531+
{
532+
// check if json_last_error_msg is defined (>= 5.5.0)
533+
if (!function_exists('json_last_error_msg')) {
534+
// return custom error messages for each code
535+
$error_strings = array(
536+
JSON_ERROR_NONE => 'No error',
537+
JSON_ERROR_DEPTH => 'Maximum stack depth exceeded',
538+
JSON_ERROR_STATE_MISMATCH => 'State mismatch (invalid or malformed JSON)',
539+
JSON_ERROR_CTRL_CHAR => 'Control character error, potentially incorrectly encoded',
540+
JSON_ERROR_SYNTAX => 'Syntax error',
541+
JSON_ERROR_UTF8 => 'Malformed UTF-8 characters, potentially incorrectly encoded'
542+
);
543+
544+
$error = json_last_error();
545+
return isset($error_strings[$error]) ? $error_strings[$error] : 'Unknown error';
546+
547+
}
548+
549+
// use existing function
550+
return json_last_error_msg();
551+
552+
}
553+
525554
/**
526555
* ParseClient::setStorage, will update the storage object used for
527556
* persistence.

tests/Parse/AddOperationTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ public function testAddOperation()
4040
*/
4141
public function testBadObjects()
4242
{
43-
$this->setExpectedException(ParseException::class,
43+
$this->setExpectedException('\Parse\ParseException',
4444
'AddOperation requires an array.');
4545
new AddOperation('not an array');
4646

@@ -84,7 +84,7 @@ public function testMergePrevious()
8484
*/
8585
public function testInvalidMerge()
8686
{
87-
$this->setExpectedException(ParseException::class,
87+
$this->setExpectedException('\Parse\ParseException',
8888
'Operation is invalid after previous operation.');
8989
$addOp = new AddOperation([
9090
'key1' => 'value1'

tests/Parse/AddUniqueOperationTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ public function testAddUniqueOp()
5050
*/
5151
public function testBadObjects()
5252
{
53-
$this->setExpectedException(ParseException::class,
53+
$this->setExpectedException('\Parse\ParseException',
5454
'AddUniqueOperation requires an array.');
5555
$addUnique = new AddUniqueOperation('not-an-array');
5656

@@ -114,7 +114,7 @@ public function testMergePrevious()
114114
*/
115115
public function testInvalidMerge()
116116
{
117-
$this->setExpectedException(ParseException::class,
117+
$this->setExpectedException('\Parse\ParseException',
118118
'Operation is invalid after previous operation.');
119119
$addOp = new AddUniqueOperation([
120120
'key1' => 'value1'

tests/Parse/IncrementOperationTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ public function testMergePrevious()
6262
*/
6363
public function testInvalidMerge()
6464
{
65-
$this->setExpectedException(ParseException::class,
65+
$this->setExpectedException('\Parse\ParseException',
6666
'Operation is invalid after previous operation.');
6767
$addOp = new IncrementOperation();
6868
$addOp->_mergeWithPrevious(new AddOperation(['key' => 'value']));

tests/Parse/ParseClientTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ public function testParseNotInitialized() {
7171
* @group client-not-initialized
7272
*/
7373
public function testAppNotNotInitialized() {
74-
$this->setExpectedException(\Exception::class,
74+
$this->setExpectedException('\Exception',
7575
'You must call Parse::initialize(..., $accountKey) before making any app requests. '.
7676
'Your account key must not be null or empty.'
7777
);
@@ -508,7 +508,7 @@ public function testStreamCAFile()
508508
*/
509509
public function testBadApiResponse()
510510
{
511-
$this->setExpectedException(ParseException::class,
511+
$this->setExpectedException('\Parse\ParseException',
512512
'Bad Request. Could not decode Response: (4) Syntax error');
513513

514514
$httpClient = ParseClient::getHttpClient();

tests/Parse/ParseCurlTest.php

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ class ParseCurlTest extends \PHPUnit_Framework_TestCase
1616
{
1717
public function testBadExec()
1818
{
19-
$this->setExpectedException(ParseException::class,
19+
$this->setExpectedException('\Parse\ParseException',
2020
'You must call ParseCurl::init first');
2121

2222
$parseCurl = new ParseCurl();
@@ -26,7 +26,7 @@ public function testBadExec()
2626

2727
public function testBadSetOption()
2828
{
29-
$this->setExpectedException(ParseException::class,
29+
$this->setExpectedException('\Parse\ParseException',
3030
'You must call ParseCurl::init first');
3131

3232
$parseCurl = new ParseCurl();
@@ -36,7 +36,7 @@ public function testBadSetOption()
3636

3737
public function testBadSetOptionsArray()
3838
{
39-
$this->setExpectedException(ParseException::class,
39+
$this->setExpectedException('\Parse\ParseException',
4040
'You must call ParseCurl::init first');
4141

4242
$parseCurl = new ParseCurl();
@@ -46,7 +46,7 @@ public function testBadSetOptionsArray()
4646

4747
public function testBadGetInfo()
4848
{
49-
$this->setExpectedException(ParseException::class,
49+
$this->setExpectedException('\Parse\ParseException',
5050
'You must call ParseCurl::init first');
5151

5252
$parseCurl = new ParseCurl();
@@ -56,7 +56,7 @@ public function testBadGetInfo()
5656

5757
public function testBadGetError()
5858
{
59-
$this->setExpectedException(ParseException::class,
59+
$this->setExpectedException('\Parse\ParseException',
6060
'You must call ParseCurl::init first');
6161

6262
$parseCurl = new ParseCurl();
@@ -66,7 +66,7 @@ public function testBadGetError()
6666

6767
public function testBadErrorCode()
6868
{
69-
$this->setExpectedException(ParseException::class,
69+
$this->setExpectedException('\Parse\ParseException',
7070
'You must call ParseCurl::init first');
7171

7272
$parseCurl = new ParseCurl();
@@ -76,7 +76,7 @@ public function testBadErrorCode()
7676

7777
public function testBadClose()
7878
{
79-
$this->setExpectedException(ParseException::class,
79+
$this->setExpectedException('\Parse\ParseException',
8080
'You must call ParseCurl::init first');
8181

8282
$parseCurl = new ParseCurl();

tests/Parse/ParseInstallationTest.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ public function tearDown()
2323
*/
2424
public function testMissingIdentifyingField()
2525
{
26-
$this->setExpectedException(ParseException::class,
26+
$this->setExpectedException('\Parse\ParseException',
2727
'at least one ID field (deviceToken, installationId) must be specified in this operation');
2828

2929
(new ParseInstallation())->save();
@@ -34,7 +34,7 @@ public function testMissingIdentifyingField()
3434
*/
3535
public function testMissingDeviceType()
3636
{
37-
$this->setExpectedException(ParseException::class,
37+
$this->setExpectedException('\Parse\ParseException',
3838
'deviceType must be specified in this operation');
3939

4040
$installation = new ParseInstallation();
@@ -48,7 +48,7 @@ public function testMissingDeviceType()
4848
*/
4949
public function testClientsCannotFindWithoutMasterKey()
5050
{
51-
$this->setExpectedException(ParseException::class,
51+
$this->setExpectedException('\Parse\ParseException',
5252
'Clients aren\'t allowed to perform the find operation on the installation collection.');
5353

5454
$query = ParseInstallation::query();
@@ -66,7 +66,7 @@ public function testClientsCannotDestroyWithoutMasterKey()
6666
$installation->set('deviceType', 'android');
6767
$installation->save();
6868

69-
$this->setExpectedException(ParseException::class,
69+
$this->setExpectedException('\Parse\ParseException',
7070
"Clients aren't allowed to perform the delete operation on the installation collection.");
7171

7272
// try destroying, without using the master key

tests/Parse/ParsePushTest.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ public function tearDown()
2121
}
2222

2323
public function testNoMasterKey() {
24-
$this->setExpectedException(ParseException::class);
24+
$this->setExpectedException('\Parse\ParseException');
2525

2626
ParsePush::send(
2727
[
@@ -46,7 +46,7 @@ public function testBasicPush()
4646
*/
4747
public function testMissingWhereAndChannels()
4848
{
49-
$this->setExpectedException(ParseException::class,
49+
$this->setExpectedException('\Parse\ParseException',
5050
"Sending a push requires either \"channels\" or a \"where\" query.");
5151

5252
ParsePush::send([
@@ -62,7 +62,7 @@ public function testMissingWhereAndChannels()
6262
*/
6363
public function testWhereAndChannels()
6464
{
65-
$this->setExpectedException(ParseException::class,
65+
$this->setExpectedException('\Parse\ParseException',
6666
"Channels and query can not be set at the same time.");
6767

6868
$query = ParseInstallation::query();
@@ -108,7 +108,7 @@ public function testPushToQueryWithoutWhere()
108108

109109
public function testNonQueryWhere()
110110
{
111-
$this->setExpectedException(\Exception::class,
111+
$this->setExpectedException('\Exception',
112112
'Where parameter for Parse Push must be of type ParseQuery');
113113
ParsePush::send(
114114
[
@@ -133,7 +133,7 @@ public function testPushDates()
133133

134134
public function testExpirationTimeAndIntervalSet()
135135
{
136-
$this->setExpectedException(\Exception::class,
136+
$this->setExpectedException('\Exception',
137137
'Both expiration_time and expiration_interval can\'t be set.');
138138
ParsePush::send(
139139
[

tests/Parse/ParseQueryTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2243,7 +2243,7 @@ public function testAscendingByArray() {
22432243

22442244
public function testOrQueriesVaryingClasses()
22452245
{
2246-
$this->setExpectedException(\Exception::class,
2246+
$this->setExpectedException('\Exception',
22472247
'All queries must be for the same class');
22482248
ParseQuery::orQueries([
22492249
new ParseQuery('Class1'),
@@ -2275,7 +2275,7 @@ public function testSetConditions()
22752275

22762276
public function testBadConditions()
22772277
{
2278-
$this->setExpectedException(ParseException::class,
2278+
$this->setExpectedException('\Parse\ParseException',
22792279
"Conditions must be in an array");
22802280

22812281
$query = new ParseQuery('TestObject');

tests/Parse/ParseRelationOperationTest.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ public function tearDown()
3030
*/
3131
public function testMissingObjects()
3232
{
33-
$this->setExpectedException(\Exception::class,
33+
$this->setExpectedException('\Exception',
3434
'Cannot create a ParseRelationOperation with no objects.');
3535
new ParseRelationOperation(null, null);
3636

@@ -41,7 +41,7 @@ public function testMissingObjects()
4141
*/
4242
public function testMixedClasses()
4343
{
44-
$this->setExpectedException(\Exception::class,
44+
$this->setExpectedException('\Exception',
4545
'All objects in a relation must be of the same class.');
4646

4747
$objects = [];
@@ -78,7 +78,7 @@ public function testSingleObjects()
7878
*/
7979
public function testApplyDifferentClassRelation()
8080
{
81-
$this->setExpectedException(\Exception::class,
81+
$this->setExpectedException('\Exception',
8282
'Related object object must be of class '
8383
.'Class1, but DifferentClass'
8484
.' was passed in.');
@@ -96,7 +96,7 @@ public function testApplyDifferentClassRelation()
9696
*/
9797
public function testInvalidApply()
9898
{
99-
$this->setExpectedException(\Exception::class,
99+
$this->setExpectedException('\Exception',
100100
'Operation is invalid after previous operation.');
101101
$addObj = new ParseObject('Class1');
102102
$op = new ParseRelationOperation($addObj, null);
@@ -120,7 +120,7 @@ public function testMergeNone()
120120
*/
121121
public function testMergeDifferentClass()
122122
{
123-
$this->setExpectedException(\Exception::class,
123+
$this->setExpectedException('\Exception',
124124
'Related object object must be of class '
125125
.'Class1, but AnotherClass'
126126
.' was passed in.');
@@ -140,7 +140,7 @@ public function testMergeDifferentClass()
140140
*/
141141
public function testInvalidMerge()
142142
{
143-
$this->setExpectedException(\Exception::class,
143+
$this->setExpectedException('\Exception',
144144
'Operation is invalid after previous operation.');
145145
$obj = new ParseObject('Class1');
146146
$op = new ParseRelationOperation($obj, null);

tests/Parse/ParseRoleTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -235,7 +235,7 @@ public function createEden()
235235

236236
public function testSettingNonStringAsName()
237237
{
238-
$this->setExpectedException(ParseException::class,
238+
$this->setExpectedException('\Parse\ParseException',
239239
"A role's name must be a string.");
240240
$role = new ParseRole();
241241
$role->setName(12345);
@@ -247,7 +247,7 @@ public function testSettingNonStringAsName()
247247
*/
248248
public function testSavingWithoutName()
249249
{
250-
$this->setExpectedException(ParseException::class,
250+
$this->setExpectedException('\Parse\ParseException',
251251
'Roles must have a name.');
252252
$role = new ParseRole();
253253
$role->setACL(new ParseACL());

0 commit comments

Comments
 (0)