當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。