public function testFilterByRefFkCompositeKey() { BookstoreDataPopulator::depopulate(); BookstoreDataPopulator::populate(); BookstoreDataPopulator::populateOpinionFavorite(); // prepare the test data $testOpinion = BookOpinionQuery::create()->innerJoin('BookOpinion.ReaderFavorite')->findOne(); $testFavorite = $testOpinion->getReaderFavorite(); $opinion = BookOpinionQuery::create()->filterByReaderFavorite($testFavorite)->findOne(); $this->assertEquals($testOpinion, $opinion, 'Generated query handles filterByRefFk() methods correctly for composite fkeys'); }
/** * Test the effect of typecast on primary key values and instance pool retrieval. */ public function testObjectInstancePoolTypecasting() { $reader = new BookReader(); $reader->setName("Tester"); $reader->save(); $readerId = $reader->getId(); $book = new Book(); $book->setTitle("BookTest"); $book->setISBN("TEST"); $book->save(); $bookId = $book->getId(); $opinion = new BookOpinion(); $opinion->setBookId((string) $bookId); $opinion->setReaderId((string) $readerId); $opinion->setRating(5); $opinion->setRecommendToFriend(false); $opinion->save(); $opinion2 = BookOpinionQuery::create()->findPk(array($bookId, $readerId)); $this->assertSame($opinion, $opinion2, "Expected same object to be retrieved from differently type-casted primary key values."); }