public function testDoInsert()
 {
     try {
         $c = new Criteria();
         $c->setPrimaryTableName(BookPeer::TABLE_NAME);
         $c->add(BookPeer::AUTHOR_ID, 'lkhlkhj');
         BasePeer::doInsert($c, Propel::getServiceContainer()->getWriteConnection(BookPeer::DATABASE_NAME));
     } catch (RuntimeException $e) {
         $this->assertContains('[INSERT INTO `book` (`AUTHOR_ID`) VALUES (:p1)]', $e->getMessage(), 'SQL query is written in the exception message');
     }
 }
Exemple #2
0
 public function testCommentDoUpdate()
 {
     $c1 = new Criteria();
     $c1->setPrimaryTableName(BookPeer::TABLE_NAME);
     $c1->setComment('Foo');
     $c2 = new Criteria();
     $c2->add(BookPeer::TITLE, 'Updated Title');
     $con = Propel::getServiceContainer()->getConnection(BookPeer::DATABASE_NAME);
     BasePeer::doUpdate($c1, $c2, $con);
     $expected = 'UPDATE /* Foo */ `book` SET `TITLE`=\'Updated Title\'';
     $this->assertEquals($expected, $con->getLastExecutedQuery(), 'Criteria::setComment() adds a comment to update queries');
 }