public function testMagicFind() { $con = Propel::getServiceContainer()->getConnection(BookTableMap::DATABASE_NAME); $c = new ModelCriteria('bookstore', 'Propel\\Tests\\Bookstore\\Book'); $books = $c->findByTitle('Don Juan'); $expectedSQL = $this->getSql("SELECT book.id, book.title, book.isbn, book.price, book.publisher_id, book.author_id FROM book WHERE book.title='Don Juan'"); $this->assertEquals($expectedSQL, $con->getLastExecutedQuery(), 'findByXXX($value) is turned into findBy(XXX, $value)'); $c = new ModelCriteria('bookstore', 'Propel\\Tests\\Bookstore\\Book'); $books = $c->findByTitleAndISBN('Don Juan', 1234); $expectedSQL = $this->getSql("SELECT book.id, book.title, book.isbn, book.price, book.publisher_id, book.author_id FROM book WHERE book.title='Don Juan' AND book.isbn=1234"); $this->assertEquals($expectedSQL, $con->getLastExecutedQuery(), 'findByXXXAndYYY($value) is turned into findBy(array(XXX,YYY), $value)'); $c = new ModelCriteria('bookstore', 'Propel\\Tests\\Bookstore\\Book'); $book = $c->findOneByTitle('Don Juan'); $expectedSQL = $this->getSql("SELECT book.id, book.title, book.isbn, book.price, book.publisher_id, book.author_id FROM book WHERE book.title='Don Juan' LIMIT 1"); $this->assertEquals($expectedSQL, $con->getLastExecutedQuery(), 'findOneByXXX($value) is turned into findOneBy(XXX, $value)'); $c = new ModelCriteria('bookstore', 'Propel\\Tests\\Bookstore\\Book'); $book = $c->findOneByTitleAndISBN('Don Juan', 1234); $expectedSQL = $this->getSql("SELECT book.id, book.title, book.isbn, book.price, book.publisher_id, book.author_id FROM book WHERE book.title='Don Juan' AND book.isbn=1234 LIMIT 1"); $this->assertEquals($expectedSQL, $con->getLastExecutedQuery(), 'findOneByXXX($value) is turned into findOneBy(XXX, $value)'); }
public function testMagicFind() { $con = Propel::getServiceContainer()->getConnection(BookTableMap::DATABASE_NAME); $c = new ModelCriteria('bookstore', 'Propel\\Tests\\Bookstore\\Book'); $books = $c->findByTitle('Don Juan'); $expectedSQL = $this->getSql("SELECT book.ID, book.TITLE, book.ISBN, book.PRICE, book.PUBLISHER_ID, book.AUTHOR_ID FROM `book` WHERE book.TITLE='Don Juan'"); $this->assertEquals($expectedSQL, $con->getLastExecutedQuery(), 'findByXXX($value) is turned into findBy(XXX, $value)'); $c = new ModelCriteria('bookstore', 'Propel\\Tests\\Bookstore\\Book'); $books = $c->findByTitleAndISBN('Don Juan', 1234); $expectedSQL = $this->getSql("SELECT book.ID, book.TITLE, book.ISBN, book.PRICE, book.PUBLISHER_ID, book.AUTHOR_ID FROM `book` WHERE book.TITLE='Don Juan' AND book.ISBN=1234"); $this->assertEquals($expectedSQL, $con->getLastExecutedQuery(), 'findByXXXAndYYY($value) is turned into findBy(array(XXX,YYY), $value)'); $c = new ModelCriteria('bookstore', 'Propel\\Tests\\Bookstore\\Book'); $book = $c->findOneByTitle('Don Juan'); $expectedSQL = $this->getSql("SELECT book.ID, book.TITLE, book.ISBN, book.PRICE, book.PUBLISHER_ID, book.AUTHOR_ID FROM `book` WHERE book.TITLE='Don Juan' LIMIT 1"); $this->assertEquals($expectedSQL, $con->getLastExecutedQuery(), 'findOneByXXX($value) is turned into findOneBy(XXX, $value)'); $c = new ModelCriteria('bookstore', 'Propel\\Tests\\Bookstore\\Book'); $book = $c->findOneByTitleAndISBN('Don Juan', 1234); $expectedSQL = $this->getSql("SELECT book.ID, book.TITLE, book.ISBN, book.PRICE, book.PUBLISHER_ID, book.AUTHOR_ID FROM `book` WHERE book.TITLE='Don Juan' AND book.ISBN=1234 LIMIT 1"); $this->assertEquals($expectedSQL, $con->getLastExecutedQuery(), 'findOneByXXX($value) is turned into findOneBy(XXX, $value)'); }