public function testSave() { $name = 'Test Category'; $category = new Category(); $category->setName($name); $category->setCategoryGroup_id($this->testGroupId); $category->setDepartment_id($this->testDepartmentId); $category->save(); $this->assertEquals($category->getName(), $name); $this->assertEquals($category->getCategoryGroup_id(), $this->testGroupId); $this->assertEquals($category->getDepartment_id(), $this->testDepartmentId); }
/** * A form for updating the SLA times for all categories at once */ public function sla() { $this->template->setFilename('backend'); if (isset($_POST['categories'])) { try { foreach ($_POST['categories'] as $id => $post) { $category = new Category($id); $category->setSlaDays($post['slaDays']); $category->save(); } header('Location: ' . BASE_URL . '/categories'); exit; } catch (\Exception $e) { $_SESSION['errorMessages'][] = $e; } } $t = new CategoryTable(); $list = $t->find(); $this->template->blocks[] = new Block('categories/slaForm.inc', ['categoryList' => $list]); }