Exemple #1
0
 public function testSetRelationMapComposite()
 {
     $table = ReaderFavoritePeer::getTableMap();
     $join = new ModelJoin();
     $join->setTableMap($table);
     $join->setRelationMap($table->getRelation('BookOpinion'));
     $this->assertEquals(array(ReaderFavoritePeer::BOOK_ID, ReaderFavoritePeer::READER_ID), $join->getLeftColumns(), 'setRelationMap() automatically sets the left columns for composite relationships');
     $this->assertEquals(array(BookOpinionPeer::BOOK_ID, BookOpinionPeer::READER_ID), $join->getRightColumns(), 'setRelationMap() automatically sets the right columns for composite relationships');
 }
 public function testUseFkQueryTwiceTwoAliases()
 {
     $q = BookQuery::create()->useAuthorQuery('a')->filterByFirstName('Leo')->endUse()->useAuthorQuery('b')->filterByLastName('Tolstoi')->endUse();
     $join1 = new ModelJoin();
     $join1->setJoinType(Criteria::LEFT_JOIN);
     $join1->setTableMap(AuthorPeer::getTableMap());
     $join1->setRelationMap(BookPeer::getTableMap()->getRelation('Author'), null, 'a');
     $join1->setRelationAlias('a');
     $join2 = new ModelJoin();
     $join2->setJoinType(Criteria::LEFT_JOIN);
     $join2->setTableMap(AuthorPeer::getTableMap());
     $join2->setRelationMap(BookPeer::getTableMap()->getRelation('Author'), null, 'b');
     $join2->setRelationAlias('b');
     $q1 = BookQuery::create()->addAlias('a', AuthorPeer::TABLE_NAME)->addJoinObject($join1, 'a')->add('a.FIRST_NAME', 'Leo', Criteria::EQUAL)->addAlias('b', AuthorPeer::TABLE_NAME)->addJoinObject($join2, 'b')->add('b.LAST_NAME', 'Tolstoi', Criteria::EQUAL);
     $this->assertTrue($q->equals($q1), 'useFkQuery() called twice on the same relation with two aliases creates two joins');
 }