private function procGetIDNum($session) { $queryType = @$_GET['type']; shell_exec("java PHPHandler requestRFIDTagId"); $idNum = (string) shell_exec("java PHPHandler downloadRFID"); if ($queryType == "add") { $session->form->setValue("rfid", $idNum); $_SESSION['value_array'] = $session->form->getValueArray(); session_write_close(); header("Location: bookProcess.php?submitBookChanges&type=" . $queryType); } else { if ($queryType == "change" || $queryType == "remove") { $book = new Book(); $result = $book->getBookCallNo($idNum); $callNo = $result['CallNo']; header("Location: bookProcess.php?setupChangeList&type=" . $queryType . "&callNo=" . $callNo . ""); } else { if ($queryType == "checkinout") { $book = new Book(); $result = $book->getBookCallNo($idNum); $callNo = $result['CallNo']; header("Location: librarianProcess.php?checkinout&s=1&callNo=" . $callNo . ""); } } } }
function books() { $objs = new Book(); $objs->get(); $data = array('books' => $objs); $this->load->view('backend/books', $data); }
public function testFormatALotOfResults() { $nbBooks = 50; $con = Propel::getConnection(BookPeer::DATABASE_NAME); Propel::disableInstancePooling(); $book = new Book(); for ($i = 0; $i < $nbBooks; $i++) { $book->clear(); $book->setTitle('BookTest' . $i); $book->save($con); } $stmt = $con->query('SELECT * FROM book'); $formatter = new PropelOnDemandFormatter(); $formatter->init(new ModelCriteria('bookstore', 'Book')); $books = $formatter->format($stmt); $this->assertTrue($books instanceof PropelOnDemandCollection, 'PropelOnDemandFormatter::format() returns a PropelOnDemandCollection'); $this->assertEquals($nbBooks, count($books), 'PropelOnDemandFormatter::format() returns a collection that counts as many rows as the results in the query'); $i = 0; foreach ($books as $book) { $this->assertTrue($book instanceof Book, 'PropelOnDemandFormatter::format() returns a collection of Model objects'); $this->assertEquals('BookTest' . $i, $book->getTitle(), 'PropelOnDemandFormatter::format() returns the model objects matching the query'); $i++; } Propel::enableInstancePooling(); }
function testGetId() { $name = "Randy Mclure"; $test_patron = new Book($name); $result = $test_patron->getId(); $this->assertEquals(null, $result); }
function update() { $params = $this->input->post(); $obj = new Book(); $obj->where('id', $params['id'])->update($params); echo $obj->check_last_query(); }
function bookInsertion($title, $ISBN, $author) { $book = new \Book(['title' => $title, 'isbn' => $ISBN]); $book->link('author', $author); $book->save(); return $book; }
/** * __construct method */ public function __construct(View $view, $settings = array()) { parent::__construct($view, $settings); App::import("Model", 'Book'); $Book = new Book(); $this->calibrePath = $Book->getCalibrePath(); }
public function hallAction() { $this->view->loginuser = $_SESSION['loginuser']; $book = new Book(); $res = $book->fetchAll()->toArray(); $this->view->res = $res; }
public function test_create_from_array() { $data = array('title' => 'New Book', 'author_id' => '1', 'quantity' => '500', 'price' => '7.77'); // 'New Book' doesn't exist // i.e. test may be invalid $book = new Book(); $book = $book->find_by_title('New Book'); if (count($book) != 0) { $this->errors['create_from_array'][] = 'pre-exists'; } $new_book = new Book(); $new_book->create($data); // 'New Book' was created // e.g. create() isn't working if (is_null($new_book->id)) { $this->errors['create_from_array'][] = 'new_book_id'; } // 'New Book' can be fetched // e.g. update() isn't working $fetch_book = new Book(); $fetch_book = $fetch_book->find_by_title('New Book'); if (count($fetch_book) != 1) { $this->errors['create_from_array'][] = 'fetch_count'; } if ($fetch_book[0]->id != $new_book->id) { $this->errors['create_from_array'][] = 'fetch_id_match'; } }
public function test_update_from_array() { $data = array('title' => 'New Book', 'author_id' => '1', 'quantity' => '500', 'price' => '7.77'); // Create Book to test $new_book = new Book(); $new_book->create($data); // 'New Book' exists // i.e. test may be invalid $book = new Book(); $book = $book->find_by_title('New Book'); if (count($book) == 0) { $this->errors['update_from_array'][] = 'non-existent'; } if (count($book) > 1) { $this->errors['update_from_array'][] = 'too_many'; } $new_data = array('author_id' => '2', 'quantity' => '600', 'price' => '8.88'); $update_book = new Book(); $update_book = $update_book->first_by_title('New Book'); $update_book->update($new_data); // Fetch book // e.g. update() isn't working $fetch_book = new Book(); $fetch_book = $fetch_book->first_by_title('New Book'); if ($fetch_book->author_id != 2) { $this->errors['update_from_array'][] = 'author_id'; } if ($fetch_book->quantity != 600) { $this->errors['update_from_array'][] = 'quantity'; } if ($fetch_book->price != '8.88') { $this->errors['update_from_array'][] = 'price'; } }
public function testTicket2() { $obj = new Book(); $obj->set('name', 'yes2'); $obj->save(); $this->assertEqual($obj->get('name'), 'yes2'); $obj->save(); }
/** * @return bool * @throws Exception */ public function process() { $bookModel = new Book(); if (!$bookModel->load($this->data) || !$bookModel->validate()) { throw new Exception('Invalid data!'); } return $bookModel->delete(); }
public function testWeCanCreateABookWithInformation() { $title = 'New Title'; $author = "Author"; $book = new Book($title, $author); $this->assertEquals($title, $book->getTitle()); $this->assertEquals($author, $book->getAuthor()); }
public function removeBook(Book $bookToRemove) { foreach ($this->books as $key => $book) { /** @var Book $book */ if ($book->getAuthorAndTitle() === $bookToRemove->getAuthorAndTitle()) { unset($this->books[$key]); } } }
function bookInsertion($title, $ISBN, $author) { $book = new \Book(); $book->title = $title; $book->isbn = $ISBN; $book->author()->associate($author); $book->save(); return $book; }
public function removeBook(Book $bookToRemove) { foreach ($this->books as $key => $book) { if ($book->getAuthorAndTitle() === $bookToRemove->getAuthorAndTitle()) { unset($this->books[$key]); } } $this->books = array_values($this->books); }
function handlePUT(mysqli $conn) { parse_str(file_get_contents("php://input"), $data); $book = new Book(); $book->update($conn, $data['id']); $book->setTitle($data['title']); $book->setAuthor($data['author']); $book->setDesc($data['desc']); }
/** * @return bool * @throws Exception */ public function process() { $bookModel = new Book(); if ($bookModel->load($this->data) && $bookModel->validate()) { $bookModel->save(); return (array) $bookModel; } throw new Exception('Invalid data!'); }
public function testAddingABook() { $author = AuthorPeer::retrieveByPK($this->author->getId()); $c1 = new Book(); $c1->setTitle("ORM 101"); $author->addBook($c1); $this->assertEquals(3, count($author->getBooks())); $this->assertEquals(3, $author->countBooks()); }
/** * 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"); } }
function testUpdate() { $book_name = "Siddhartha"; $test_book = new Book($book_name); $test_book->save(); $test_book->setTitle("Peace Train"); $test_book->update(); $result = Book::getAll(); $this->assertEquals($test_book, $result[0]); }
function mapBookRecordSet($recordset) { $books = array(); while ($data = mysql_fetch_array($recordset)) { $book = new Book(); $book->mapObject($data); array_push($books, $book); } return $books; }
function runBookInsertion($i) { $book = new Book(); $book->title = 'Hello' . $i; $book->author_id = $this->authors[array_rand($this->authors)]; $book->isbn = '1234'; $book->price = $i; $book->save($this->con); $this->books[] = $book->id; }
function testRemoveCopies() { $book_name = "Marakami"; $new_book = new Book($book_name); $new_book->save(); Copies::setCopies($new_book, 8); Copies::removeCopies($new_book, 5); $result = Copies::getCopies($new_book); $this->assertEquals(3, $result); }
function testGetBookTitle() { //arrange $book_title = 'Call of the Wild'; $test_book_title = new Book($book_title); var_dump($book_title); //act $result = $test_book_title->getBookTitle(); //assert $this->assertEquals($book_title, $result); }
public function find ($id= null){ if ($id!= null){ $book= new Book(); $book->load($id); return $book; } else{ $error = new GsError(303,"Error loading book."); throw $error; } }
/** * @return array * @throws Exception */ public function process() { $bookModel = new Book(); if (!$bookModel->load($this->data)) { return $bookModel->getAllRecords(); } if ($bookModel->validate()) { return $bookModel->getRecords(); } throw new Exception('Invalid data!'); }
public function testClear() { $b = new Book(); $b->setNew(false); $b->clear(); $this->assertTrue($b->isNew(), 'clear() sets the object to new'); $b = new Book(); $b->setDeleted(true); $b->clear(); $this->assertFalse($b->isDeleted(), 'clear() sets the object to not deleted'); }
/** * fake for test */ public function findOne($con = null) { if (true === $this->bySlug) { $book = new Book(); $book->setId(1); $book->setName('My Book'); $book->setSlug('my-book'); return $book; } return null; }
public function test_makeDrawingMap() { $zip = $this->makeZipMock(['xl/workbook.xml', 'xl/_rels/workbook.xml.rels', 'xl/worksheets/_rels/sheet1.xml.rels', 'xl/worksheets/_rels/sheet2.xml.rels', 'xl/worksheets/_rels/sheet3.xml.rels']); $bookUtil = new Book(); $map = $bookUtil->makeDrawingMap($zip); $this->assertInternalType('array', $map); $this->assertArrayNotHasKey('表紙', $map); $this->assertArrayHasKey('日別_Y', $map); $this->assertArrayHasKey('日別_YDN', $map); $this->assertEquals(['xl/drawings/drawing1.xml', 'xl/drawings/drawing2.xml'], $map['日別_Y']); }