public function testCommitAfterFetch() { $con = Propel::getServiceContainer()->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', 'Propel\\Tests\\Bookstore\\Book'); $c->setFormatter(ModelCriteria::FORMAT_ARRAY); $c->join('Propel\\Tests\\Bookstore\\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'])); }
/** * 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."); }