public function testGetLeftPhpName() { $q = AuthorQuery::create()->joinBook(); $joins = $q->getJoins(); $join = $joins['Book']; $with = new ModelWith($join); $this->assertNull($with->getLeftPhpName(), 'A ModelWith initialized from a primary join has a null left phpName'); $q = AuthorQuery::create('a')->joinBook(); $joins = $q->getJoins(); $join = $joins['Book']; $with = new ModelWith($join); $this->assertNull($with->getLeftPhpName(), 'A ModelWith initialized from a primary join with alias has a null left phpName'); $q = AuthorQuery::create()->joinBook('b'); $joins = $q->getJoins(); $join = $joins['b']; $with = new ModelWith($join); $this->assertNull($with->getLeftPhpName(), 'A ModelWith initialized from a primary join with alias has a null left phpName'); $q = AuthorQuery::create()->join('Propel\\Tests\\Bookstore\\Author.Book')->join('Book.Publisher'); $joins = $q->getJoins(); $join = $joins['Publisher']; $with = new ModelWith($join); $this->assertEquals('Book', $with->getLeftPhpName(), 'A ModelWith uses the previous join relation name as left phpName'); $q = ReviewQuery::create()->join('Propel\\Tests\\Bookstore\\Review.Book')->join('Book.Author')->join('Book.Publisher'); $joins = $q->getJoins(); $join = $joins['Publisher']; $with = new ModelWith($join); $this->assertEquals('Book', $with->getLeftPhpName(), 'A ModelWith uses the previous join relation name as left phpName'); $q = ReviewQuery::create()->join('Propel\\Tests\\Bookstore\\Review.Book')->join('Book.BookOpinion')->join('BookOpinion.BookReader'); $joins = $q->getJoins(); $join = $joins['BookOpinion']; $with = new ModelWith($join); $this->assertEquals('Book', $with->getLeftPhpName(), 'A ModelWith uses the previous join relation name as left phpName'); $join = $joins['BookReader']; $with = new ModelWith($join); $this->assertEquals('BookOpinion', $with->getLeftPhpName(), 'A ModelWith uses the previous join relation name as left phpName'); $q = BookReaderQuery::create()->join('Propel\\Tests\\Bookstore\\BookReader.BookOpinion')->join('BookOpinion.Book')->join('Book.Author'); $joins = $q->getJoins(); $join = $joins['Book']; $with = new ModelWith($join); $this->assertEquals('BookOpinion', $with->getLeftPhpName(), 'A ModelWith uses the previous join relation name as related class'); $join = $joins['Author']; $with = new ModelWith($join); $this->assertEquals('Book', $with->getLeftPhpName(), 'A ModelWith uses the previous join relation name as left phpName'); $q = BookSummaryQuery::create()->join('Propel\\Tests\\Bookstore\\BookSummary.SummarizedBook')->join('SummarizedBook.Author'); $joins = $q->getJoins(); $join = $joins['Author']; $with = new ModelWith($join); $this->assertEquals('SummarizedBook', $with->getLeftPhpName(), 'A ModelWith uses the previous join relation name as left phpName'); }
/** * @see testDoDeleteCompositePK() */ private function createReaderWithId($id) { $con = Propel::getServiceContainer()->getConnection(BookReaderTableMap::DATABASE_NAME); $r = BookReaderQuery::create()->findPk($id); if (!$r) { $r = new BookReader(); $r->setName('Reader' . $id)->save(); $r1Id = $r->getId(); $sql = "UPDATE " . BookReaderTableMap::TABLE_NAME . " SET id = ? WHERE id = ?"; $stmt = $con->prepare($sql); $stmt->bindValue(1, $id); $stmt->bindValue(2, $r1Id); $stmt->execute(); } }