Example #1
0
 public function testCount()
 {
     authorizeFromEnv();
     $validQueries = array(array('count' => 'true'), array('count' => true));
     foreach ($validQueries as $query) {
         $resp = CleverStudent::all($query);
         $this->assertEquals($resp['count'] > 0, true);
     }
 }
 public function testCanPaginateWithFirstAndLastIDsOfCollection()
 {
     authorizeFromEnv();
     $students = CleverStudent::all(array("limit" => 2));
     $page_1_handle = array('oldest' => $students[0], 'newest' => end($students));
     reset($students);
     # Request two students occuring after our last request
     $students_page_2 = CleverStudent::all(array("limit" => 2, "starting_after" => $page_1_handle['newest']));
     $this->assertInternalType('array', $students_page_2);
     $page_2_handle = array('oldest' => $students_page_2[0], 'newest' => end($students_page_2));
     reset($students_page_2);
     # Request the first two students again, or the ones before our last request
     $students_page_1_again = CleverStudent::all(array("limit" => 2, "ending_before" => $page_2_handle['oldest']));
     $this->assertInternalType('array', $students_page_1_again);
     for ($i = 0; $i < count($students_page_1_again); $i++) {
         $this->assertEquals($students_page_1_again[$i], $students[$i]);
     }
     $this->assertEquals($students, $students_page_1_again);
 }
Example #3
0
 /**
  * @expectedException UndefinedEndpointException
  */
 public function testUndefinedSecondLevel()
 {
     $students = CleverStudent::all(array('limit' => 1));
     $student = $students[0];
     $objs = $student->eventz();
 }