public function postEditProfile(Request $request) { $input = $request->all(); $service = new UserProfileService($this->profile_validator); try { $service->processForm($input); } catch (JacopoExceptionsInterface $e) { $errors = $service->getErrors(); return Redirect::back()->withInput()->withErrors($errors); } return Redirect::back()->withInput()->withMessage(Config::get('acl_messages.flash.success.user_profile_edit_success')); }
/** * @test **/ public function it_check_for_permission_and_set_error_incase() { $mock_auth_helper = m::mock('StdClass')->shouldReceive('checkProfileEditPermission')->once()->andReturn(false)->getMock(); App::instance('authentication_helper', $mock_auth_helper); $service = new UserProfileService(new VoidValidator()); try { $service->processForm(["user_id" => 1]); } catch (\LaravelAcl\Authentication\Exceptions\PermissionException $e) { } $errors = $service->getErrors(); $this->assertTrue($errors->has('model')); }