function test_save() { //Arrange $description = "Buy book on learning French"; $project_id = 1; $position = 1; $test_step = new Step($description, $project_id, $position); //Act $test_step->save(); //Assert $result = Step::getAll(); $this->assertEquals([$test_step], $result); }
function test_delete() { //Arrange $description = "Buy book on learning French"; $project_id = 1; $position = 1; $test_step = new Step($description, $project_id, $position); $test_step->save(); $description2 = "Buy French bread"; $project_id2 = 1; $position2 = 2; $test_step2 = new Step($description2, $project_id2, $position2); $test_step2->save(); //Act $test_step->delete(); $result = Step::getAll(); //Assert $this->assertEquals([$test_step2], $result); }
static function find($search_id) { $found_step = null; $steps = Step::getAll(); foreach ($steps as $step) { if ($step->getId() == $search_id) { $found_step = $step; } } return $found_step; }