示例#1
0
 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);
 }
示例#2
0
 function testGetId()
 {
     //Arrange
     $book_id = 1;
     $due_date = '0000-00-00';
     $id = 1;
     $test_copy = new Copy($book_id, $due_date, $id);
     $test_copy->save();
     //Act
     $result = $test_copy->getId();
     //Assert
     $this->assertEquals(true, is_numeric($result));
 }
示例#3
0
 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);
 }
示例#4
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);
 }
示例#5
0
 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());
 }
示例#6
0
 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()));
 }
示例#7
0
 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);
 }
示例#8
0
 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);
 }
示例#9
0
 function test_getCopy()
 {
     //Arrange
     $book_id = 1;
     $test_copy = new Copy($book_id);
     $test_copy->save();
     $checked_in_status = 0;
     $due_date = "2000 BC";
     $patron_id = 1;
     $test_checkout = new Checkout($checked_in_status, $due_date, $test_copy->getId(), $patron_id);
     $test_checkout->save();
     //Act
     $result = $test_checkout->getCopy();
     //Assert
     $this->assertEquals($test_copy, $result);
 }
示例#10
0
 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);
 }
示例#11
0
 function testGetCopy()
 {
     //Arrange
     $copy_id = 1;
     $test_copy = new Copy($copy_id);
     $test_copy->save();
     $copy_id2 = 2;
     $id2 = 2;
     $test_copy2 = new Copy($copy_id2);
     $test_copy2->save();
     $name = "Ping Pong";
     $id2 = 1;
     $test_patron = new Patron($name);
     $test_patron->save();
     //Act
     $test_patron->addCopy($test_copy->getId());
     $test_patron->addCopy($test_copy2->getId());
     //Assert
     $this->assertEquals($test_patron->getCopy(), [$test_copy, $test_copy2]);
 }
示例#12
0
 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);
 }