From 9e2daa03888c2cbd47fb8d9c7050bb1ae7c7d7d6 Mon Sep 17 00:00:00 2001 From: Benjamin Friedman Date: Fri, 12 May 2017 17:10:40 -0700 Subject: [PATCH 1/2] Updates mocking to work with phpunit 4.0. Updates a pair of test cases with a small time delay so that updatedAt related queries will return as expected --- tests/Parse/ParseClientTest.php | 3 ++- tests/Parse/ParseQueryTest.php | 42 ++++++++++++++++++--------------- 2 files changed, 25 insertions(+), 20 deletions(-) diff --git a/tests/Parse/ParseClientTest.php b/tests/Parse/ParseClientTest.php index cda198b2..910171ac 100644 --- a/tests/Parse/ParseClientTest.php +++ b/tests/Parse/ParseClientTest.php @@ -514,7 +514,8 @@ public function testBadApiResponse() $httpClient = ParseClient::getHttpClient(); // create a mock of the current http client - $stubClient = $this->createMock(get_class($httpClient)); + $stubClient = $this->getMockBuilder(get_class($httpClient)) + ->getMock(); // stub the response type to return // something we will try to work with diff --git a/tests/Parse/ParseQueryTest.php b/tests/Parse/ParseQueryTest.php index 38e579c3..7057334c 100644 --- a/tests/Parse/ParseQueryTest.php +++ b/tests/Parse/ParseQueryTest.php @@ -1499,20 +1499,23 @@ public function testOrderByCreatedAtDesc() } } + /** + * @group order-by-updated-at + */ public function testOrderByUpdatedAtAsc() { $numbers = [3, 1, 2]; $objects = []; - $this->saveObjects( - 3, - function ($i) use ($numbers, &$objects) { - $obj = ParseObject::create('TestObject'); - $obj->set('number', $numbers[$i]); - $objects[] = $obj; - return $obj; - } - ); + foreach($numbers as $num) { + $obj = ParseObject::create('TestObject'); + $obj->set('number', $num); + $obj->save(); + $objects[] = $obj; + sleep(1); + + } + $objects[1]->set('number', 4); $objects[1]->save(); $query = new ParseQuery('TestObject'); @@ -1541,16 +1544,16 @@ public function testOrderByUpdatedAtDesc() { $numbers = [3, 1, 2]; $objects = []; - $this->saveObjects( - 3, - function ($i) use ($numbers, &$objects) { - $obj = ParseObject::create('TestObject'); - $obj->set('number', $numbers[$i]); - $objects[] = $obj; - return $obj; - } - ); + foreach($numbers as $num) { + $obj = ParseObject::create('TestObject'); + $obj->set('number', $num); + $obj->save(); + $objects[] = $obj; + sleep(1); + + } + $objects[1]->set('number', 4); $objects[1]->save(); $query = new ParseQuery('TestObject'); @@ -1561,7 +1564,8 @@ function ($i) use ($numbers, &$objects) { count($results), 'Did not return correct number of objects.' ); - $expected = [4, 3, 2]; + + $expected = [4, 2, 3]; for ($i = 0; $i < 3; ++$i) { $this->assertEquals( $expected[$i], From 1bd2dc2ddf19a0160286e5a6750032326414fb3a Mon Sep 17 00:00:00 2001 From: Benjamin Friedman Date: Sat, 13 May 2017 12:03:46 -0700 Subject: [PATCH 2/2] Bumped internal version # --- src/Parse/ParseClient.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Parse/ParseClient.php b/src/Parse/ParseClient.php index fb2166fa..5bc2cf13 100755 --- a/src/Parse/ParseClient.php +++ b/src/Parse/ParseClient.php @@ -111,7 +111,7 @@ final class ParseClient * * @var string */ - const VERSION_STRING = 'php1.2.2'; + const VERSION_STRING = 'php1.2.7'; /** * Parse\Client::initialize, must be called before using Parse features.