当前位置: 首页>>代码示例>>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;未经允许,请勿转载。