Exemplo n.º 1
0
 function testDelete()
 {
     $name = "John Doe";
     $password = "******";
     $email = "*****@*****.**";
     $signed_in = 0;
     $test_user = new User($name, $password, $email, $signed_in);
     $test_user->save();
     $course_title = "Literature";
     $subject = "English";
     $course_description = "Deconstructing English literature.";
     $user_id = $test_user->getId();
     $test_course = new Course($course_title, $subject, $course_description, $user_id);
     $test_course->save();
     $unit_title = "Into the Wild";
     $unit_description = "The life and death of Chris McCandless.";
     $course_id = $test_course->getId();
     $test_unit = new Unit($unit_title, $unit_description, $course_id);
     $test_unit->save();
     $unit_title2 = "The Catcher in the Rye";
     $unit_description2 = "Foul-mouthed kid is angsty.";
     $test_unit2 = new Unit($unit_title2, $unit_description2, $course_id);
     $test_unit2->save();
     $test_unit->delete();
     $result = Unit::getAll();
     $this->assertEquals([$test_unit2], $result);
 }
Exemplo n.º 2
0
 function index_delete()
 {
     $models = json_decode($this->delete('models'));
     foreach ($models as $key => $value) {
         $obj = new Unit(null, $this->entity);
         $obj->where("id", $value->id)->get();
         $data["results"][] = array("data" => $value, "status" => $obj->delete());
     }
     //Response data
     $this->response($data, 200);
 }
Exemplo n.º 3
0
        Flight::ok($object);
    } catch (Exception $exception) {
        Flight::error($exception);
    }
});
Flight::route('PUT /v1/main/unit/@id', function ($id) {
    try {
        $object = Unit::update($id);
        Flight::ok($object);
    } catch (Exception $exception) {
        Flight::error($exception);
    }
});
Flight::route('DELETE /v1/main/unit/@id', function ($id) {
    try {
        $object = Unit::delete($id);
        Flight::ok($object);
    } catch (Exception $exception) {
        Flight::error($exception);
    }
});
//=============================================================================
//UnitType
//=============================================================================
Flight::route('GET /v1/main/unittype', function () {
    try {
        $array = UnitType::selectAll();
        Flight::ok($array);
    } catch (Exception $exception) {
        Flight::error($exception);
    }