public function testMagicOrderBy() { $con = Propel::getServiceContainer()->getConnection(BookTableMap::DATABASE_NAME); $c = new ModelCriteria('bookstore', 'Propel\\Tests\\Bookstore\\Book'); $books = $c->orderByTitle()->find($con); $expectedSQL = $this->getSql("SELECT book.id, book.title, book.isbn, book.price, book.publisher_id, book.author_id FROM book ORDER BY book.title ASC"); $this->assertEquals($expectedSQL, $con->getLastExecutedQuery(), 'orderByXXX() is turned into orderBy(XXX)'); $c = new ModelCriteria('bookstore', 'Propel\\Tests\\Bookstore\\Book'); $books = $c->orderByTitle(Criteria::DESC)->find($con); $expectedSQL = $this->getSql("SELECT book.id, book.title, book.isbn, book.price, book.publisher_id, book.author_id FROM book ORDER BY book.title DESC"); $this->assertEquals($expectedSQL, $con->getLastExecutedQuery(), 'orderByXXX($direction) is turned into orderBy(XXX, $direction)'); }
public function testMagicOrderBy() { $con = Propel::getServiceContainer()->getConnection(BookTableMap::DATABASE_NAME); $c = new ModelCriteria('bookstore', 'Propel\\Tests\\Bookstore\\Book'); $books = $c->orderByTitle()->find($con); $expectedSQL = $this->getSql("SELECT book.ID, book.TITLE, book.ISBN, book.PRICE, book.PUBLISHER_ID, book.AUTHOR_ID FROM `book` ORDER BY book.TITLE ASC"); $this->assertEquals($expectedSQL, $con->getLastExecutedQuery(), 'orderByXXX() is turned into orderBy(XXX)'); $c = new ModelCriteria('bookstore', 'Propel\\Tests\\Bookstore\\Book'); $books = $c->orderByTitle(Criteria::DESC)->find($con); $expectedSQL = $this->getSql("SELECT book.ID, book.TITLE, book.ISBN, book.PRICE, book.PUBLISHER_ID, book.AUTHOR_ID FROM `book` ORDER BY book.TITLE DESC"); $this->assertEquals($expectedSQL, $con->getLastExecutedQuery(), 'orderByXXX($direction) is turned into orderBy(XXX, $direction)'); }