public function testSetGetAllergyCategory() { // Arrange $item = new Item(); $item->setCategory(1); $expectedResult = 1; // Act $result = $item->getCategory(); // Assert $this->assertEquals($result, $expectedResult); }
public function update(Item $item) { $idCategory = $item->getCategory()->getId(); $id = intval($id); $name = $this->db->quote($item->getName()); $price = $this->db->quote($item->getPrice()); $stock = $this->db->quote($item->getStock()); $image = $this->db->quote($item->getImage()); $description = $this->db->quote($item->getDescription()); $query = ' UPDATE item SET name=' . $name . ', price=' . $price . ', stock=' . $stock . ', image=' . $image . ', description=' . $description . ', id_category=' . $idCategory . ' WHERE id=' . $id; $res = $this->db->exec($query); if ($res) { $id = $this->db->lastInsertId(); if ($id) { return $this->findByID($id); } else { throw new Exception('Internal server Error'); } } }
public static function getCountries() { return Item::getCategory('Country'); }