/**
  * @expectedException PropelException
  */
 public function testSaveOnReadOnlyEntityThrowsException()
 {
     $col = new PropelObjectCollection();
     $col->setModel('ContestView');
     $cv = new ContestView();
     $col[] = $cv;
     $col->save();
 }
 protected function createBooks($nb = 15, $con = null)
 {
     BookQuery::create()->deleteAll($con);
     $books = new PropelObjectCollection();
     $books->setModel('Book');
     for ($i = 0; $i < $nb; $i++) {
         $b = new Book();
         $b->setTitle('Book' . $i);
         $books[] = $b;
     }
     $books->save($con);
 }
 public function testFromArray()
 {
     $author = new Author();
     $author->setFirstName('Jane');
     $author->setLastName('Austen');
     $author->save();
     $books = array(array('Title' => 'Mansfield Park', 'AuthorId' => $author->getId()), array('Title' => 'Pride And PRejudice', 'AuthorId' => $author->getId()));
     $col = new PropelObjectCollection();
     $col->setModel('Book');
     $col->fromArray($books);
     $col->save();
     $nbBooks = PropelQuery::from('Book')->count();
     $this->assertEquals(6, $nbBooks);
     $booksByJane = PropelQuery::from('Book b')->join('b.Author a')->where('a.LastName = ?', 'Austen')->count();
     $this->assertEquals(2, $booksByJane);
 }
 protected function populateCreatedAt()
 {
     Table2Query::create()->deleteAll();
     $ts = new PropelObjectCollection();
     $ts->setModel('Table2');
     for ($i = 0; $i < 10; $i++) {
         $t = new Table2();
         $t->setTitle('CreatedAt' . $i);
         $t->setCreatedAt(time() - $i * 24 * 60 * 60 - 30);
         $ts[] = $t;
     }
     $ts->save();
 }