public function update()
 {
     // Load the $category for editing
     if (isset($_REQUEST['category_id']) && $_REQUEST['category_id']) {
         try {
             $category = new Category($_REQUEST['category_id']);
         } catch (\Exception $e) {
             $_SESSION['errorMessages'][] = $e;
             header('Location: ' . BASE_URL . '/categories');
             exit;
         }
     } else {
         $category = new Category();
     }
     if (isset($_POST['name'])) {
         try {
             $category->handleUpdate($_POST);
             $category->save();
             header('Location: ' . BASE_URL . '/categories');
             exit;
         } catch (\Exception $e) {
             $_SESSION['errorMessages'][] = $e;
         }
     }
     $this->template->setFilename('backend');
     $this->template->blocks[] = new Block('categories/updateCategoryForm.inc', array('category' => $category));
 }
 public function testHandleUpdate()
 {
     $data = ['name' => 'Name', 'description' => 'Description', 'postingPermissionLevel' => 'test permission', 'displayPermissionLevel' => 'testing display', 'slaDays' => 2, 'notificationReplyEmail' => 'test@somewhere', 'autoResponseIsActive' => 1, 'autoResponseText' => 'auto response', 'autoCloseIsActive' => 1, 'department_id' => '', 'categoryGroup_id' => '', 'customFields' => '', 'autoCloseSubstatus_id' => ''];
     $category = new Category();
     $category->handleUpdate($data);
     foreach ($data as $f => $value) {
         $get = 'get' . ucfirst($f);
         $this->assertEquals($value, $category->{$get}());
     }
 }