public function updateFaculty() { $validator = Validator::make(Input::all(), array('name' => 'required', 'shortname' => 'required', 'description' => 'required', 'id' => 'required')); if ($validator->fails()) { // If not inform user of errors. return Response::json(array('success' => false, 'errors' => $validator->messages())); } else { // Check user has permission to create faculty. if (Auth::user()->rank == 3) { // Load the Faculty. $faculty = Faculty::find(Input::get('id')); // Save changes. $faculty->facultyname = Input::get('name'); $faculty->facultyshort = Input::get('shortname'); $faculty->facultydescription = Input::get('description'); $faculty->save(); // If not inform user of errors. return Response::json(array('success' => true)); } } }
/** * Function that updates specified faculty. */ protected function updateFaculty($id) { $response = $this->call('POST', '/account/update-faculty', ['name' => 'phpunitFaculty123', 'shortname' => 'phpunitFaculty', 'description' => str_random(60), 'id' => $id]); $json = json_decode($response->getContent()); $this->assertEquals(true, $json->success); // Verify that the change was made. $f = Faculty::find($id); $this->assertEquals('phpunitFaculty123', $f->facultyname); return $f; }