/** * @return bool * @param Option $o */ public static function updateOption($o) { $db = DB::getConn(); $stm = $db->prepare('update Option set title=:title, isCorrect=:correct where id=:id'); $stm->bindParam(':id', $o->getId()); $stm->bindParam(':title', $o->getText()); $stm->bindParam(':correct', $o->isCorrect()); $stm->execute(); }
function test_getIdsFromNames() { //arrange $name = "peanut-free"; $test_option = new Option($name); $test_option->save(); $name2 = "soy-free"; $test_option2 = new Option($name2); $test_option2->save(); //act $suitable_options_names = array($test_option->getName(), $test_option2->getName()); $result = Option::getIdsFromNames($suitable_options_names); //assert $this->assertEquals([$test_option->getId(), $test_option2->getId()], $result); }