/** <tt>update test</tt> */ public function testUpdate() { $item = new Author(); $item->name = 'Andrei Cristescu'; $this->assertEqual($item->insert(), $item->id); $item->email = '*****@*****.**'; $this->assertEqual($item->update(), 1); $this->assertEqual($item->delete(), 1); }
function testDelete() { $name = "Stephen King"; $test_author = new Author($name); $test_author->save(); $name2 = "Neal Stephenson"; $test_author2 = new Author($name2); $test_author2->save(); $test_author->delete(); $this->assertEquals([$test_author2], Author::getAll()); }
function test_delete() { $name = "Jerry Garcia"; $test_author = new Author($name); $test_author->save(); $name2 = "Frank Sinatra"; $test_author2 = new Author($name2); $test_author2->save(); $test_author->delete(); $result = Author::getAll(); $this->assertEquals([$test_author2], $result); }
function test_delete() { //Arrange $name = "Bob"; $test_author = new Author($name); $test_author->save(); $name2 = "Billy Bob"; $test_author2 = new Author($name2); $test_author2->save(); //Act $test_author->delete(); //Assert $result = Author::getAll(); $this->assertEquals([$test_author2], $result); }
function test_delete() { //Arrange $author_name = "Jack London"; $test_author = new Author($author_name); $test_author->save(); $author_name2 = "Robert Jordan"; $test_author2 = new Author($author_name2); $test_author2->save(); //Act $test_author2->delete(); $result = Author::getAll(); //Assert $this->assertEquals([$test_author], $result); }
function testDeleteAuthor() { //Arrange $id = null; $name = "Lemony Snicket"; $test_book = new Book($id, $name); $test_book->save(); $name2 = "J.R.R. Tolkien"; $test_author = new Author($id, $name2); $test_author->save(); //Act $test_author->addBook($test_book); $test_author->delete(); //Assert $this->assertEquals([], $test_book->getAuthors()); }
function testDelete() { //Arrange $author_name = "Frank Herbert"; $id = null; $test_author = new Author($author_name, $id); $test_author->save(); $author_name2 = "Neal Stephenson"; $id2 = null; $test_author2 = new Author($author_name2, $id2); $test_author2->save(); //Act $test_author->delete(); //Assert $this->assertEquals([$test_author2], Author::getAll()); }
function test_delete() { //Arrange $name = "Kurt Vonnegut"; $test_author = new Author($name); $test_author->save(); //Act $test_author->delete(); $result = Author::getAll(); //Assert $this->assertEquals([], $result); }
function test_delete() { //Arrange $name = "J.K. Rowling"; $test_author = new Author($name); $test_author->save(); $name2 = "C.S. Lewis"; $test_author2 = new Author($name2); $test_author2->save(); //Act $test_author->delete(); $result = Author::getAll(); //Assert $this->assertEquals($test_author2, $result[0]); }
function testDelete() { //Arrange $name = "Nathan Young"; $id = null; $test_author = new Author($name, $id); $test_author->save(); $name2 = "Kyle Pratuch"; $test_author2 = new Author($name2, $id); $test_author2->save(); //Act $test_author->delete(); // $this->assertEquals([$test_author2], Author::getAll()); }
function test_delete() { //Arrange $name = "Ashlin Aronin"; $test_author = new Author($name); $test_author->save(); $name2 = "Vincent Adultman"; $test_author2 = new Author($name2); $test_author2->save(); //Act $test_author->delete(); //Assert $result = Author::getAll(); $this->assertEquals($test_author2, $result[0]); }
function testDelete() { //Arrange $title = "Harry Potter"; $id = 1; $test_book = new Book($title, $id); $test_book->save(); $name = "JK Rowling"; $id = 1; $test_author = new Author($name, $id); $test_author->save(); //Act $test_author->addBook($test_book); $test_author->delete(); //Assert $this->assertEquals([], $test_book->getAuthors()); }
/** * method Delete() * Delete a record */ function Delete($param) { try { // get the parameter $key $key = $param['key']; // open a transaction with database 'library' TTransaction::open('library'); // instantiates object Author $object = new Author($key); // deletes the object from the database $object->delete(); // close the transaction TTransaction::close(); // reload the listing $this->onReload(); // shows the success message new TMessage('info', TAdiantiCoreTranslator::translate('Record deleted')); } catch (Exception $e) { // shows the exception error message new TMessage('error', '<b>Error</b> ' . $e->getMessage()); // undo all pending operations TTransaction::rollback(); } }
function test_delete() { //Arrange $name = "Stephen King"; $test_author = new Author($name); $test_author->save(); $name2 = "Clive Barker"; $test_author2 = new Author($name2); $test_author2->save(); //Act $test_author->delete(); $result = Author::getAll(); //Assert $this->assertEquals([$test_author2], $result); }
if (!is_writable($Campsite['IMAGE_DIRECTORY'])) { camp_html_add_msg($translator->trans('Unable to add new image, target directory is not writable.', array(), 'users')); camp_html_add_msg(camp_get_error_message(CAMP_ERROR_WRITE_DIR, $Campsite['IMAGE_DIRECTORY'])); camp_html_goto_page("/{$ADMIN}/"); exit; } if (!$g_user->hasPermission('EditAuthors')) { camp_html_display_error($translator->trans('You do not have the permission to change authors.', array(), 'users')); exit; } $id = Input::Get('id', 'int', -1); // Delete author $del_id = Input::Get('del_id', 'int', -1); if ($del_id > -1) { $author = new Author($del_id); if ($author->delete()) { camp_html_add_msg($translator->trans('Author deleted.', array(), 'users'), 'ok'); } } // Add new author type $add_author_type = Input::Get('add_author', 'string', null); if ($add_author_type !== null) { $authorTypeObj = new AuthorType(); if ($authorTypeObj->create($add_author_type) === true) { camp_html_add_msg($translator->trans('Author type added.', array(), 'users'), 'ok'); } else { camp_html_add_msg($translator->trans('Cannot add author type, this type already exists.', array(), 'users')); } } // Delete author type $del_id_type = Input::Get('del_id_type', 'int', -1);
class DefaultValuesForm extends AuthorForm { public function configure() { $this->setDefault('name', 'John Doe'); } } $author = new Author(); $form = new DefaultValuesForm($author); $t->is($form->getDefault('name'), 'John Doe', '->__construct() uses form defaults for new objects'); $author = new Author(); $author->name = 'Jacques Doe'; $author->save(); $form = new DefaultValuesForm($author); $t->is($form->getDefault('name'), 'Jacques Doe', '->__construct() uses object value as a default for existing objects'); $author->delete(); // ->embedRelation() $t->diag('->embedRelation()'); class myArticleForm extends ArticleForm { } $table = Doctrine::getTable('Author'); $form = new AuthorForm($table->create(array('Articles' => array(array('title' => 'Article 1'), array('title' => 'Article 2'), array('title' => 'Article 3'))))); $form->embedRelation('Articles'); $embeddedForms = $form->getEmbeddedForms(); $t->ok(isset($form['Articles']), '->embedRelation() embeds forms'); $t->is(count($embeddedForms['Articles']), 3, '->embedRelation() embeds one form for each related object'); $form->embedRelation('Articles', 'myArticleForm', array(array('test' => true))); $embeddedForms = $form->getEmbeddedForms(); $moreEmbeddedForms = $embeddedForms['Articles']->getEmbeddedForms(); $t->isa_ok($moreEmbeddedForms[0], 'myArticleForm', '->embedRelation() accepts a form class argument');
function testDelete() { //Arrange $name = "Paul Jones"; $id = 1; $test_author = new Author($name, $id); $test_author->save(); $title = "Little Cat"; $id = 1; $test_book = new Book($title, $id); $test_book->save(); //Act $test_author->addBook($test_book); $test_author->delete(); //Assert $this->assertEquals([], $test_book->getAuthors()); }