function testUpdate() { $title = "Anathem"; $test_book = new Book($title); $test_book->save(); $new_title = "crypotnomicon"; $test_book->update($new_title); $this->assertEquals($new_title, $test_book->getTitle()); }
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']); }
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 testUpdate() { $book_name = "Rum diaries"; $test_book = new Book($book_name); $test_book->save(); $test_book->setTitle("Gum Diariez"); $test_book->update(); $result = Book::getAll(); $this->assertEquals($test_book, $result[0]); }
function test_update() { $title = "Three Blind Mice"; $test_book = new Book($title); $test_book->save(); $title2 = "Chicken Dog"; $test_book->update($title2); $result = Book::getAll(); $this->assertEquals([$test_book], $result); }
function testUpdate() { //Arrange $book_name = "Intro to Art"; $test_book = new Book($book_name); $test_book->save(); //Act $new_book_name = "Intro to Fine Arts"; $test_book->update($new_book_name); //Assert $this->assertEquals("Intro to Fine Arts", $test_book->getTitle()); }
function testUpdate() { //Arrange $title = "Harry Potter"; $id = 1; $test_book = new Book($title, $id); $test_book->save(); $new_title = "Moby Dick"; //Act $test_book->update($new_title); //Assert $this->assertEquals("Moby Dick", $test_book->getTitle()); }
function testUpdate() { //Arrange $title = "Little Cat"; $id = 1; $test_book = new Book($title, $id); $test_book->save(); $new_title = "Big Cat"; //Act $test_book->update($new_title); //Assert $this->assertEquals("Big Cat", $test_book->getTitle()); }
function testUpdate() { //Arrange $title = "Where the Red Fern Grows"; $id = null; $test_book = new Book($title, $id); $test_book->save(); $new_title = "Where the Green Fern Dies"; //Act $test_book->update($new_title); //Assert $this->assertEquals("Where the Green Fern Dies", $test_book->getTitle()); }
public static function updateBook($id) { $params = filter_input_array(INPUT_POST); $attributes = array('id' => $id, 'name' => $params['name'], 'author' => $params['author'], 'publishyear' => $params['publishyear'], 'pages' => $params['pages'], 'description' => $params['description']); $book = new Book($attributes); $errors = $book->errors(); if (count($errors) == 0) { $book->update(); Redirect::to('/allbooks/' . $book->id, array('message' => 'Kirjaa on muokattu onnistuneesti!')); } else { View::make('book/edit_book.html', array('errors' => $errors, 'attributes' => $attributes)); } }
public static function update($id) { $params = $_POST; $v = new Valitron\Validator($params); $v->rule('required', 'book_name'); $v->rule('lengthBetween', 'book_name', 1, 50); $v->rule('required', 'writer'); $v->rule('lengthBetween', 'writer', 1, 50); $v->rule('required', 'publisher'); $v->rule('lengthBetween', 'publisher', 1, 50); $v->rule('numeric', 'published'); $v->rule('required', 'published'); $v->rule('lengthBetween', 'published', 1, 4); $attributes = array('id' => $id, 'book_name' => $params['book_name'], 'writer' => $params['writer'], 'publisher' => $params['publisher'], 'published' => $params['published'], 'genre' => $params['genre']); if ($v->validate()) { $book = new Book($attributes); $book->update(); Redirect::to('/book/' . $book->id, array('message' => 'Kirjan tietoja on muokattu.')); } }
if ($_POST['action'] == 'submit') { if (isset($_POST['usertext'])) { $text = $_POST['usertext']; $book = new Book(); $book->add($text); } else { echo "sorry you have to enter name and comment"; } } elseif ($_POST['action'] == 'like') { if ($_POST['l_id']) { $id = $_POST['l_id']; $book = new Book(); $book->like($id); } } elseif ($_POST['action'] == 'delete') { if ($_POST['d_id']) { $id = $_POST['d_id']; $book = new Book(); $book->delete($id); } } elseif ($_POST['action'] == 'update') { if ($_POST['up_id']) { if ($_POST['new_comment']) { $new_comment = $_POST['new_comment']; $id = $_POST['up_id']; $book = new Book(); $book->update($id, $new_comment); } } } }
if (isset($_REQUEST["id"])) { $id = $_REQUEST["id"]; $b = $book->getBookInfo($id); if (!$b) { $page->show404(); } switch ($action) { case 'submit': $coverLoc = WWW_DIR . "covers/book/" . $id . '.jpg'; if ($_FILES['cover']['size'] > 0) { $tmpName = $_FILES['cover']['tmp_name']; $file_info = getimagesize($tmpName); if (!empty($file_info)) { move_uploaded_file($_FILES['cover']['tmp_name'], $coverLoc); } } $_POST['cover'] = file_exists($coverLoc) ? 1 : 0; $_POST['publishdate'] = empty($_POST['publishdate']) || !strtotime($_POST['publishdate']) ? $con['publishdate'] : date("Y-m-d H:i:s", strtotime($_POST['publishdate'])); $book->update($id, $_POST["title"], $_POST['asin'], $_POST['url'], $_POST["author"], $_POST["publisher"], $_POST["publishdate"], $_POST["cover"]); header("Location:" . WWW_TOP . "/book-list.php"); die; break; case 'view': default: $page->title = "Book Edit"; $page->smarty->assign('book', $b); break; } } $page->content = $page->smarty->fetch('book-edit.tpl'); $page->render();
function test_update() { //Arrange $title = "World War Z"; $genre = "Horror"; $test_book = new Book($title, $genre); $test_book->save(); $new_name = "Reginald Irving-Jones"; //Act $test_book->update($new_name); //Assert $this->assertEquals($new_name, $test_book->getTitle()); }
function testUpdate() { //Arrange $title = "Grapes of Wrath"; $test_book = new Book($title); $test_book->save(); $new_title = "Harry Potter"; //Act $test_book->update($new_title); //Assert $this->assertEquals("Harry Potter", $test_book->getTitle()); }
function book_edit_form_submit($data) { $error = book_validate($data); if (!empty($error)) { return FALSE; } else { $book = new Book(); $update = $book->update($data); if ($update['code'] == 200) { return book_list($data['id']); } } }
function test_updateGenre() { //Arrange $title = "Whimsical Fairytales...and other stories"; $genre = "Fantasy"; $test_book = new Book($title, $genre); $test_book->save(); $column_to_update = "genre"; $new_info = "Historical Fiction"; //Act $test_book->update($column_to_update, $new_info); //Assert $result = Book::getAll(); $this->assertEquals("Historical Fiction", $result[0]->getGenre()); }
function testUpdate() { //Arrange $book_title = "Snow Crash"; $id = null; $test_book = new Book($book_title, $id); $test_book->save(); $new_book_title = "Foundations Edge"; //Act $test_book->update($new_book_title); //Assert $this->assertEquals("Foundations Edge", $test_book->getBookTitle()); }
function testUpdate() { //Arrange $book_name = "Gattica"; $id = 1; $test_book = new Book($book_name, $id); $test_book->save(); $new_book_name = "How to run"; //Act $test_book->update($new_book_name); //Assert $this->assertEquals($new_book_name, $test_book->getBookName()); }
function testUpdate() { //Arrange $title = "Title"; $test_book = new Book($title); $test_book->save(); $new_title = "New Title"; //Act $test_book->update($new_title); //Assert $this->assertEquals($test_book->getTitle(), $new_title); }
function testUpdate() { //Arrange $id = null; $name = "A Series of Unfortunate Events"; $test_book = new Book($id, $name); $test_book->save(); $new_name = "An Unfortunate Event"; //Act $test_book->update($new_name); //Assert $result = $test_book->getName(); $this->assertEquals("An Unfortunate Event", $result); }