public function update() { if (!empty($_REQUEST['contactMethod_id'])) { try { $method = new ContactMethod($_REQUEST['contactMethod_id']); } catch (\Exception $e) { $_SESSION['errorMessages'][] = $e; header('Location: ' . BASE_URL . '/contactMethods'); exit; } } else { $method = new ContactMethod(); } if (isset($_POST['name'])) { $method->handleUpdate($_POST); try { $method->save(); header('Location: ' . BASE_URL . '/contactMethods'); exit; } catch (\Exception $e) { $_SESSION['errorMessages'][] = $e; } } $this->template->blocks[] = new Block('contactMethods/updateForm.inc', array('contactMethod' => $method)); }
public function testSaveAndLoad() { $method = new ContactMethod(); $method->setName('test'); $method->save(); $id = $method->getId(); $this->assertNotEmpty($id); $method = new ContactMethod($id); $this->assertEquals('test', $method->getName()); }