コード例 #1
0
 public function testSerializeObjectWithCollections()
 {
     $book1 = new Book();
     $book1->setTitle('Foo5');
     $book1->setISBN('1234');
     $book2 = new Book();
     $book2->setTitle('Foo6');
     $book2->setISBN('1234');
     $author = new Author();
     $author->setFirstName('JAne');
     $author->addBook($book1);
     $author->addBook($book2);
     $author->save();
     $a = clone $author;
     $sa = serialize($a);
     $author->clearAllReferences();
     $this->assertEquals($author, unserialize($sa));
 }
コード例 #2
0
 public function setUp()
 {
     parent::setUp();
     $a = new Author();
     $a->setFirstName("Douglas");
     $a->setLastName("Adams");
     $b1 = new Book();
     $b1->setTitle("The Hitchhikers Guide To The Galaxy");
     $a->addBook($b1);
     $b2 = new Book();
     $b2->setTitle("The Restaurant At The End Of The Universe");
     $a->addBook($b2);
     $a->save();
     $this->author = $a;
     $this->books = array($b1, $b2);
     Propel::enableInstancePooling();
     // Clear author instance pool so the object would be fetched from the database
     AuthorPeer::clearInstancePool();
 }
コード例 #3
0
ファイル: AuthorTest.php プロジェクト: kevintokheim/Library
 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]);
 }
コード例 #4
0
 /**
  * Primary key should differ
  */
 public function testSavedObjectCreatesDifferentHashForIdenticalObjects()
 {
     $book1 = new Book();
     $book1->setTitle('Foo5');
     $book1->setISBN('1234');
     $author1 = new Author();
     $author1->setFirstName('JAne');
     $author1->setLastName('JAne');
     $author1->addBook($book1);
     $author1->save();
     $author2 = new Author();
     $author2->setFirstName('JAne');
     $author2->setLastName('JAne');
     $author2->addBook($book1);
     $author2->save();
     $this->assertNotEquals($author1->hashCode(), $author2->hashCode());
 }
コード例 #5
0
ファイル: AuthorTest.php プロジェクト: kevintokheim/Liberry
 function test_findByAuthorName()
 {
     //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();
     $test_author->addBook($test_book);
     //Act
     $result = Author::findByAuthorName("David Foster Wallace");
     //Assert
     $this->assertEquals($test_author->getId(), $result);
 }
コード例 #6
0
 function testGetBooks()
 {
     //Arrange
     $id = null;
     $name = "Lemony Snicket";
     $test_author = new Author($id, $name);
     $test_author->save();
     $name2 = "Fresh Off The Boat";
     $test_book = new Book($id, $name2);
     $test_book->save();
     $test_author->addBook($test_book);
     $name3 = "A Series of Unfortunate Events";
     $test_book2 = new Book($id, $name3);
     $test_book2->save();
     $test_author->addBook($test_book2);
     //Act
     $result = $test_author->getBooks();
     //Assert
     $this->assertEquals([$test_book, $test_book2], $result);
 }
コード例 #7
0
 /**
  * This tests to see whether modified objects are being silently overwritten by calls to fk accessor methods.
  * @link       http://propel.phpdb.org/trac/ticket/509#comment:5
  */
 public function testModifiedObjectOverwrite()
 {
     BookstoreDataPopulator::populate();
     $author = new Author();
     $author->setFirstName("John");
     $author->setLastName("Public");
     $books = $author->getBooks();
     // empty, of course
     $this->assertEquals(0, count($books), "Expected empty collection.");
     $book = new Book();
     $book->setTitle("A sample book");
     $book->setISBN("INITIAL ISBN");
     $author->addBook($book);
     $author->save();
     $book->setISBN("MODIFIED ISBN");
     $books = $author->getBooks();
     $this->assertEquals(1, count($books), "Expected 1 book.");
     $this->assertSame($book, $books[0], "Expected the same object to be returned by fk accessor.");
     $this->assertEquals("MODIFIED ISBN", $books[0]->getISBN(), "Expected the modified value NOT to have been overwritten.");
 }
コード例 #8
0
ファイル: AuthorTest.php プロジェクト: umamiMike/Library
 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());
 }
コード例 #9
0
ファイル: AuthorTest.php プロジェクト: r-hills/library-1
 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]);
 }
コード例 #10
0
ファイル: AuthorTest.php プロジェクト: bborealis/library
 function testDelete()
 {
     //Arrange
     $title = "Harry Potter";
     $id = 1;
     $test_book = new Book($title, $id);
     $test_book->save();
     $name = "JK Rowling";
     $id = 1;
     $test_author = new Author($name, $id);
     $test_author->save();
     //Act
     $test_author->addBook($test_book);
     $test_author->delete();
     //Assert
     $this->assertEquals([], $test_book->getAuthors());
 }
コード例 #11
0
 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);
 }
コード例 #12
0
 /**
  * Declares an association between this object and a Author object.
  *
  * @param      Author $v
  * @return     Book The current object (for fluent API support)
  * @throws     PropelException
  */
 public function setAuthor(Author $v = null)
 {
     if ($v === null) {
         $this->setAuthorId(NULL);
     } else {
         $this->setAuthorId($v->getId());
     }
     $this->aAuthor = $v;
     // Add binding for other direction of this n:n relationship.
     // If this object has already been added to the Author object, it will not be re-added.
     if ($v !== null) {
         $v->addBook($this);
     }
     return $this;
 }
コード例 #13
0
ファイル: AuthorTest.php プロジェクト: jtorrespdx/library
 function testGetBook()
 {
     //Arrange
     $first_name = "John";
     $last_name = "Steinbeck";
     $test_author = new Author($first_name, $last_name);
     $test_author->save();
     $title = "Grapes of Wrath";
     $test_book = new Book($title);
     $test_book->save();
     $title2 = "Cannery Row";
     $test_book2 = new Book($title2);
     $test_book2->save();
     //Act
     $test_author->addBook($test_book);
     $test_author->addBook($test_book2);
     $result = $test_author->getBook();
     //Assert
     $this->assertEquals([$test_book, $test_book2], $result);
 }
コード例 #14
0
ファイル: app.php プロジェクト: CaseyH33/Library
require_once __DIR__ . "/../src/Author.php";
require_once __DIR__ . "/../src/Book.php";
$app = new Silex\Application();
$app['debug'] = true;
$server = 'mysql:host=localhost;dbname=library';
$username = '******';
$password = '******';
$DB = new PDO($server, $username, $password);
use Symfony\Component\HttpFoundation\Request;
Request::enableHttpMethodParameterOverride();
$app->register(new Silex\Provider\TwigServiceProvider(), array('twig.path' => __DIR__ . '/../views'));
$app->get("/", function () use($app) {
    return $app['twig']->render('index.html.twig', array('authors' => Author::getAll(), 'books' => Book::getAll()));
});
$app->post("/author_book", function () use($app) {
    $title = $_POST['title'];
    $book = new Book($title, $id = null);
    $book->save();
    $name = $_POST['name'];
    $author = new Author($name, $id = null);
    $author->save();
    $result = $author->addBook($book);
    return $app['twig']->render('index.html.twig', array('books' => Book::getAll(), 'authors' => Author::getAll()));
});
$app->post("/delete_all", function () use($app) {
    $GLOBALS['DB']->exec("DELETE FROM authors_books_t;");
    Author::deleteAll();
    Book::deleteAll();
    return $app['twig']->render('index.html.twig', array('authors' => Author::getAll(), 'books' => Book::getAll()));
});
return $app;
コード例 #15
0
 /**
  * Declares an association between this object and a Author object.
  * Mapped by fields authorId
  * 
  * @param Author $author
  * @return $this|\Book The current object (for fluent API support)
  */
 public function setAuthor(Author $author = null)
 {
     $this->author = $author;
     // Setup bidirectional relationship.
     if (null !== $author) {
         $author->addBook($this);
     }
 }
コード例 #16
0
 public function testRefFKAddReturnsCurrentObject()
 {
     $author = new Author();
     $author->setFirstName('Leo');
     $ret = $author->addBook(new Book());
     $this->assertSame($author, $ret);
 }
コード例 #17
0
 public function testManyToMany()
 {
     $library = new Library();
     $library->setName('Travis County Reader');
     $library->save();
     $library2 = new Library();
     $library2->setName('LBJ Center');
     $library2->save();
     $author = new Author();
     $author->setName('Haruki Murakami');
     $book = new Book();
     $book->setTitle('Norwegian Wood');
     $book->save();
     $book2 = new Book();
     $book2->setTitle('Kafka on the Shore');
     $book2->save();
     $author->addBook($book);
     $author->addBook($book2);
     $author->save();
     $book2library = new Book2library();
     $book2library->setBookId($book->getBookId());
     $book2library->setLibraryId($library->getLibraryId());
     $book2library->save();
     $book2library2 = new Book2library();
     $book2library2->setBookId($book2->getBookId());
     $book2library2->setLibraryId($library->getLibraryId());
     $book2library2->save();
     $book2library3 = new Book2library();
     $book2library3->setBookId($book->getBookId());
     $book2library3->setLibraryId($library2->getLibraryId());
     $book2library3->save();
     $book2library4 = new Book2library();
     $book2library4->setBookId($book2->getBookId());
     $book2library4->setLibraryId($library2->getLibraryId());
     $book2library4->save();
     // now both books should be in both libraries
     $sameLibrary = Library::constructByKey($library->getLibraryId());
     $bookJoinsInTravis = $sameLibrary->getBook2library_Collection();
     // $this->dump($bookJoinsInTravis);
     $this->assertEqual(count($bookJoinsInTravis), 2);
     // This test is similar to the 4 that are commented out below, but this shows what is different
     // AND it ignores the creation_datetime and last_modified_datetime differences b/c they are
     // intentionally not autoloaded after a save. Just manually call load() after save if you want
     // to get the updated data.
     $mismatches = $this->getFieldMismatches($bookJoinsInTravis->getPosition(0)->getBook_Object(), $book);
     // Unset mistmatches that we know to be intentional
     if (isset($mismatches['creation_datetime'])) {
         unset($mismatches['creation_datetime']);
     }
     if (isset($mismatches['last_modified_datetime'])) {
         unset($mismatches['last_modified_datetime']);
     }
     $this->assertTrue(empty($mismatches), implode("\n", $mismatches));
     // these fail because the $book and $book2 don't have some default values set after save like creation_datetime
     // (which is intentional; call load() after save if you want to get the updated data.)
     // $this->assertIdentical($bookJoinsInTravis->getPosition(0)->getBook_Object(), $book);
     // $this->assertIdentical($bookJoinsInTravis->getPosition(1)->getBook_Object(), $book2);
     $this->assertEqual($bookJoinsInTravis->getPosition(0)->getBook_Object()->getBookId(), $book->getBookId());
     $this->assertEqual($bookJoinsInTravis->getPosition(1)->getBook_Object()->getBookId(), $book2->getBookId());
     $sameLibrary2 = Library::constructByKey($library2->getLibraryId());
     $bookJoinsInLbj = $sameLibrary2->getBook2library_Collection();
     $this->assertEqual(count($bookJoinsInLbj), 2);
     // these fail because the $book and $book2 don't have some default values set after save like creation_datetime
     // (which is intentional; call load() after save if you want to get the updated data.)
     // $this->assertIdentical($bookJoinsInLbj->getPosition(0)->getBook_Object(), $book);
     // $this->assertIdentical($bookJoinsInLbj->getPosition(1)->getBook_Object(), $book2);
     $this->assertEqual($bookJoinsInLbj->getPosition(0)->getBook_Object()->getBookId(), $book->getBookId());
     $this->assertEqual($bookJoinsInLbj->getPosition(1)->getBook_Object()->getBookId(), $book2->getBookId());
 }
コード例 #18
0
ファイル: AuthorTest.php プロジェクト: nathanhwyoung/Library
 function testGetBooks()
 {
     //Arrange
     $title = "Where the Red Fern Grows";
     $year_published = 1961;
     $id = null;
     $test_book = new Book($title, $year_published, $id);
     $test_book->save();
     $title2 = "Where the Wild Things Are";
     $year_published2 = 1964;
     $test_book2 = new Book($title2, $year_published2, $id);
     $test_book2->save();
     $name = "Nathan Young";
     $test_author = new Author($name, $id);
     $test_author->save();
     //Act
     $test_author->addBook($test_book);
     $test_author->addBook($test_book2);
     //Assert
     $this->assertEquals([$test_book, $test_book2], $test_author->getBooks());
 }
コード例 #19
0
ファイル: AuthorTest.php プロジェクト: bencasalino/library
 function testGetBook()
 {
     //Arrange
     $title = "Title";
     $id = 1;
     $test_book = new Book($title, $id);
     $test_book->save();
     $title2 = "Other Title";
     $id2 = 2;
     $test_book2 = new Book($title2, $id2);
     $test_book2->save();
     $name = "Ping Pong";
     $id2 = 1;
     $test_author = new Author($name, $id2);
     $test_author->save();
     //Act
     $test_author->addBook($test_book->getId());
     $test_author->addBook($test_book2->getId());
     //Assert
     $this->assertEquals($test_author->getBook(), [$test_book, $test_book2]);
 }
コード例 #20
0
 function test_getBooks()
 {
     //Arrange
     $test_author = new Author("J.K. Rowling");
     $test_author->save();
     $test_author2 = new Author("Harry Potter");
     $test_author2->save();
     $test_book = new Book("Harry Potter and the Dish Stone", "Non-fiction");
     $test_book->save();
     $test_book2 = new Book("Kelli Potter and the Three Bananas", "Fanasty");
     $test_book2->save();
     //Act
     $test_author->addBook($test_book);
     $test_author->addBook($test_book2);
     $test_author2->addBook($test_book);
     //Assert
     $this->assertEquals($test_author->getBooks(), [$test_book, $test_book2]);
 }
コード例 #21
0
 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');
 }
コード例 #22
0
ファイル: AuthorTest.php プロジェクト: alexMcosta/library2
 function testSearchByAuthorLast()
 {
     //Arrange
     $author_first = "J.K.";
     $author_last = "Rowling";
     $test_author = new Author($author_first, $author_last);
     $test_author->save();
     $author_first2 = "Stephen";
     $author_last2 = "King";
     $test_author2 = new Author($author_first2, $author_last2);
     $test_author2->save();
     $title = "Grapes of Wrath";
     $test_book = new Book($title);
     $test_book->save();
     $test_author->addBook($test_book);
     $title2 = "Harry Potter";
     $test_book2 = new Book($title2);
     $test_book2->save();
     $test_author->addBook($test_book2);
     $title3 = "Misery";
     $test_book3 = new Book($title3);
     $test_book3->save();
     $test_author2->addBook($test_book3);
     $search_string = "Rowling";
     //Act
     $result = Author::searchByAuthorLast($search_string);
     //Assert
     $this->assertEquals([$test_book, $test_book2], $result[0]);
 }
コード例 #23
0
ファイル: Ticket520Test.php プロジェクト: ketheriel/ETVA
 public function testNewObjectsGetLostOnJoin()
 {
     /* While testNewObjectsAvailableWhenSaveNotCalled passed as of
     		revision 851, in this case we call getBooksJoinPublisher() instead
     		of just getBooks(). get...Join...() does not contain the check whether
     		the current object is new, it will always consult the DB and lose the
     		new objects entirely. Thus the test fails. (At least for Propel 1.2 ?!?) */
     $this->markTestSkipped();
     $a = new Author();
     $a->setFirstName("Douglas");
     $a->setLastName("Adams");
     $p = new Publisher();
     $p->setName('Pan Books Ltd.');
     $b1 = new Book();
     $b1->setTitle("The Hitchhikers Guide To The Galaxy");
     $b1->setPublisher($p);
     // uh... did not check that :^)
     $a->addBook($b1);
     $b2 = new Book();
     $b2->setTitle("The Restaurant At The End Of The Universe");
     $b2->setPublisher($p);
     $a->addBook($b2);
     $books = $a->getBooksJoinPublisher();
     $this->assertEquals(2, count($books));
     $this->assertContains($b1, $books);
     $this->assertContains($b2, $books);
     $a->save();
     $this->assertFalse($b1->isNew());
     $this->assertFalse($b2->isNew());
 }
コード例 #24
0
ファイル: AuthorTest.php プロジェクト: kennygrage/epicLibrary
 function test_getBooks()
 {
     $title = "War and Peace";
     $id = null;
     $test_book = new Book($title, $id);
     $test_book->save();
     $author_name2 = "Plato";
     $test_author2 = new Author($author_name2, $id);
     $test_author2->save();
     //Act
     $test_author2->addBook($test_book);
     $result = $test_author2->getBooks();
     //Assert
     $this->assertEquals([$test_book], $result);
 }
コード例 #25
0
ファイル: app.php プロジェクト: alexMcosta/library2
});
//Librarian Home
//Loads basic page
$app->get("/librarian_home", function () use($app) {
    return $app['twig']->render('librarian.html.twig', array('books' => Book::getAll()));
});
//allows user to post new books and view them on the same page
$app->post("/librarian_home", function () use($app) {
    $title = $_POST['title'];
    $author_first = $_POST['author_first_name'];
    $author_last = $_POST['author_last_name'];
    $book = new Book($title);
    $book->save();
    $author = new Author($author_first, $author_last);
    $author->save();
    $author->addBook($book);
    return $app['twig']->render('librarian.html.twig', array('books' => Book::getAll(), 'authors' => Author::getAll()));
});
//Book page
$app->get("/books/{id}", function ($id) use($app) {
    $book = Book::find($id);
    $author = $book->getAuthor();
    return $app['twig']->render('book.html.twig', array('book' => $book, 'author' => $author));
});
//Search for title or author
$app->post("/search/title", function () use($app) {
    $title = $_POST['search_title'];
    $books = Book::searchByTitle($title);
    return $app['twig']->render('search_results.html.twig', array('books' => $books));
});
$app->post("/search/author", function () use($app) {
コード例 #26
0
 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]);
 }
コード例 #27
0
 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]);
 }
コード例 #28
0
 public function testToArrayIncludesForeignReferrers()
 {
     $a1 = new Author();
     $a1->setFirstName('Leo');
     $a1->setLastName('Tolstoi');
     $arr = $a1->toArray(BasePeer::TYPE_PHPNAME, null, array(), true);
     $this->assertFalse(array_key_exists('Books', $arr));
     $b1 = new Book();
     $b1->setTitle('War and Peace');
     $b2 = new Book();
     $b2->setTitle('Anna Karenina');
     $a1->addBook($b1);
     $a1->addBook($b2);
     $arr = $a1->toArray(BasePeer::TYPE_PHPNAME, null, array(), true);
     $this->assertTrue(array_key_exists('Books', $arr));
     $this->assertEquals(2, count($arr['Books']));
     $this->assertEquals('War and Peace', $arr['Books']['Book_0']['Title']);
     $this->assertEquals('Anna Karenina', $arr['Books']['Book_1']['Title']);
     $this->assertEquals('*RECURSION*', $arr['Books']['Book_0']['Author']);
 }
コード例 #29
0
 public function testFindOneWithEmptyLeftJoinOneToMany()
 {
     // non-empty relation
     $a1 = new Author();
     $a1->setFirstName('Foo');
     $b1 = new Book();
     $b1->setTitle('Foo1');
     $a1->addBook($b1);
     $b2 = new Book();
     $b2->setTitle('Foo2');
     $a1->addBook($b2);
     $a1->save();
     $con = Propel::getConnection(BookPeer::DATABASE_NAME);
     $author = AuthorQuery::create()->filterByFirstName('Foo')->leftJoinWith('Author.Book')->findOne($con);
     $count = $con->getQueryCount();
     $books = $author->getBooks(null, $con);
     $this->assertEquals(2, $books->count());
     $this->assertEquals($count, $con->getQueryCount());
     // empty relation
     $a2 = new Author();
     $a2->setFirstName('Bar');
     $a2->save();
     $author = AuthorQuery::create()->filterByFirstName('Bar')->leftJoinWith('Author.Book')->findOne($con);
     $count = $con->getQueryCount();
     $books = $author->getBooks(null, $con);
     $this->assertEquals(0, $books->count());
     $this->assertEquals($count, $con->getQueryCount());
 }
コード例 #30
0
ファイル: AuthorTest.php プロジェクト: jlbethel/Library
 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);
 }