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('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('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('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('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('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'); }