function test_tableEqualsColumnJoinedGetAll()
 {
     $theQuestion = 'Why does this not work?';
     $theAnswer = 'I dont know!';
     $question = new MDB_QT(TABLE_QUESTION);
     $question->removeAll();
     $newQuest = array(TABLE_QUESTION => $theQuestion);
     $qid = $question->add($newQuest);
     $answer = new MDB_QT(TABLE_ANSWER);
     $answer->removeAll();
     $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->assertEqual($expected, $data[0]);
 }
Пример #2
0
 function test_innerJoin()
 {
     $theQuestion = 'Why does this not work?';
     $theAnswer = 'I dont know!';
     $question = new MDB_QT(TABLE_QUESTION);
     $question->removeAll();
     $newQuest = array(TABLE_QUESTION => $theQuestion);
     $qid = $question->add($newQuest);
     $answer = new MDB_QT(TABLE_ANSWER);
     $answer->removeAll();
     $newAnswer = array(TABLE_QUESTION . '_id' => $qid, TABLE_ANSWER => $theAnswer);
     $aid = $answer->add($newAnswer);
     $question->setJoin(TABLE_ANSWER, TABLE_QUESTION . '.id = ' . TABLE_ANSWER . '.question_id', 'inner');
     $data = $question->getAll();
     if (DB_TYPE == 'ibase') {
         $expected = array('t_answer_id' => $aid, 't_answer_answer' => $theAnswer, 't_answer_question_id' => $qid, 'id' => $qid, 'question' => $theQuestion);
     } else {
         $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->assertEqual($expected, $data[0]);
 }