コード例 #1
0
ファイル: CheckoutTest.php プロジェクト: ashlinaronin/library
 function test_getAll()
 {
     // for now, feed a dummy copy_id just for testing
     // later, we will need to use getNextCopy() in Book class
     // to get a copy for a given book
     //Arrange
     // Make a Patron
     $name = "Dan Brown";
     $phone = "3";
     $email = "*****@*****.**";
     $test_patron = new Patron($name, $phone, $email);
     $test_patron->save();
     // Make a Checkout and save
     $patron_id = $test_patron->getId();
     $copy_id = 1;
     $date = "2015-08-09";
     $test_checkout = new Checkout($patron_id, $copy_id, $date);
     $test_checkout->save();
     // Make a 2nd Checkout and save under the same patron
     $copy_id2 = 1;
     $date2 = "2015-08-09";
     $test_checkout2 = new Checkout($patron_id, $copy_id2, $date2);
     $test_checkout2->save();
     //Act
     $result = Checkout::getAll();
     //Assert
     $this->assertEquals([$test_checkout, $test_checkout2], $result);
 }
コード例 #2
0
ファイル: PatronTest.php プロジェクト: umamiMike/Library
 function testDelete()
 {
     $name = "Randy Mclure";
     $test_patron = new Patron($name);
     $test_patron->save();
     $name2 = "Ballface Majure";
     $test_patron2 = new Patron($name2);
     $test_patron2->save();
     $test_patron->delete();
     $this->assertEquals([$test_patron2], Patron::getAll());
 }
コード例 #3
0
 function testGetPatronId()
 {
     $patron_name = "Eduardo";
     $patron_id = 1;
     $test_patron = new Patron($patron_name, $patron_id);
     $test_patron->save();
     $copy_id = 1;
     $due_date = "2015-01-01";
     $checkout_status = false;
     $test_checkout = new Checkout($patron_id, $copy_id, $due_date, $checkout_status);
     $result = $test_checkout->getPatronId();
     $this->assertEquals(1, $result);
 }
コード例 #4
0
ファイル: PatronTest.php プロジェクト: kylepratuch/library-1
 function testGetAll()
 {
     //Arrange
     $patron_name = "Butterball";
     $id = null;
     $test_patron = new Patron($patron_name, $id);
     $test_patron->save();
     $patron_name2 = "Lance Armstrang";
     $id2 = null;
     $test_patron2 = new Patron($patron_name2, $id2);
     $test_patron2->save();
     //Act
     $result = Patron::getAll();
     //Assert
     $this->assertEquals([$test_patron, $test_patron2], $result);
 }
コード例 #5
0
 function testAddCheckout()
 {
     $title = "Three Blind Mice";
     $test_book = new Book($title);
     $test_book->save();
     $test_copy = new Copy($amount = 1, $test_book->getId());
     $test_copy->save();
     $name = "Joe Bongtana";
     $test_patron = new Patron($name);
     $test_patron->save();
     $due_date = "01-01-2016";
     $status = 1;
     $test_checkout = new Checkout($test_copy->getId(), $test_patron->getId(), $due_date, $status);
     $test_checkout->save();
     $test_patron->addCheckout($test_checkout);
     $result = Checkout::getAll();
     $this->assertEquals($test_checkout, $result);
 }
コード例 #6
0
 function testDelete()
 {
     //Arrange
     $id = null;
     $name = "Allen";
     $phone = "4444";
     $test_patron = new Patron($id, $name, $phone);
     $name2 = "Phil";
     $phone2 = "5555";
     $test_patron2 = new Patron($id, $name2, $phone2);
     $test_patron2->save();
     //Act
     $test_patron->delete();
     //Assert
     $this->assertEquals([$test_patron2], Patron::getAll());
 }
コード例 #7
0
ファイル: CheckoutTest.php プロジェクト: r-hills/Library
 function test_updateDueDate()
 {
     //Arrange
     // Make a Patron
     $name = "Dan Brown";
     $phone = "3";
     $email = "*****@*****.**";
     $test_patron = new Patron($name, $phone, $email);
     $test_patron->save();
     // Make a Checkout and save
     $patron_id = $test_patron->getId();
     $copy_id = 1;
     $due_date = "2015-08-09";
     $test_checkout = new Checkout($patron_id, $copy_id, $due_date);
     $test_checkout->save();
     $new_due_date = "2015-08-27";
     //Act
     $test_checkout->updateDueDate($new_due_date);
     //Assert
     $result = $test_checkout->getDueDate();
     $this->assertEquals($new_due_date, $result);
 }
コード例 #8
0
ファイル: BarTest.php プロジェクト: kellimargaret/Beer-Me
 function testGetAllTokens()
 {
     $name = "Side Street";
     $phone = "555-555-5555";
     $address = "123 ABC. Street";
     $website = "http://www.sidestreetpdx.com";
     $test_bar = new Bar($name, $phone, $address, $website);
     $test_bar->save();
     $test_item = new Item("tacos", 2.25);
     $test_item->save();
     $test_bar->addItem($test_item);
     $returned_ids = $GLOBALS['DB']->query("SELECT id FROM menus WHERE bar_id = {$test_bar->getId()};");
     $ids = array();
     foreach ($returned_ids as $returned_id) {
         $id = $returned_id['id'];
         array_push($ids, $id);
     }
     $name = "Kyle Pratuch";
     $email = "*****@*****.**";
     $test_patron = new Patron($name, $email);
     $test_patron->save();
     $test_token = new Token($test_patron->getId(), $ids[0], 3);
     $test_token->save();
     //   var_dump($test_token);
     $result = $test_bar->getAllTokens();
     $this->assertEquals($test_token, $result[0]);
 }
コード例 #9
0
ファイル: PatronTest.php プロジェクト: jcubed22/library-1
 function testPatronFind()
 {
     //Arrange
     $patron_name = "Mr. Pickles";
     $id = null;
     $test_patron = new Patron($patron_name, $id);
     $test_patron->save();
     $patron_name2 = "John Doe";
     $test_patron2 = new Patron($patron_name2, $id);
     $test_patron2->save();
     //Act
     $id = $test_patron2->getId();
     //Assert
     $result = Patron::find($id);
     $this->assertEquals($test_patron2, $result);
 }
コード例 #10
0
ファイル: app.php プロジェクト: kellimargaret/Beer-Me
    } elseif ($bar == NULL) {
        return $app['twig']->render("patron.html.twig", array('user' => $user, 'user_tokens' => $user->getTokens(), 'all_bars' => $all_bars, 'preferred_bars' => false, 'send_token' => false, 'token_form' => false, 'edit_user' => false));
    } else {
        return $app['twig']->render("bar.html.twig", array('bar' => $bar, 'tokens' => $bar->getAllTokens(), 'items' => $bar->getAllItems(), 'get_tokens' => false, 'show_menu' => false, 'edit_bar' => false));
    }
});
//Sign Up Routes:
$app->get("/show_customer_signup", function () use($app) {
    return $app['twig']->render('index.html.twig', array('about' => false, 'sign_up' => true, "sign_in" => false, 'team' => false, 'customer_signup' => true, 'business_signup' => false));
});
$app->get("/show_business_signup", function () use($app) {
    return $app['twig']->render('index.html.twig', array('about' => false, 'sign_up' => true, "sign_in" => false, 'team' => false, 'customer_signup' => false, 'business_signup' => true));
});
$app->post("/customer_signup", function () use($app) {
    $new_user = new Patron($_POST['username'], $_POST['email']);
    $new_user->save();
    return $app['twig']->render("signup_confirmation.html.twig");
});
$app->post("/business_signup", function () use($app) {
    $new_bar = new Bar($_POST['name'], $_POST['phone'], $_POST['address'], $_POST['website']);
    $new_bar->save();
    return $app['twig']->render("signup_confirmation.html.twig");
});
//Get Show email search
$app->get("/show_email_search/{id}", function ($id) use($app) {
    $user = Patron::find($id);
    $all_bars = Bar::getAll();
    return $app['twig']->render("patron.html.twig", array('user' => $user, 'user_tokens' => $user->getTokens(), 'all_bars' => $all_bars, 'preferred_bars' => false, 'send_token' => true, 'token_form' => false, 'edit_user' => false));
});
//Get Show User Tokens
$app->get("/show_user_tokens/{id}", function ($id) use($app) {
コード例 #11
0
ファイル: CheckoutTest.php プロジェクト: kevintokheim/Library
 function test_getPatron()
 {
     //Arrange
     $name = "Phyllis the kind Grandma";
     $test_patron = new Patron($name);
     $test_patron->save();
     $checked_in_status = 0;
     $due_date = "2000 BC";
     $copy_id = 1;
     $test_checkout = new Checkout($checked_in_status, $due_date, $copy_id, $test_patron->getId());
     $test_checkout->save();
     //Act
     $result = $test_checkout->getPatron();
     //Assert
     $this->assertEquals($test_patron, $result);
 }
コード例 #12
0
 function testDeletePatron()
 {
     $name = "Hulk Hogan";
     $id = 1;
     $test_patron = new Patron($name, $id);
     $test_patron->save();
     $name2 = "Kool-aid Man and Randal Savage";
     $id2 = 2;
     $test_patron2 = new Patron($name2, $id2);
     $test_patron2->save();
     $test_patron->deletePatron();
     $this->assertEquals([$test_patron2], Patron::getAll());
 }
コード例 #13
0
 function testDeleteOne()
 {
     //Arrange
     $patron_name = "Sally";
     $phone_number = "1234567890";
     $test_patron = new Patron($patron_name, $phone_number);
     $test_patron->save();
     $patron_name2 = "Joe";
     $phone_number2 = "0987654321";
     $test_patron2 = new Patron($patron_name2, $phone_number2);
     $test_patron2->save();
     //Act
     $test_patron->deleteOne();
     //Assert
     $this->assertEquals([$test_patron2], Patron::getAll());
 }
コード例 #14
0
ファイル: PatronTest.php プロジェクト: jlbethel/Library
 function test_addCheckout()
 {
     $name = "Big Lebowski";
     $test_book = new Book($name);
     $test_book->save();
     $test_book->addCopy();
     $copies = $test_book->getCopies();
     $patron_name = "Big Lebowski";
     $test_patron = new Patron($patron_name);
     $test_patron->save();
     $test_patron->addCheckout($copies[0]);
     $result = $test_patron->getCheckouts();
     $this->assertEquals(1, count($result));
 }
コード例 #15
0
ファイル: CheckoutTest.php プロジェクト: r-hills/library-1
 function test_saveWithPatron()
 {
     //Arrange
     // Create a Patron
     $name = "Suzie";
     $phone = "1-800-342-0909";
     $test_patron = new Patron($name, $phone);
     $test_patron->save();
     // Create a Checkout with the new Patron
     $copy_id = 1;
     $patron_id = $test_patron->getId();
     $due_date = "2015-09-03";
     $test_checkout = new Checkout($copy_id, $patron_id, $due_date);
     //Act
     $test_checkout->save();
     //Assert
     $result = Checkout::getAll();
     $this->assertEquals($test_checkout, $result[0]);
 }
コード例 #16
0
ファイル: PatronTest.php プロジェクト: kevintokheim/Library
 function test_addCheckout()
 {
     //Arrange
     $name = "Jerald the crotchety grandpa";
     $test_patron = new Patron($name);
     $test_patron->save();
     $book_id = 8;
     $test_copy = new Copy($book_id);
     $test_copy->save();
     //Act
     $test_patron->addCheckout($test_copy);
     $result = $test_patron->getCheckouts();
     //Assert
     $this->assertEquals($test_patron->getId(), $result[0]->getPatronId());
 }
コード例 #17
0
ファイル: app.php プロジェクト: bborealis/library
    $author = Author::find($id);
    $book = $author->getAuthors();
    return $app['twig']->render('author.html.twig', array('book' => $book, 'author' => $author));
});
$app->post("/delete_authors", function () use($app) {
    Author::deleteAll();
    return $app['twig']->render('authors.html.twig', array('authors' => Author::getAll()));
});
$app->post("/authors", function () use($app) {
    $author = new Author($_POST['name']);
    $author->save();
    // $book->addAuthor($author);
    return $app['twig']->render('authors.html.twig', array('authors' => Author::getAll()));
});
//patrons
$app->get("/patrons", function () use($app) {
    return $app['twig']->render('patrons.html.twig', array('patrons' => Patron::getAll()));
});
$app->post("/patrons", function () use($app) {
    $patron = new Patron($_POST['name']);
    $patron->save();
    return $app['twig']->render('patrons.html.twig', array('patrons' => Patron::getAll()));
});
$app->get("/patron/{id}", function ($id) use($app) {
    $patron = Patron::find($id);
    $copies = $patron->getCopies();
    $book_titles = $copies->getCheckoutTitles();
    return $app['twig']->render('patron.html.twig', array('patron' => $patron, 'copies' => $copies, 'book_titles' => $book_titles));
});
//copies
return $app;
コード例 #18
0
ファイル: PatronTest.php プロジェクト: alexdbrown/library
 function test_delete()
 {
     //Arrange
     $name = "Suzie Palloozi";
     $phone = "1-800-439-0398";
     $test_patron = new Patron($name, $phone);
     $test_patron->save();
     $name2 = "Tac Zoltani";
     $phone2 = "1-800-407-3930";
     $test_patron2 = new Patron($name2, $phone2);
     $test_patron2->save();
     //Act
     $test_patron->delete();
     //Assert
     $result = Patron::getAll();
     $this->assertEquals($test_patron2, $result[0]);
 }
コード例 #19
0
ファイル: PatronTest.php プロジェクト: bborealis/library
 function testDelete()
 {
     //Arrange
     $due_date = "2015-10-10";
     $book_id = 1;
     $id = 1;
     $test_copy = new Copy($due_date, $book_id, $id);
     $test_copy->save();
     $name = "Jim Bob";
     $id = 1;
     $test_patron = new Patron($name, $id);
     $test_patron->save();
     //Act
     $test_patron->addCopy($test_copy);
     $test_patron->delete();
     //Assert
     $this->assertEquals([], $test_copy->getPatrons());
 }
コード例 #20
0
ファイル: app.php プロジェクト: jlbethel/Library
    return $app['twig']->render('patron.html.twig', array('patron' => $patron, 'checkouts' => $patron->getCheckouts()));
});
//-------------------------------------------------------//
$app->post("/books", function () use($app) {
    $new_book = new Book($_POST['title']);
    $new_book->save();
    return $app['twig']->render('books.html.twig', array('books' => Book::getAll()));
});
$app->post("/authors", function () use($app) {
    $new_author = new Author($_POST['name']);
    $new_author->save();
    return $app['twig']->render('authors.html.twig', array('authors' => Author::getAll()));
});
$app->post("/patrons", function () use($app) {
    $new_patron = new Patron($_POST['name']);
    $new_patron->save();
    return $app['twig']->render('patrons.html.twig', array('patrons' => Patron::getAll()));
});
$app->post("/add_author", function () use($app) {
    $book = Book::find($_POST['book_id']);
    $author = Author::find($_POST['author_id']);
    $book->addAuthor($author);
    return $app['twig']->render('book.html.twig', array('copies' => $book->getCopies(), 'book' => $book, 'authors' => $book->getAuthors(), 'all_authors' => Author::getAll()));
});
$app->post("/add_book", function () use($app) {
    $book = Book::find($_POST['book_id']);
    $author = Author::find($_POST['author_id']);
    $author->addBook($book);
    return $app['twig']->render('author.html.twig', array('author' => $author, 'books' => $author->getBooks(), 'all_books' => Book::getAll()));
});
$app->post("/add_copy", function () use($app) {
コード例 #21
0
ファイル: PatronTest.php プロジェクト: r-hills/Library
 function test_find()
 {
     //Arrange
     $name = "Dan Brown";
     $phone = "3";
     $email = "*****@*****.**";
     $test_patron = new Patron($name, $phone, $email);
     $test_patron->save();
     //Act
     $result = Patron::find($test_patron->getId());
     //Assert
     $this->assertEquals($test_patron, $result);
 }
コード例 #22
0
ファイル: PatronTest.php プロジェクト: r-hills/library-1
 function test_getAllCheckouts()
 {
     //Arrange
     // create 2 test patrons.
     $name = "Suzie Palloozi";
     $phone = "1-800-439-0398";
     $test_patron = new Patron($name, $phone);
     $test_patron->save();
     // create 2 test checkouts. hard code copy_id for now
     $copy_id = 1;
     $patron_id = $test_patron->getId();
     $due_date = "2015-03-04";
     $test_checkout = new Checkout($copy_id, $patron_id, $due_date);
     $test_checkout->save();
     //Act
     $result = $test_patron->getAllCheckouts();
     //Assert
     $this->assertEquals([$test_checkout], $result);
 }
コード例 #23
0
ファイル: PatronTest.php プロジェクト: bborealis/library-1
 function testGetCheckouts()
 {
     //Arrange
     $name = "Jim Bob";
     $id = 1;
     $test_patron = new Patron($name, $id);
     $test_patron->save();
     $book_id = 1;
     $id = 1;
     $test_copy = new Copy($book_id, $id);
     $test_copy->save();
     $book_id2 = 2;
     $id2 = 2;
     $test_copy2 = new Copy($book_id2, $id2);
     $test_copy2->save();
     $copy_id = $test_copy->getId();
     $patron_id = $test_patron->getId();
     $id = null;
     $due_date = "2015-09-30";
     $test_checkout = new Checkout($copy_id, $patron_id, $due_date, $id);
     $test_checkout->save();
     // $copy_id2 = $test_copy2->getId();
     // $patron_id2 = $test_patron->getId();
     // $id2 = null;
     // $due_date2 = "2015-09-30";
     // $test_checkout2 = new Checkout($copy_id2, $patron_id2, $id2, $due_date2);
     $copy_id2 = $test_copy2->getId();
     $patron_id2 = $test_patron->getId();
     $id2 = null;
     $due_date2 = "2015-04-20";
     $test_checkout2 = new Checkout($copy_id2, $patron_id2, $due_date2, $id2);
     $test_checkout2->save();
     // var_dump($test_checkout);
     // var_dump($test_checkout2);
     //Act
     // $test_patron->addCheckout($test_checkout);
     // $test_patron->addCheckout($test_checkout2);
     $result = $test_patron->getCheckouts();
     // var_dump($result);
     //Assert
     $this->assertEquals(2, count($test_patron->getCheckouts()));
 }
コード例 #24
0
ファイル: PatronTest.php プロジェクト: CaseyH33/Beer_Me
 function testGetPreferredBars()
 {
     //Arrange
     $name = "Kyle Pratuch";
     $email = "*****@*****.**";
     $test_patron = new Patron($name, $email);
     $test_patron->save();
     $bar_name = "Side Street";
     $phone = "555-555-5555";
     $address = "123 ABC. Street";
     $website = "http://www.sidestreetpdx.com";
     $test_bar = new Bar($bar_name, $phone, $address, $website);
     $test_bar->save();
     $bar_name2 = "ABC Pub";
     $phone2 = "444-444-4444";
     $address2 = "321 CBA Street";
     $website2 = "http://www.sesamestreet.com";
     $test_bar2 = new Bar($bar_name2, $phone2, $address2, $website2);
     $test_bar2->save();
     $test_patron->addPreferredBar($test_bar);
     $test_patron->addPreferredBar($test_bar2);
     //Act
     $result = $test_patron->getPreferredBars();
     //Assert
     $this->assertEquals([$test_bar, $test_bar2], $result);
 }
コード例 #25
0
ファイル: CopyTest.php プロジェクト: kevintokheim/Library
 function test_addCheckout()
 {
     //Arrange
     $book_id = 4;
     $test_copy = new Copy($book_id);
     $test_copy->save();
     $name = "Phyllis the kind Grandma";
     $test_patron = new Patron($name);
     $test_patron->save();
     //Act
     $test_copy->addCheckout($test_patron);
     $result = $test_copy->getCheckout();
     //Assert
     $this->assertEquals($test_copy->getId(), $result->getCopyId());
 }
コード例 #26
0
ファイル: PatronTest.php プロジェクト: kennygrage/epicLibrary
 function test_find()
 {
     //Arrange
     $patron_name = "Paco";
     $id = 1;
     $test_patron = new Patron($patron_name, $id);
     $test_patron->save();
     $patron_name2 = "BurritoJr";
     $id2 = 2;
     $test_patron2 = new Patron($patron_name2, $id2);
     $test_patron2->save();
     //Act
     $test_id = $test_patron->getId();
     $result = Patron::find($test_id);
     //Arrange
     $this->assertEquals($test_patron, $result);
 }
コード例 #27
0
ファイル: PatronTest.php プロジェクト: jlbethel/library-1
 function testUpdatePatronName()
 {
     //Arrange
     $patron_name = "Joe Patron";
     $id = 1;
     $test_patron = new Patron($patron_name, $id);
     $test_patron->save();
     $new_name = "James Patron";
     //Act
     $test_patron->updatePatronName($new_name);
     //Assert
     $this->assertEquals("James Patron", $test_patron->getPatronName());
 }
コード例 #28
0
ファイル: CopyTest.php プロジェクト: bdspen/library_day1
 function testGetPatron()
 {
     //Arrange
     $book_id = 1;
     $id = 1;
     $test_copy = new Copy($book_id, $id);
     $test_copy->save();
     $name = "Ping Pong";
     $id2 = 1;
     $test_patron = new Patron($name, $id2);
     $test_patron->save();
     $name2 = "Ding Dong";
     $id3 = 2;
     $test_patron2 = new Patron($name2, $id3);
     $test_patron2->save();
     //Act
     $test_copy->addPatron($test_patron->getId());
     $test_copy->addPatron($test_patron2->getId());
     //Assert
     $this->assertEquals($test_copy->getPatron(), [$test_patron, $test_patron2]);
 }
コード例 #29
0
ファイル: CopyTest.php プロジェクト: bborealis/library
 function testGetPatrons()
 {
     //Arrange
     $due_date = "2015-10-10";
     $book_id = 1;
     $id = 1;
     $test_copy = new Copy($due_date, $book_id, $id);
     $test_copy->save();
     $name = "Jim Bob";
     $id = 1;
     $test_patron = new Patron($name, $id);
     $test_patron->save();
     $name2 = "Sally Sue";
     $id2 = 2;
     $test_patron2 = new Patron($name, $id);
     $test_patron2->save();
     //Act
     $test_copy->addPatron($test_patron);
     $test_copy->addPatron($test_patron2);
     $result = $test_copy->getPatrons();
     //Assert
     $this->assertEquals([$test_patron, $test_patron2], $result);
 }
コード例 #30
0
ファイル: PatronTest.php プロジェクト: jschold/Library
 function testFind()
 {
     $patron_name = "Jasmine";
     $id = 1;
     $new_patron = new Patron($patron_name, $id);
     $new_patron->save();
     $patron_name = "Aladdin";
     $new_patron2 = new Patron($patron_name);
     $new_patron2->save();
     $result = Patron::find($new_patron->getId());
     $this->assertEquals($new_patron, $result);
 }