function runBookInsertion($i)
 {
     $book = new Book();
     $book->setTitle('Hello' . $i);
     $book->setAuthorId($this->authors[array_rand($this->authors)]);
     $book->setISBN('1234');
     $book->setPrice($i);
     $book->save($this->con);
     $this->books[] = $book->getId();
 }
 protected function setUp()
 {
     parent::setUp();
     $book1 = new Book();
     $book1->setId(9012);
     $book1->setTitle('Don Juan');
     $book1->setISBN('0140422161');
     $book1->setPrice(12.99);
     $book1->setAuthorId(5678);
     $book1->setPublisherId(1234);
     $book1->resetModified();
     $book2 = new Book();
     $book2->setId(58);
     $book2->setTitle('Harry Potter and the Order of the Phoenix');
     $book2->setISBN('043935806X');
     $book2->setPrice(10.99);
     $book2->resetModified();
     $this->coll = new PropelObjectCollection();
     $this->coll->setModel('Book');
     $this->coll[] = $book1;
     $this->coll[] = $book2;
 }
예제 #3
0
 public function testLoadObject()
 {
     $newAuthor = new Author();
     $newAuthor->setName('James Joyce');
     $newAuthor->setCreationDatetime(date('Y-m-d H:i:s'));
     $newAuthor->save();
     $newBook = new Book();
     $newBook->setTitle('Ulysses');
     $newBook->setAuthorId($newAuthor->getAuthorId());
     $newBook->setIntroduction('1264 pages of bs by one of the masters.');
     $newBook->setCreationDatetime(date('Y-m-d H:i:s'));
     $newBook->save();
     $sameBook = Book::constructByKey($newBook->getBookId());
     // this one fails; see ticket #27, http://trac.coughphp.com/ticket/27
     //$this->assertIdentical($newBook->getBookId(), $sameBook->getBookId());
     $this->assertEqual($newBook->getBookId(), $sameBook->getBookId());
     $this->assertIdentical($newBook->getTitle(), $sameBook->getTitle());
     // again, this is broke; see ticket #27
     //$this->assertIdentical($newBook->getAuthorId(), $sameBook->getAuthorId());
     $this->assertEqual($newBook->getAuthorId(), $sameBook->getAuthorId());
     $this->assertIdentical($newBook->getIntroduction(), $sameBook->getIntroduction());
     $this->assertIdentical($newBook->getCreationDatetime(), $sameBook->getCreationDatetime());
 }
예제 #4
0
 public function addBook(Book $object)
 {
     $object->setAuthorId($this->getAuthorId());
     $object->setAuthor_Object($this);
     $this->getBook_Collection()->add($object);
     return $object;
 }