Skip to content

Update .travis.yml #325

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 21 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
language: php
php:
- '5.4'
- '5.5'
- '5.6'
- '7.0'
- '7.1'
# - hhvm # on Trusty only
# - nightly
before_install:
- nvm install 6.11
install:
- composer install
- npm install -g mongodb-runner
- npm install
before_script:
- mongodb-runner --start
script:
- nohup npm start 1>&2 &
- sleep 10
- ./vendor/bin/phpunit
31 changes: 30 additions & 1 deletion src/Parse/ParseClient.php
Original file line number Diff line number Diff line change
Expand Up @@ -497,7 +497,7 @@ public static function _request(
if(!isset($decoded) && $response !== '') {
throw new ParseException(
'Bad Request. Could not decode Response: '.
'('.json_last_error().') '.json_last_error_msg(),
'('.json_last_error().') '.self::getLastJSONErrorMsg(),
-1
);

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

}

/**
* Returns the last error message from a failed json_decode call
*
* @return string
*/
private static function getLastJSONErrorMsg()
{
// check if json_last_error_msg is defined (>= 5.5.0)
if (!function_exists('json_last_error_msg')) {
// return custom error messages for each code
$error_strings = array(
JSON_ERROR_NONE => 'No error',
JSON_ERROR_DEPTH => 'Maximum stack depth exceeded',
JSON_ERROR_STATE_MISMATCH => 'State mismatch (invalid or malformed JSON)',
JSON_ERROR_CTRL_CHAR => 'Control character error, potentially incorrectly encoded',
JSON_ERROR_SYNTAX => 'Syntax error',
JSON_ERROR_UTF8 => 'Malformed UTF-8 characters, potentially incorrectly encoded'
);

$error = json_last_error();
return isset($error_strings[$error]) ? $error_strings[$error] : 'Unknown error';

}

// use existing function
return json_last_error_msg();

}

/**
* ParseClient::setStorage, will update the storage object used for
* persistence.
Expand Down
4 changes: 2 additions & 2 deletions tests/Parse/AddOperationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public function testAddOperation()
*/
public function testBadObjects()
{
$this->setExpectedException(ParseException::class,
$this->setExpectedException('\Parse\ParseException',
'AddOperation requires an array.');
new AddOperation('not an array');

Expand Down Expand Up @@ -84,7 +84,7 @@ public function testMergePrevious()
*/
public function testInvalidMerge()
{
$this->setExpectedException(ParseException::class,
$this->setExpectedException('\Parse\ParseException',
'Operation is invalid after previous operation.');
$addOp = new AddOperation([
'key1' => 'value1'
Expand Down
4 changes: 2 additions & 2 deletions tests/Parse/AddUniqueOperationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ public function testAddUniqueOp()
*/
public function testBadObjects()
{
$this->setExpectedException(ParseException::class,
$this->setExpectedException('\Parse\ParseException',
'AddUniqueOperation requires an array.');
$addUnique = new AddUniqueOperation('not-an-array');

Expand Down Expand Up @@ -114,7 +114,7 @@ public function testMergePrevious()
*/
public function testInvalidMerge()
{
$this->setExpectedException(ParseException::class,
$this->setExpectedException('\Parse\ParseException',
'Operation is invalid after previous operation.');
$addOp = new AddUniqueOperation([
'key1' => 'value1'
Expand Down
2 changes: 1 addition & 1 deletion tests/Parse/IncrementOperationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ public function testMergePrevious()
*/
public function testInvalidMerge()
{
$this->setExpectedException(ParseException::class,
$this->setExpectedException('\Parse\ParseException',
'Operation is invalid after previous operation.');
$addOp = new IncrementOperation();
$addOp->_mergeWithPrevious(new AddOperation(['key' => 'value']));
Expand Down
4 changes: 2 additions & 2 deletions tests/Parse/ParseClientTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ public function testParseNotInitialized() {
* @group client-not-initialized
*/
public function testAppNotNotInitialized() {
$this->setExpectedException(\Exception::class,
$this->setExpectedException('\Exception',
'You must call Parse::initialize(..., $accountKey) before making any app requests. '.
'Your account key must not be null or empty.'
);
Expand Down Expand Up @@ -508,7 +508,7 @@ public function testStreamCAFile()
*/
public function testBadApiResponse()
{
$this->setExpectedException(ParseException::class,
$this->setExpectedException('\Parse\ParseException',
'Bad Request. Could not decode Response: (4) Syntax error');

$httpClient = ParseClient::getHttpClient();
Expand Down
14 changes: 7 additions & 7 deletions tests/Parse/ParseCurlTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ class ParseCurlTest extends \PHPUnit_Framework_TestCase
{
public function testBadExec()
{
$this->setExpectedException(ParseException::class,
$this->setExpectedException('\Parse\ParseException',
'You must call ParseCurl::init first');

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

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

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

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

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

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

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

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

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

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

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

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

$parseCurl = new ParseCurl();
Expand Down
8 changes: 4 additions & 4 deletions tests/Parse/ParseInstallationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public function tearDown()
*/
public function testMissingIdentifyingField()
{
$this->setExpectedException(ParseException::class,
$this->setExpectedException('\Parse\ParseException',
'at least one ID field (deviceToken, installationId) must be specified in this operation');

(new ParseInstallation())->save();
Expand All @@ -34,7 +34,7 @@ public function testMissingIdentifyingField()
*/
public function testMissingDeviceType()
{
$this->setExpectedException(ParseException::class,
$this->setExpectedException('\Parse\ParseException',
'deviceType must be specified in this operation');

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

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

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

// try destroying, without using the master key
Expand Down
10 changes: 5 additions & 5 deletions tests/Parse/ParsePushTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public function tearDown()
}

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

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

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

$query = ParseInstallation::query();
Expand Down Expand Up @@ -108,7 +108,7 @@ public function testPushToQueryWithoutWhere()

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

public function testExpirationTimeAndIntervalSet()
{
$this->setExpectedException(\Exception::class,
$this->setExpectedException('\Exception',
'Both expiration_time and expiration_interval can\'t be set.');
ParsePush::send(
[
Expand Down
4 changes: 2 additions & 2 deletions tests/Parse/ParseQueryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2243,7 +2243,7 @@ public function testAscendingByArray() {

public function testOrQueriesVaryingClasses()
{
$this->setExpectedException(\Exception::class,
$this->setExpectedException('\Exception',
'All queries must be for the same class');
ParseQuery::orQueries([
new ParseQuery('Class1'),
Expand Down Expand Up @@ -2275,7 +2275,7 @@ public function testSetConditions()

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

$query = new ParseQuery('TestObject');
Expand Down
12 changes: 6 additions & 6 deletions tests/Parse/ParseRelationOperationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public function tearDown()
*/
public function testMissingObjects()
{
$this->setExpectedException(\Exception::class,
$this->setExpectedException('\Exception',
'Cannot create a ParseRelationOperation with no objects.');
new ParseRelationOperation(null, null);

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

$objects = [];
Expand Down Expand Up @@ -78,7 +78,7 @@ public function testSingleObjects()
*/
public function testApplyDifferentClassRelation()
{
$this->setExpectedException(\Exception::class,
$this->setExpectedException('\Exception',
'Related object object must be of class '
.'Class1, but DifferentClass'
.' was passed in.');
Expand All @@ -96,7 +96,7 @@ public function testApplyDifferentClassRelation()
*/
public function testInvalidApply()
{
$this->setExpectedException(\Exception::class,
$this->setExpectedException('\Exception',
'Operation is invalid after previous operation.');
$addObj = new ParseObject('Class1');
$op = new ParseRelationOperation($addObj, null);
Expand All @@ -120,7 +120,7 @@ public function testMergeNone()
*/
public function testMergeDifferentClass()
{
$this->setExpectedException(\Exception::class,
$this->setExpectedException('\Exception',
'Related object object must be of class '
.'Class1, but AnotherClass'
.' was passed in.');
Expand All @@ -140,7 +140,7 @@ public function testMergeDifferentClass()
*/
public function testInvalidMerge()
{
$this->setExpectedException(\Exception::class,
$this->setExpectedException('\Exception',
'Operation is invalid after previous operation.');
$obj = new ParseObject('Class1');
$op = new ParseRelationOperation($obj, null);
Expand Down
4 changes: 2 additions & 2 deletions tests/Parse/ParseRoleTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,7 @@ public function createEden()

public function testSettingNonStringAsName()
{
$this->setExpectedException(ParseException::class,
$this->setExpectedException('\Parse\ParseException',
"A role's name must be a string.");
$role = new ParseRole();
$role->setName(12345);
Expand All @@ -247,7 +247,7 @@ public function testSettingNonStringAsName()
*/
public function testSavingWithoutName()
{
$this->setExpectedException(ParseException::class,
$this->setExpectedException('\Parse\ParseException',
'Roles must have a name.');
$role = new ParseRole();
$role->setACL(new ParseACL());
Expand Down
8 changes: 4 additions & 4 deletions tests/Parse/ParseSchemaTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -334,7 +334,7 @@ public function testInvalidTypeException()
*/
public function testBadSchemaGet()
{
$this->setExpectedException(ParseException::class);
$this->setExpectedException('\Parse\ParseException');

$user = new ParseUser();
$user->setUsername('schema-user');
Expand All @@ -351,7 +351,7 @@ public function testBadSchemaGet()
*/
public function testBadSchemaSave()
{
$this->setExpectedException(ParseException::class);
$this->setExpectedException('\Parse\ParseException');

$user = new ParseUser();
$user->setUsername('schema-user');
Expand All @@ -368,7 +368,7 @@ public function testBadSchemaSave()
*/
public function testBadSchemaUpdate()
{
$this->setExpectedException(ParseException::class);
$this->setExpectedException('\Parse\ParseException');

$user = new ParseUser();
$user->setUsername('schema-user');
Expand All @@ -385,7 +385,7 @@ public function testBadSchemaUpdate()
*/
public function testBadSchemaDelete()
{
$this->setExpectedException(ParseException::class);
$this->setExpectedException('\Parse\ParseException');

$user = new ParseUser();
$user->setUsername('schema-user');
Expand Down
Loading