Пример #1
0
 protected function emptyTables()
 {
     $res1 = AuthorPeer::doDeleteAll();
     $res2 = PublisherPeer::doDeleteAll();
     $res3 = AuthorPeer::doDeleteAll();
     $res4 = ReviewPeer::doDeleteAll();
     $res5 = MediaPeer::doDeleteAll();
     $res6 = BookClubListPeer::doDeleteAll();
     $res7 = BookListRelPeer::doDeleteAll();
 }
 public function testCommitAfterFetch()
 {
     $con = Propel::getConnection(BookPeer::DATABASE_NAME);
     AuthorPeer::doDeleteAll($con);
     $a = new Author();
     $a->setFirstName('Test');
     $a->setLastName('User');
     $a->save($con);
     $con->beginTransaction();
     $stmt = $con->prepare('SELECT author.FIRST_NAME, author.LAST_NAME FROM author');
     $stmt->execute();
     $authorArr = array(0 => 'Test', 1 => 'User');
     $i = 0;
     $row = $stmt->fetch(PDO::FETCH_NUM);
     $stmt->closeCursor();
     $con->commit();
     $this->assertEquals($authorArr, $row, 'PDO driver supports calling $stmt->fetch before the transaction has been closed');
 }
 /**
  * @see http://www.propelorm.org/ticket/959
  */
 public function testFindOneWithSameRelatedObject()
 {
     BookPeer::doDeleteAll();
     AuthorPeer::doDeleteAll();
     $auth = new Author();
     $auth->setFirstName('John');
     $auth->save();
     $book1 = new Book();
     $book1->setTitle('Hello');
     $book1->setAuthor($auth);
     $book1->save();
     $book2 = new Book();
     $book2->setTitle('World');
     $book2->setAuthor($auth);
     $book2->save();
     BookPeer::clearInstancePool();
     AuthorPeer::clearInstancePool();
     $c = new ModelCriteria('bookstore', 'Book');
     $c->setFormatter(ModelCriteria::FORMAT_ARRAY);
     $c->join('Book.Author');
     $c->with('Author');
     $books = $c->find();
     $this->assertEquals(2, count($books));
     $firstBook = $books[0];
     $this->assertTrue(isset($firstBook['Author']));
     $secondBook = $books[1];
     $this->assertTrue(isset($secondBook['Author']));
 }
Пример #4
0
 /**
  * Test the doDeleteAll() method when onDelete="SETNULL".
  */
 public function testDoDeleteAll_SetNull()
 {
     $c = new Criteria();
     $c->add(BookPeer::AUTHOR_ID, null, Criteria::NOT_EQUAL);
     // 1) make sure there are some books with valid authors
     $this->assertTrue(count(BookPeer::doSelect($c)) > 0, "Expect some book.author_id columns that are not NULL.");
     // 2) delete all the authors
     AuthorPeer::doDeleteAll();
     // 3) now verify that the book.author_id columns are all nul
     $this->assertEquals(0, count(BookPeer::doSelect($c)), "Expect all book.author_id columns to be NULL.");
 }
The tests expect a model similar to this one:

    propel:
      article:
        id:          ~
        title:       varchar(255)

Beware that the tables for these models will be emptied by the tests, so use a test database connection.
*/

include dirname(__FILE__).'/../../bootstrap.php';

$con = Propel::getConnection();

// cleanup database
AuthorPeer::doDeleteAll();
CommentPeer::doDeleteAll();
CategoryPeer::doDeleteAll();
ArticlePeer::doDeleteAll();

$t = new lime_test(33, new lime_output_color());

$article1 = new Article();
$article1->setTitle('tt1');
$article1->save();
$article2 = new Article();
$article2->setTitle('tt2');
$article2->save();
$article3 = new Article();
$article3->setTitle('tt3');
$article3->save();
Пример #6
0
 public static function depopulate()
 {
     AcctAccessRolePeer::doDeleteAll();
     AuthorPeer::doDeleteAll();
     BookstorePeer::doDeleteAll();
     BookstoreContestPeer::doDeleteAll();
     BookstoreContestEntryPeer::doDeleteAll();
     BookstoreEmployeePeer::doDeleteAll();
     BookstoreEmployeeAccountPeer::doDeleteAll();
     BookstoreSalePeer::doDeleteAll();
     BookClubListPeer::doDeleteAll();
     BookOpinionPeer::doDeleteAll();
     BookReaderPeer::doDeleteAll();
     BookListRelPeer::doDeleteAll();
     BookPeer::doDeleteAll();
     ContestPeer::doDeleteAll();
     CustomerPeer::doDeleteAll();
     MediaPeer::doDeleteAll();
     PublisherPeer::doDeleteAll();
     ReaderFavoritePeer::doDeleteAll();
     ReviewPeer::doDeleteAll();
 }
 public static function depopulate($con = null)
 {
     if ($con === null) {
         $con = Propel::getConnection(BookPeer::DATABASE_NAME);
     }
     $con->beginTransaction();
     AuthorPeer::doDeleteAll($con);
     BookstorePeer::doDeleteAll($con);
     BookstoreContestPeer::doDeleteAll($con);
     BookstoreContestEntryPeer::doDeleteAll($con);
     BookstoreEmployeePeer::doDeleteAll($con);
     BookstoreEmployeeAccountPeer::doDeleteAll($con);
     BookstoreSalePeer::doDeleteAll($con);
     BookClubListPeer::doDeleteAll($con);
     BookOpinionPeer::doDeleteAll($con);
     BookReaderPeer::doDeleteAll($con);
     BookListRelPeer::doDeleteAll($con);
     BookPeer::doDeleteAll($con);
     ContestPeer::doDeleteAll($con);
     CustomerPeer::doDeleteAll($con);
     MediaPeer::doDeleteAll($con);
     PublisherPeer::doDeleteAll($con);
     ReaderFavoritePeer::doDeleteAll($con);
     ReviewPeer::doDeleteAll($con);
     $con->commit();
 }