當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Author::getBooks方法代碼示例

本文整理匯總了PHP中Author::getBooks方法的典型用法代碼示例。如果您正苦於以下問題:PHP Author::getBooks方法的具體用法?PHP Author::getBooks怎麽用?PHP Author::getBooks使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Author的用法示例。


在下文中一共展示了Author::getBooks方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: testAddBook

 function testAddBook()
 {
     //Arrange
     $name = "Ben";
     $test_author = new Author($name);
     $test_author->save();
     $book_name = "Intro to Art";
     $test_book = new Book($book_name);
     $test_book->save();
     //Act
     $test_author->addBook($test_book);
     //Assert
     $this->assertEquals($test_author->getBooks(), [$test_book]);
 }
開發者ID:kevintokheim,項目名稱:Library,代碼行數:14,代碼來源:AuthorTest.php

示例2: testRemoveObjectOneToMany

 public function testRemoveObjectOneToMany()
 {
     BookQuery::create()->deleteAll();
     AuthorQuery::create()->deleteAll();
     $book = new Book();
     $book->setTitle('Propel Book');
     $book2 = new Book();
     $book2->setTitle('Propel2 Book');
     $author = new Author();
     $author->setFirstName('François');
     $author->setLastName('Z');
     $author->addBook($book);
     $author->addBook($book2);
     $this->assertCount(2, $author->getBooks());
     $author->removeBook($book);
     $books = $author->getBooks();
     $this->assertCount(1, $books);
     $this->assertEquals('Propel2 Book', reset($books)->getTitle());
     $author->save();
     $book->save();
     $book2->save();
     $this->assertEquals(2, BookQuery::create()->count(), 'Two Book');
     $this->assertEquals(1, AuthorQuery::create()->count(), 'One Author');
     $this->assertEquals(1, BookQuery::create()->filterByAuthor($author)->count());
     $author->addBook($book);
     $author->save();
     $this->assertEquals(2, BookQuery::create()->filterByAuthor($author)->count());
     $author->removeBook($book2);
     $author->save();
     $this->assertEquals(1, BookQuery::create()->filterByAuthor($author)->count());
     $this->assertEquals(2, BookQuery::create()->count(), 'Two Book because FK is not required so book is not delete when removed from author\'s book collection');
 }
開發者ID:natecj,項目名稱:Propel,代碼行數:32,代碼來源:GeneratedObjectRelTest.php

示例3: testSetUp

 public function testSetUp()
 {
     $this->assertTrue(Propel::isInstancePoolingEnabled());
     $this->assertEquals(2, count($this->author->getBooks()));
     $this->assertEquals(2, $this->author->countBooks());
 }
開發者ID:kcornejo,項目名稱:estadistica,代碼行數:6,代碼來源:PoisonedCacheBugTest.php

示例4: testGetBooks

 function testGetBooks()
 {
     $title = "Kama Sutra";
     $id = 1;
     $test_book = new Book($title, $id);
     $test_book->save();
     $title2 = "Oh Yeah";
     $id2 = 2;
     $test_book2 = new Book($title2, $id2);
     $test_book2->save();
     $name = "Uncle Ben";
     $id3 = 3;
     $test_author = new Author($name, $id3);
     $test_author->save();
     //Act
     $test_author->addBook($test_book);
     $test_author->addBook($test_book2);
     //Assert
     $this->assertEquals($test_author->getBooks(), [$test_book, $test_book2]);
 }
開發者ID:bencasalino,項目名稱:library_day1,代碼行數:20,代碼來源:AuthorTest.php

示例5: Author

 function test_deleteAllBooks()
 {
     //Arrange
     $name = "Benjamin";
     // $id = 1;
     $test_author = new Author($name);
     $test_author->save();
     $title = "Book Title";
     // $id2 = 1;
     $test_book = new Book($title);
     $test_book->save();
     $title = "Book Title2";
     // $id3 = 2;
     $test_book2 = new Book($title);
     $test_book2->save();
     $test_author->addBook($test_book);
     $test_author->addBook($test_book2);
     //Act
     $test_author->deleteAllBooks();
     $result = $test_author->getBooks();
     //Assert
     $this->assertEquals([], $result);
 }
開發者ID:jlbethel,項目名稱:library-1,代碼行數:23,代碼來源:AuthorTest.php

示例6: testSetterOneToManyReplacesOldObjectsByNewObjects

 public function testSetterOneToManyReplacesOldObjectsByNewObjects()
 {
     // Ensure no data
     BookQuery::create()->deleteAll();
     AuthorQuery::create()->deleteAll();
     $books = new PropelObjectCollection();
     foreach (array('foo', 'bar') as $title) {
         $b = new Book();
         $b->setTitle($title);
         $books[] = $b;
     }
     $a = new Author();
     $a->setBooks($books);
     $a->save();
     $books = $a->getBooks();
     $this->assertEquals('foo', $books[0]->getTitle());
     $this->assertEquals('bar', $books[1]->getTitle());
     $books = new PropelObjectCollection();
     foreach (array('bam', 'bom') as $title) {
         $b = new Book();
         $b->setTitle($title);
         $books[] = $b;
     }
     $a->setBooks($books);
     $a->save();
     $books = $a->getBooks();
     $this->assertEquals('bam', $books[0]->getTitle());
     $this->assertEquals('bom', $books[1]->getTitle());
     $this->assertEquals(1, AuthorQuery::create()->count());
     $this->assertEquals(2, BookQuery::create()->count());
 }
開發者ID:ratibus,項目名稱:Crew,代碼行數:31,代碼來源:GeneratedObjectTest.php

示例7: testGetBooks

 function testGetBooks()
 {
     //Arrange
     $author_name = "Super Dog";
     $id2 = 2;
     $test_author = new Author($author_name, $id2);
     $test_author->save();
     $book_title = "Snow Crash";
     $id = null;
     $test_book = new Book($book_title, $id);
     $test_book->save();
     $book_title2 = "Ready Player One";
     $id2 = null;
     $test_book2 = new Book($book_title2, $id2);
     $test_book2->save();
     //Act
     $test_author->addBook($test_book);
     $test_author->addBook($test_book2);
     $result = $test_author->getBooks();
     //Assert
     $this->assertEquals($result, [$test_book, $test_book2]);
 }
開發者ID:juliocesardiaz,項目名稱:library-1,代碼行數:22,代碼來源:AuthorTest.php

示例8: testGetBooks

 function testGetBooks()
 {
     $name = "Stephen King";
     $test_author = new Author($name);
     $test_author->save();
     $title = "Carrie";
     $test_book = new Book($title);
     $test_book->save();
     $test_author->addBook($test_book);
     $title2 = "Misery";
     $test_book2 = new Book($title2);
     $test_book2->save();
     $test_author->addBook($test_book2);
     $this->assertEquals([$test_book, $test_book2], $test_author->getBooks());
 }
開發者ID:umamiMike,項目名稱:Library,代碼行數:15,代碼來源:AuthorTest.php

示例9: testGetBooks

 function testGetBooks()
 {
     //Arrange
     $name = "JK Rowling";
     $id = 1;
     $test_author = new Author($name, $id);
     $test_author->save();
     $title = "Harry Potter";
     $id = 1;
     $test_book = new Book($title, $id);
     $test_book->save();
     $title2 = "Moby Dick";
     $id2 = 2;
     $test_book2 = new Book($title, $id);
     $test_book2->save();
     //Act
     $test_author->addBook($test_book);
     $test_author->addBook($test_book2);
     $result = $test_author->getBooks();
     //Assert
     $this->assertEquals([$test_book, $test_book2], $result);
 }
開發者ID:bborealis,項目名稱:library,代碼行數:22,代碼來源:AuthorTest.php

示例10: Author

 function test_addBook_getBooks()
 {
     $name = "Jerry Garcia";
     $test_author = new Author($name);
     $test_author->save();
     $name2 = "Frank Sinatra";
     $test_author2 = new Author($name2);
     $test_author2->save();
     $book_title = "Three Blind Mice";
     $test_book = new Book($book_title);
     $test_book->save();
     $test_author->addBook($test_book);
     $result = $test_author->getBooks();
     $this->assertEquals([$test_book], $result);
 }
開發者ID:nathanhwyoung,項目名稱:Library-2,代碼行數:15,代碼來源:AuthorTest.php

示例11: Author

 function test_getBooks()
 {
     $name = "Roberto Bolano";
     $test_author = new Author($name);
     $test_author->save();
     $title = "Infinite Jest";
     $test_book = new Book($title);
     $test_book->save();
     $title2 = "Infinite Jest";
     $test_book2 = new Book($title2);
     $test_book2->save();
     //Act
     $test_author->addBook($test_book2);
     $test_author->addBook($test_book);
     $result = $test_author->getBooks();
     //Assert
     $this->assertEquals([$test_book, $test_book2], $result);
 }
開發者ID:kevintokheim,項目名稱:Liberry,代碼行數:18,代碼來源:AuthorTest.php

示例12: Author

 function test_addBook()
 {
     //Arrange
     $author_name = "Jack London";
     $test_author = new Author($author_name);
     $test_author->save();
     $title = "Sea Wolf";
     $test_book = new Book($title);
     $test_book->save();
     //Act
     $result = [$test_book];
     $test_author->addBook($test_book);
     //Assert
     $this->assertEquals($test_author->getBooks(), $result);
 }
開發者ID:jlbethel,項目名稱:Library,代碼行數:15,代碼來源:AuthorTest.php

示例13: Author

 function test_getBooks()
 {
     //Arrange
     $name = "Bob";
     $test_author = new Author($name);
     $test_author->save();
     $title = "dog book";
     $test_book = new Book($title);
     $test_book->save();
     $title2 = "History of nothing";
     $test_book2 = new Book($title2);
     $test_book2->save();
     //Act
     $test_author->addBook($test_book);
     $test_author->addBook($test_book2);
     //Assert
     $result = $test_author->getBooks();
     $this->assertEquals([$test_book, $test_book2], $result);
 }
開發者ID:r-hills,項目名稱:Library,代碼行數:19,代碼來源:AuthorTest.php

示例14: testGetBooks

 function testGetBooks()
 {
     //Arrange
     $name = "Paul Jones";
     $id = 1;
     $test_author = new Author($name, $id);
     $test_author->save();
     $title = "Little Cat";
     $id = 1;
     $test_book = new Book($title, $id);
     $test_book->save();
     $title2 = "Little Dog";
     $id2 = 2;
     $test_book2 = new Book($title2, $id2);
     $test_book2->save();
     //Act
     $test_author->addBook($test_book);
     $test_author->addBook($test_book2);
     $result = $test_author->getBooks();
     //Assert
     $this->assertEquals([$test_book, $test_book2], $result);
 }
開發者ID:bborealis,項目名稱:library-1,代碼行數:22,代碼來源:AuthorTest.php

示例15: Author

 function test_getBooks()
 {
     //Arrange
     $name = "Pladoh";
     $test_author = new Author($name);
     $test_author->save();
     $title = "Theory of Everything and Nothing at All";
     $genre = "Nonsense";
     $test_book = new Book($title, $genre);
     $test_book->save();
     $title2 = "Philosoraptor: A Memoir";
     $genre2 = "Alternate History/Dinosaurs";
     $test_book2 = new Book($title, $genre);
     $test_book2->save();
     //Act
     $test_author->addBook($test_book);
     $test_author->addBook($test_book2);
     //Assert
     $this->assertEquals($test_author->getBooks(), [$test_book, $test_book2]);
 }
開發者ID:r-hills,項目名稱:library-1,代碼行數:20,代碼來源:AuthorTest.php


注:本文中的Author::getBooks方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。