function test_getAll() { $user = new tests_Common(TABLE_USER); $user->setLimit(0, 10); $user->add(array('login' => 1)); $user->add(array('login' => 2)); $user->add(array('login' => 3)); $user->add(array('login' => 4)); $this->assertEquals(1, sizeof($user->getAll(0, 1))); $user->setLimit(0, 3); $this->assertEquals(2, sizeof($user->getAll(0, 2))); $this->assertEquals(3, sizeof($user->getAll())); }
function test_tableEqualsColumnJoinedGetAll() { $theQuestion = 'Why does this not work?'; $theAnswer = 'I dont know!'; $question = new tests_Common(TABLE_QUESTION); $newQuest = array(TABLE_QUESTION => $theQuestion); $qid = $question->add($newQuest); $answer = new tests_Common(TABLE_ANSWER); $newAnswer = array(TABLE_QUESTION . '_id' => $qid, TABLE_ANSWER => $theAnswer); $aid = $answer->add($newAnswer); $question->autoJoin(TABLE_ANSWER); //$newData['id']=$id; $data = $question->getAll(); $expected = array('_answer_id' => $aid, '_answer_answer' => $theAnswer, '_answer_question_id' => $qid, 'id' => $qid, 'question' => $theQuestion); // assertEquals doesnt sort arrays recursively, so we have to extract the data :-( // we cant do this: $this->assertEquals(array($newData),$question->getAll()); $this->assertEquals($expected, $data[0]); }