function testSetCategoryName() { //Arrange $category_name = "Kitchen chores"; $test_category = new Category($category_name); //Act $test_category->setCategoryName("Home chores"); $result = $test_category->getCategoryName(); //Assert $this->assertEquals("Home chores", $result); }
function testUpdate() { $category_name = "music"; $new_category = new Category($category_name); $new_category->save(); $new_category->setCategoryName("concerts"); $new_category->update(); $result = Category::getAll(); $this->assertEquals($new_category, $result[0]); }
/** * Populate category object * * @param array $category * @return object Category */ protected function getCategory($category) { if (empty($category)) { throw new BuyatException('Malformed response from server'); } $categoryObject = new Category(); $categoryObject->setCategoryID($category['category_id']); $categoryObject->setLevel($category['level']); $categoryObject->setCategoryName($category['category_name']); if (isset($category['subcategories'])) { $vSubCategories = array(); foreach ($category['subcategories'] as $vSubCategory) { $vSubCategories[] = $this->getCategory($vSubCategory['value']); } $categoryObject->setSubcategories($vSubCategories); } if (isset($category['parent_category_id'])) { $categoryObject->setParentCategoryID($category['parent_category_id']); } if (isset($category['parent_category_name'])) { $categoryObject->setParentCategoryName($category['parent_category_name']); } return $categoryObject; }