コード例 #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 プロジェクト: kylepratuch/library-1
 function testGetId()
 {
     //Arrange
     $id = 1;
     $patron_name = "Chichi";
     $test_patron = new Patron($patron_name, $id);
     //Act
     $result = $test_patron->getId();
     //Assert
     $this->assertEquals(1, $result);
 }
コード例 #3
0
ファイル: PatronTest.php プロジェクト: umamiMike/Library
 function testFind()
 {
     $name = "Randy Mclure";
     $test_patron = new Patron($name);
     $test_patron->save();
     $name2 = "Ballface Majure";
     $test_patron2 = new Patron($name2);
     $test_patron2->save();
     $result = Patron::find($test_patron->getId());
     $this->assertEquals($result, $test_patron);
 }
コード例 #4
0
 function testGetId()
 {
     //Arrange
     $patron_name = "Sally";
     $phone_number = "1234567890";
     $test_patron = new Patron($patron_name, $phone_number);
     $test_patron->save();
     //Act
     $result = $test_patron->getId();
     //Assert
     $this->assertEquals(true, is_numeric($result));
 }
コード例 #5
0
ファイル: PatronTest.php プロジェクト: alexdbrown/library
 function test_find()
 {
     //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
     $result = Patron::find($test_patron2->getId());
     //Assert
     $this->assertEquals($test_patron2, $result);
 }
コード例 #6
0
ファイル: PatronTest.php プロジェクト: bborealis/library
 function testFind()
 {
     //Arrange
     $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
     $result = Patron::find($test_patron2->getId());
     //Assert
     $this->assertEquals($test_patron2, $result);
 }
コード例 #7
0
 function testFind()
 {
     //Arrange
     $id = null;
     $name = "Marcos";
     $phone = "4444";
     $test_patron = new Patron($id, $name, $phone);
     $test_patron->save();
     $name2 = "Phil";
     $phone2 = "5555";
     $test_patron2 = new Patron($id, $name2, $phone2);
     $test_patron2->save();
     //Act
     $result = Patron::find($test_patron->getId());
     //Assert
     $this->assertEquals($test_patron, $result);
 }
コード例 #8
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);
 }
コード例 #9
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]);
 }
コード例 #10
0
ファイル: PatronTest.php プロジェクト: bencasalino/library
 function find()
 {
     //Arrange
     $name = "Name";
     $id = 1;
     $test_patron = new Patron($name, $id);
     $name2 = "Different Name";
     $id2 = 2;
     $test_patron2 = new Patron($name2, $id2);
     //Act
     $result = Patron::find($test_patron2->getId());
     //Assert
     $this->assertEquals($test_student2, $result);
 }
コード例 #11
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]);
 }
コード例 #12
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);
 }
コード例 #13
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()));
 }
コード例 #14
0
ファイル: PatronTest.php プロジェクト: jlbethel/Library
 function test_updatePatronName()
 {
     //Arrange
     $patron_name = "Hannibal";
     $test_patron = new Patron($patron_name);
     $test_patron->save();
     $patron_name2 = "Johnny";
     $test_patron->updatePatronName($patron_name2);
     //Act
     $id = $test_patron->getId();
     $result = new Patron($patron_name2, $id);
     //Assert
     $this->assertEquals(Patron::find($id), $result);
 }
コード例 #15
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());
 }
コード例 #16
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);
 }
コード例 #17
0
ファイル: PatronTest.php プロジェクト: CaseyH33/Beer_Me
 function testGetTokens()
 {
     //Arrange
     $name = "Kyle Pratuch";
     $email = "*****@*****.**";
     $test_recipient = new Patron($name, $email);
     $test_recipient->save();
     $name2 = "Jason Bethel";
     $email2 = "*****@*****.**";
     $test_sender = new Patron($name2, $email2);
     $test_sender->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();
     $description = "Pliny the Elder";
     $cost = 5.0;
     $id = null;
     $test_item = new Item($description, $cost, $id);
     $test_item->save();
     $test_bar->addItem($test_item);
     $patron_id = $test_recipient->getId();
     $sender_id = $test_sender->getId();
     $menu_id = 1;
     $test_token = new Token($patron_id, $menu_id, $sender_id);
     $test_token->save();
     $menu_id2 = 2;
     $test_token2 = new Token($patron_id, $menu_id2, $sender_id);
     $test_token2->save();
     //Act
     $result = $test_recipient->getTokens();
     //Assert
     $this->assertEquals([$test_token, $test_token2], $result);
 }
コード例 #18
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]);
 }
コード例 #19
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);
 }
コード例 #20
0
ファイル: PatronTest.php プロジェクト: jlbethel/library-1
 function test_find()
 {
     //Arrange
     $patron_name = "James Patterson";
     $id = 1;
     $test_patron = new Patron($patron_name, $id);
     $test_patron->save();
     $patron_name2 = "Albebra";
     $id = 2;
     $test_patron2 = new Patron($patron_name2, $id);
     $test_patron2->save();
     //Act
     $result = Patron::find($test_patron->getId());
     //Assert
     $this->assertEquals($test_patron, $result);
 }
コード例 #21
0
ファイル: PatronTest.php プロジェクト: umamiMike/library-1
 function testGetCurrentCheckouts()
 {
     $patron_name = "Randy Mclure";
     $test_patron = new Patron($patron_name);
     $test_patron->save();
     $due_date = null;
     $copy_id = 1;
     $checkin_status = 1;
     $test_checkout = new Checkout($due_date, $copy_id, $test_patron->getId(), $checkin_status);
     $test_checkout->save($test_patron, $due_date);
     $test_checkout->checkIn();
     $due_date2 = null;
     $copy_id2 = 2;
     $checkin_status2 = 0;
     $test_checkout2 = new Checkout($due_date2, $copy_id2, $test_patron->getId(), $checkin_status2);
     $test_checkout2->save($test_patron);
     $result = $test_patron->getCurrentCheckouts();
     $this->assertEquals([$test_checkout2], $result);
 }
コード例 #22
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);
 }
コード例 #23
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);
 }
コード例 #24
0
 function test_find()
 {
     $name = "Steve Brule";
     $id = 1;
     $test_patron1 = new Patron($name, $id);
     $test_patron1->save();
     $name2 = "Tim Heidecker";
     $id2 = 2;
     $test_patron2 = new Patron($name2, $id2);
     $test_patron2->save();
     $result = Patron::find($test_patron2->getId());
     $this->assertEquals($test_patron2, $result);
 }
コード例 #25
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);
 }
コード例 #26
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);
 }
コード例 #27
0
ファイル: CheckoutTest.php プロジェクト: umamiMike/library-1
 function testCheckIn()
 {
     $patron_name = "Randy Mclure";
     $test_patron = new Patron($patron_name);
     $test_patron->save();
     $due_date = "2015-09-10";
     $copy_id = 1;
     $patron_id = 1;
     $checkin_status = 1;
     $test_checkout = new Checkout($due_date, $copy_id, $test_patron->getId(), $checkin_status);
     $test_checkout->save($test_patron);
     $test_checkout->checkIn();
     $result = $test_checkout->getCheckinStatus();
     $this->assertEquals(1, $result);
 }