当前位置: 首页>>代码示例>>PHP>>正文


PHP Book::getAuthors方法代码示例

本文整理汇总了PHP中Book::getAuthors方法的典型用法代码示例。如果您正苦于以下问题:PHP Book::getAuthors方法的具体用法?PHP Book::getAuthors怎么用?PHP Book::getAuthors使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Book的用法示例。


在下文中一共展示了Book::getAuthors方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: testGetAuthors

 function testGetAuthors()
 {
     //Arrange
     $book_title = "Snow Crash";
     $id = 1;
     $test_book = new Book($book_title, $id);
     $test_book->save();
     $author_name = "Super Dog";
     $id2 = 2;
     $test_author = new Author($author_name, $id2);
     $test_author->save();
     $author_name2 = "Neal Stephenson";
     $id3 = 3;
     $test_author2 = new Author($author_name2, $id3);
     $test_author2->save();
     //Act
     $test_book->addAuthor($test_author);
     $test_book->addAuthor($test_author2);
     $result = $test_book->getAuthors();
     //Assert
     $this->assertEquals($result, [$test_author, $test_author2]);
 }
开发者ID:kylepratuch,项目名称:library-1,代码行数:22,代码来源:BookTest.php

示例2: testGetAuthors

 function testGetAuthors()
 {
     $title = "Carrie";
     $test_book = new Book($title);
     $test_book->save();
     $name = "Stephen King";
     $test_author = new Author($name);
     $test_author->save();
     $name2 = "Joe Hill";
     $test_author2 = new Author($name2);
     $test_author2->save();
     $test_book->addAuthor($test_author);
     $test_book->addAuthor($test_author2);
     $this->assertEquals([$test_author2, $test_author], $test_book->getAuthors());
 }
开发者ID:umamiMike,项目名称:library-1,代码行数:15,代码来源:BookTest.php

示例3: testUpdateAuthor

 function testUpdateAuthor()
 {
     $name = "Uncle Ben";
     $id3 = 3;
     $test_author = new Author($name, $id3);
     $test_author->save();
     $name2 = "Goof Ball";
     $id2 = 2;
     $test_author2 = new Author($name2, $id2);
     $test_author2->save();
     $title = "Kama Sutra";
     $id = 1;
     $test_book = new Book($title, $id);
     $test_book->save();
     //Act
     $test_book->addAuthor($test_author);
     $test_book->updateAuthor($test_author2);
     //Assert
     $this->assertEquals($test_book->getAuthors(), [$test_author2]);
 }
开发者ID:bdspen,项目名称:library_day1,代码行数:20,代码来源:BookTest.php

示例4: testGetAuthor

 function testGetAuthor()
 {
     //Arrange
     $author_name = "Stephen King";
     $id = 1;
     $test_author = new Author($author_name, $id);
     $test_author->save();
     $author_name2 = "Bob Smith";
     $id2 = 2;
     $test_author2 = new Author($author_name2, $id2);
     $test_author2->save();
     $book_name = "Gattica";
     $id = 1;
     $test_book = new Book($book_name, $id);
     $test_book->save();
     //Act
     $test_book->addAuthor($test_author);
     $test_book->addAuthor($test_author2);
     //Assert
     $this->assertEquals($test_book->getAuthors(), [$test_author, $test_author2]);
 }
开发者ID:kennygrage,项目名称:epicLibrary,代码行数:21,代码来源:BookTest.php

示例5: testAddAuthor

 function testAddAuthor()
 {
     //Arrange
     $book_name = "Intro to Art";
     $test_book = new Book($book_name);
     $test_book->save();
     $name = "Ben";
     $test_author = new Author($name);
     $test_author->save();
     //Act
     $test_book->addAuthor($test_author);
     //Assert
     $this->assertEquals($test_book->getAuthors(), [$test_author]);
 }
开发者ID:kevintokheim,项目名称:Library,代码行数:14,代码来源:BookTest.php

示例6: testGetAuthors

 function testGetAuthors()
 {
     //Arrange
     $id = null;
     $name = "A Series of Unfortunate Events";
     $test_book = new Book($id, $name);
     $test_book->save();
     $name2 = "Lemony Snicket";
     $test_author = new Author($id, $name2);
     $test_author->save();
     $test_book->addAuthor($test_author);
     $name3 = "J.R.R. Tolkien";
     $test_author2 = new Author($id, $name3);
     $test_author2->save();
     $test_book->addAuthor($test_author2);
     //Act
     $result = $test_book->getAuthors();
     //Assert
     $this->assertEquals([$test_author, $test_author2], $result);
 }
开发者ID:kellimargaret,项目名称:2015.08.26.Library,代码行数:20,代码来源:BookTest.php

示例7: Author

 function test_getAuthors()
 {
     //Arrange
     $name = "Giacomo Bordello";
     $test_author = new Author($name);
     $test_author->save();
     $name2 = "Dude Guy";
     $test_author2 = new Author($name2);
     $test_author2->save();
     $title = "Clarinet Seduction";
     $genre = "Romance";
     $test_book = new Book($title, $genre);
     $test_book->save();
     //Act
     $test_book->addAuthor($test_author);
     $test_book->addAuthor($test_author2);
     //Assert
     $this->assertEquals($test_book->getAuthors(), [$test_author, $test_author2]);
 }
开发者ID:r-hills,项目名称:library-1,代码行数:19,代码来源:BookTest.php

示例8: Book

 function test_addAuthor()
 {
     //Arrange
     $title = "Adventures on Mars";
     $test_book = new Book($title);
     $test_book->save();
     $name = "David Foster Wallace";
     $test_author = new Author($name);
     $test_author->save();
     //Act
     $test_book->addAuthor($test_author);
     $result = $test_book->getAuthors();
     //Assert
     $this->assertEquals([$test_author], $result);
 }
开发者ID:kevintokheim,项目名称:Liberry,代码行数:15,代码来源:BookTest.php

示例9: Author

 function test_AddAuthor()
 {
     //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_author];
     $test_book->addAuthor($test_author);
     //Assert
     $this->assertEquals($test_book->getAuthors(), $result);
 }
开发者ID:jlbethel,项目名称:Library,代码行数:15,代码来源:BookTest.php

示例10: testGetAuthors

 function testGetAuthors()
 {
     //Arrange
     $title = "Eat a Cupcake";
     $year_published = 1999;
     $id = null;
     $test_book = new Book($title, $year_published, $id);
     $test_book->save();
     $name = "Nathan Young";
     $test_author = new Author($name, $id);
     $test_author->save();
     $name2 = "Kyle Pratuch";
     $test_author2 = new Author($name2, $id);
     $test_author2->save();
     //Act
     $test_book->addAuthor($test_author);
     $test_book->addAuthor($test_author2);
     //Assert
     $this->assertEquals([$test_author, $test_author2], $test_book->getAuthors());
 }
开发者ID:nathanhwyoung,项目名称:Library,代码行数:20,代码来源:BookTest.php

示例11: Book

 function test_deleteAllAuthors()
 {
     //Arrange
     $title = "Wesley Pong";
     $test_book = new Book($title);
     $test_book->save();
     $name = "History";
     $test_author = new Author($name);
     $test_author->save();
     $name2 = "Lit";
     $test_author2 = new Author($name2);
     $test_author2->save();
     $test_book->addAuthor($test_author);
     $test_book->addAuthor($test_author2);
     //Act
     $test_book->deleteAllAuthors();
     $result = $test_book->getAuthors();
     //Assert
     $this->assertEquals([], $result);
 }
开发者ID:jlbethel,项目名称:library-1,代码行数:20,代码来源:BookTest.php

示例12: testAddAuthor

 function testAddAuthor()
 {
     $book_name = "Yer not a wizard harry";
     $test_book = new Book($book_name);
     $test_book->save();
     $author_name = "JK Rowling";
     $test_author = new Author($author_name);
     $test_author->save();
     $test_book->addAuthor($test_author);
     $result = $test_book->getAuthors();
     $this->assertEquals($test_author, $result[0]);
 }
开发者ID:jschold,项目名称:Library,代码行数:12,代码来源:BookTest.php

示例13: Book

 function test_getAuthors()
 {
     //Arrange
     $test_book = new Book("World War Z", "Horror");
     $test_book->save();
     $test_book2 = new Book("Billy Bartle-Barnaby", "2015-07-09");
     $test_book2->save();
     $test_author = new Author("High Times", "CHEM420");
     $test_author->save();
     $test_author2 = new Author("Gavanese Jamelan", "MUSC69");
     $test_author2->save();
     //Act
     $test_book->addAuthor($test_author);
     $test_book->addAuthor($test_author2);
     $test_book2->addAuthor($test_author2);
     //Assert
     $this->assertEquals($test_book->getAuthors(), [$test_author, $test_author2]);
 }
开发者ID:kellimargaret,项目名称:Library-Search,代码行数:18,代码来源:BookTest.php

示例14: testGetAuthors

 function testGetAuthors()
 {
     //Arrange
     $title = "Little Cat";
     $id = 1;
     $test_book = new Book($title, $id);
     $test_book->save();
     $name = "Ben";
     $id = 1;
     $test_author = new Author($name, $id);
     $test_author->save();
     $name2 = "Jen";
     $id2 = 2;
     $test_author2 = new Author($name2, $id2);
     $test_author2->save();
     //Act
     $test_book->addAuthor($test_author);
     $test_book->addAuthor($test_author2);
     //Assert
     $this->assertEquals($test_book->getAuthors(), [$test_author, $test_author2]);
 }
开发者ID:bborealis,项目名称:library-1,代码行数:21,代码来源:BookTest.php

示例15: getAuthors

    }
    public function getAuthors()
    {
        return $this->related(new Author());
    }
}
class Author extends RedBean_DomainObject
{
    public function setName($name)
    {
        $this->bean->name = $name;
    }
    public function getName()
    {
        return $this->bean->name;
    }
}
$book = new Book();
$author = new Author();
$book->setTitle("A can of beans");
$author->setName("Mr. Bean");
$book->addAuthor($author);
$id = $book->getID();
$book2 = new Book();
$book2->find($id);
asrt($book2->getTitle(), "A can of beans");
$authors = $book2->getAuthors();
asrt(count($authors), 1);
$he = array_pop($authors);
asrt($he->getName(), "Mr. Bean");
printtext("\nALL TESTS PASSED. REDBEAN SHOULD WORK FINE.\n");
开发者ID:surfnjunkie,项目名称:redbean,代码行数:31,代码来源:test.php


注:本文中的Book::getAuthors方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。