本文整理汇总了PHP中Book::getId方法的典型用法代码示例。如果您正苦于以下问题:PHP Book::getId方法的具体用法?PHP Book::getId怎么用?PHP Book::getId使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Book
的用法示例。
在下文中一共展示了Book::getId方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: removeBook
/**
* Remove book from student (lost or returned to library @see Library )
*
* @param Book $book
*
* @throws Exception
*/
public function removeBook(Book $book)
{
if (in_array($this->books, $book->getId())) {
if (($key = array_search($book->getId(), $this->books)) !== false) {
unset($this->books[$key]);
}
} else {
throw new Exception("Warning, book cannot be deleted - there are no such book owned by student");
}
}
示例2: testGetId
function testGetId()
{
$name = "Randy Mclure";
$test_patron = new Book($name);
$result = $test_patron->getId();
$this->assertEquals(null, $result);
}
示例3: testGetId
function testGetId()
{
$name = "Stephen King";
$test_author = new Book($name);
$result = $test_author->getId();
$this->assertEquals(null, $result);
}
示例4: testGetId
function testGetId()
{
$book_name = "Siddhartha";
$id = 100;
$test_book = new Book($book_name, $id);
$result = $test_book->getId();
$this->assertEquals($id, $result);
}
示例5: runBookInsertion
function runBookInsertion($i)
{
$book = new Book();
$book->setTitle('Hello' . $i);
$book->setAuthorId($this->authors[array_rand($this->authors)]);
$book->setISBN('1234');
$book->setPrice($i);
$book->save($this->con);
$this->books[] = $book->getId();
}
示例6: testFind
function testFind()
{
$title = "Anathem";
$test_book = new Book($title);
$test_book->save();
$title2 = "Snow Crash";
$test_book2 = new Book($title2);
$test_book2->save();
$result = Book::find($test_book->getId());
$this->assertEquals($result, $test_book);
}
示例7: Book
function test_find()
{
$title = "Three Blind Mice";
$test_book = new Book($title);
$test_book->save();
$title2 = "Chicken Dog";
$test_book2 = new Book($title2);
$test_book2->save();
$result = Book::find($test_book->getId());
$this->assertEquals($test_book, $result);
}
示例8: testGetBook
function testGetBook()
{
$title = "Carrie";
$test_book = new Book($title);
$test_book->save();
$book_id = $test_book->getId();
$test_copy = new Copy($book_id);
$test_copy->save();
$result = $test_copy->getBook();
$this->assertEquals($test_book, $result);
}
示例9: testGetId
function testGetId()
{
//Arrange
$title = "Grapes of Wrath";
$id = 1;
$test_book = new Book($title, $id);
//Act
$result = $test_book->getId();
//Assert
$this->assertEquals(1, $result);
}
示例10: testFind
function testFind()
{
//Arrange
$id = null;
$name = "A Series of Unfortunate Events";
$test_book = new Book($id, $name);
$test_book->save();
$name2 = "Fresh Off the Boat";
$test_book2 = new Book($id, $name2);
$test_book2->save();
//Act
$result = Book::find($test_book->getId());
//Assert
$this->assertEquals($test_book, $result);
}
示例11: Book
function test_find()
{
//Arrange
$title = "The Cat in the Hat";
$test_book = new Book($title);
$test_book->save();
$title2 = "Misery";
$test_book2 = new Book($title2);
$test_book2->save();
//Act
$id = $test_book->getId();
$result = Book::find($id);
//Assert
$this->assertEquals($test_book, $result);
}
示例12: testFind
function testFind()
{
//Arrange
$title = "Harry Potter";
$id = 1;
$test_book = new Book($title, $id);
$test_book->save();
$title2 = "Moby Dick";
$id2 = 2;
$test_book2 = new Book($title, $id);
$test_book2->save();
//Act
$result = Book::find($test_book2->getId());
//Assert
$this->assertEquals($test_book2, $result);
}
示例13: setUp
protected function setUp()
{
parent::setUp();
BookstoreDataPopulator::populate();
$cr = new Criteria();
$cr->add(AuthorPeer::LAST_NAME, "Rowling");
$cr->add(AuthorPeer::FIRST_NAME, "J.K.");
$rowling = AuthorPeer::doSelectOne($cr);
$this->authorId = $rowling->getId();
$book = new Book();
$book->setTitle("Harry Potter and the Philosopher's Stone");
$book->setISBN("1234");
$book->setAuthor($rowling);
$book->save();
$this->books[] = $book->getId();
$book = new Book();
$book->setTitle("Harry Potter and the Chamber of Secrets");
$book->setISBN("1234");
$book->setAuthor($rowling);
$book->save();
$this->books[] = $book->getId();
$book = new Book();
$book->setTitle("Harry Potter and the Prisoner of Azkaban");
$book->setISBN("1234");
$book->setAuthor($rowling);
$book->save();
$this->books[] = $book->getId();
$book = new Book();
$book->setTitle("Harry Potter and the Goblet of Fire");
$book->setISBN("1234");
$book->setAuthor($rowling);
$book->save();
$this->books[] = $book->getId();
$book = new Book();
$book->setTitle("Harry Potter and the Half-Blood Prince");
$book->setISBN("1234");
$book->setAuthor($rowling);
$book->save();
$this->books[] = $book->getId();
$book = new Book();
$book->setTitle("Harry Potter and the Deathly Hallows");
$book->setISBN("1234");
$book->setAuthor($rowling);
$book->save();
$this->books[] = $book->getId();
}
示例14: testAddCheckout
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);
}
示例15: testSaveCanInsertNonEmptyObjects
public function testSaveCanInsertNonEmptyObjects()
{
$b = new Book();
$b->setTitle('foo');
$b->setIsbn('124');
$b->save();
$this->assertFalse($b->isNew());
$this->assertNotNull($b->getId());
}