function testFind() { $book_id = 1; $test_copy = new Copy($book_id); $test_copy->save(); $book_id2 = 2; $test_copy2 = new Copy($book_id2); $test_copy2->save(); $result = Copy::find($test_copy->getId()); $this->assertEquals($test_copy, $result); }
function testFind() { //Arrange $due_date = '2015-10-10'; $book_id = 1; $id = 1; $test_copy = new Copy($due_date, $book_id, $id); $test_copy->save(); $due_date2 = '2015-11-11'; $book_id2 = 2; $id2 = 2; $test_copy2 = new Copy($due_date2, $book_id2, $id2); $test_copy2->save(); //Act $result = Copy::find($test_copy2->getId()); //Assert $this->assertEquals($test_copy2, $result); }
function testFind() { $title = "Three Blind Mice"; $test_book = new Book($title); $test_book->save(); $test_copy = new Copy($amount = 1, $test_book->getId()); $test_copy->save(); $title2 = "Chicken Dog"; $test_book2 = new Book($title2); $test_book2->save(); $test_copy2 = new Copy($amount2 = 2, $test_book2->getId()); $test_copy2->save(); $result = Copy::find($test_copy->getId()); $this->assertEquals($test_copy, $result); }
function testfind() { //Arrange $book_id = 1; $test_copy = new Copy($book_id); $test_copy->save(); $book_id2 = 2; $test_copy2 = new Copy($book_id2); $test_copy2->save(); //Act $result = Copy::find($test_copy2->getId()); //Assert $this->assertEquals($test_copy2, $result); }
return $app['twig']->render('author.html.twig', array('author' => $author, 'books' => $books, 'copies' => $copies, 'all_books' => Book::getAll())); }); $app->post("/add_copy", function () use($app) { $book_id = $_POST['book_id']; $book = Book::find($book_id); $authors = $book->getAuthors(); $copy = new Copy('0000-00-00', $book_id); $copy->save(); $copies = Copy::findCopies($book_id); return $app['twig']->render('book.html.twig', array('book' => $book, 'authors' => $authors, 'copies' => $copies)); }); $app->patch("/checkout_copy/{id}", function ($id) use($app) { $book = Book::find($id); $authors = $book->getAuthors(); $copy_id = $_POST['copy_id']; $copy = Copy::find($copy_id); $copy->update($_POST['due_date']); $copies = Copy::findCopies($id); return $app['twig']->render('book.html.twig', array('book' => $book, 'authors' => $authors, 'copies' => $copies)); }); $app->post("/delete_books", function () use($app) { Book::deleteAll(); return $app['twig']->render('books.html.twig', array('books' => Book::getAll())); }); $app->patch("/book/{id}", function ($id) use($app) { $book = Book::find($id); $title = $_POST['title']; $book->update($title); $authors = $book->getAuthors(); $copies = Copy::findCopies($id); return $app['twig']->render('book.html.twig', array('book' => $book, 'authors' => $authors, 'all_authors' => Author::getAll(), 'copies' => $copies));
function test_find() { //Arrange $available = true; $book_id = 4; $test_copy = new Copy($available, $book_id); $test_copy->save(); $available2 = 11; $book_id2 = 5; $test_copy2 = new Copy($available2, $book_id2); $test_copy2->save(); //Act $result = Copy::find($test_copy->getId()); //Assert $this->assertEquals($test_copy, $result); }
function testFind() { $book_title = "Snow Crash"; $id = null; $amount = 1; $test_book = new Book($book_title, $id); $test_book->save(); $book_title2 = "Dune"; $id2 = null; $amount2 = 2; $test_book2 = new Book($book_title2, $id2); $test_book2->save(); $test_copy = new Copy($amount, $test_book->getId()); $test_copy->save(); $test_copy2 = new Copy($amount2, $test_book2->getId()); $test_copy2->save(); $result = Copy::find($test_copy->getId()); $this->assertEquals($test_copy, $result); }