Пример #1
0
 public function testClear()
 {
     $b = new Book();
     $b->setNew(false);
     $b->clear();
     $this->assertTrue($b->isNew(), 'clear() sets the object to new');
     $b = new Book();
     $b->setDeleted(true);
     $b->clear();
     $this->assertFalse($b->isDeleted(), 'clear() sets the object to not deleted');
 }
Пример #2
0
 public function testSaveCanInsertNonEmptyObjects()
 {
     $b = new Book();
     $b->setTitle('foo');
     $b->setISBN('FA404');
     $b->save();
     $this->assertFalse($b->isNew());
     $this->assertNotNull($b->getId());
 }
Пример #3
0
 public function testSetterCollectionWithManyToManyModifiedByReferenceWithAnExistingObject()
 {
     // Ensure no data
     BookQuery::create()->deleteAll();
     BookClubListQuery::create()->deleteAll();
     BookListRelQuery::create()->deleteAll();
     $book = new Book();
     $book->setTitle('foo');
     $book->setISBN('01234');
     $book->save();
     // The object isn't "new"
     $this->assertFalse($book->isNew());
     $bookClubList = new BookClubList();
     $books = $bookClubList->getBooks();
     // Add the object by reference
     $books[] = $book;
     $bookClubList->setBooks($books);
     $bookClubList->setGroupLeader('TestLeader');
     $bookClubList->save();
     $this->assertEquals(1, BookQuery::create()->count());
     $this->assertEquals(1, BookListRelQuery::create()->count());
     $this->assertEquals(1, BookClubListQuery::create()->count());
 }