Beispiel #1
0
 public function testMagicFind()
 {
     $con = Propel::getConnection(BookPeer::DATABASE_NAME);
     $c = new ModelCriteria('bookstore', 'Book');
     $books = $c->findByTitle('Don Juan');
     $expectedSQL = "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', 'Book');
     $books = $c->findByTitleAndISBN('Don Juan', 1234);
     $expectedSQL = "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', 'Book');
     $book = $c->findOneByTitle('Don Juan');
     $expectedSQL = "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', 'Book');
     $book = $c->findOneByTitleAndISBN('Don Juan', 1234);
     $expectedSQL = "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::getConnection(BookPeer::DATABASE_NAME);
     $c = new ModelCriteria('bookstore', 'Book');
     $books = $c->findByTitle('Don Juan');
     $expectedSQL = "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', 'Book');
     $books = $c->findByTitleAndISBN('Don Juan', 1234);
     $expectedSQL = "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', 'Book');
     $book = $c->findOneByTitle('Don Juan');
     $expectedSQL = "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', 'Book');
     $book = $c->findOneByTitleAndISBN('Don Juan', 1234);
     $expectedSQL = "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)');
 }