From 95df53135dc37555a5ded751a94ef409d06b3edb Mon Sep 17 00:00:00 2001 From: Alexis Saettler Date: Sat, 5 Jan 2019 16:24:09 +0100 Subject: [PATCH] fix: fix validation fails with Services (#2258) --- CHANGELOG | 1 + app/Exceptions/MissingParameterException.php | 24 -------- .../Api/Account/ApiCompanyController.php | 14 ++--- .../Api/Account/ApiGenderController.php | 14 ++--- .../Api/Account/ApiPlaceController.php | 14 ++--- .../Controllers/Api/ApiContactController.php | 10 +-- app/Http/Controllers/Api/ApiTagController.php | 14 ++--- .../Controllers/Api/ApiTaskController.php | 14 ++--- .../Api/Contact/ApiAddressController.php | 14 ++--- .../Api/Contact/ApiCallController.php | 14 ++--- .../Api/Contact/ApiConversationController.php | 14 ++--- .../Api/Contact/ApiLifeEventController.php | 10 +-- .../Api/Contact/ApiMessageController.php | 14 ++--- .../Api/Contact/ApiOccupationController.php | 14 ++--- .../Contacts/AddressesController.php | 61 +++++++++++-------- app/Http/Controllers/ContactsController.php | 27 +++++--- app/Models/Account/ImportJob.php | 4 +- app/Services/BaseService.php | 8 +-- .../Weather/GetWeatherInformation.php | 2 +- app/Traits/JsonRespondController.php | 58 ++++++++++-------- config/logging.php | 2 +- .../Api/Account/ApiCompanyControllerTest.php | 2 +- tests/Api/Account/ApiGenderControllerTest.php | 2 +- tests/Api/Account/ApiPlaceControllerTest.php | 2 +- .../ApiActivityTypeCategoryControllerTest.php | 16 ++--- .../ApiActivityTypeControllerTest.php | 21 ++----- tests/Api/ApiTaskControllerTest.php | 4 +- .../Api/Contact/ApiAdressesControllerTest.php | 6 +- tests/Api/Contact/ApiCallControllerTest.php | 4 +- .../Api/Contact/ApiContactControllerTest.php | 4 +- .../Contact/ApiLifeEventControllerTest.php | 4 +- .../Contact/ApiOccupationControllerTest.php | 2 +- .../ApiContactFieldControllerTest.php | 2 +- .../ApiContactFieldTypeControllerTest.php | 2 +- tests/ApiTestCase.php | 8 +-- tests/Feature/InstanceTest.php | 3 + .../Account/Company/CreateCompanyTest.php | 4 +- .../Account/Company/DestroyCompanyTest.php | 4 +- .../Account/Company/UpdateCompanyTest.php | 4 +- .../Account/DestroyAllDocumentsTest.php | 4 +- .../Account/Gender/CreateGenderTest.php | 4 +- .../Account/Gender/DestroyGenderTest.php | 4 +- .../Account/Gender/UpdateGenderTest.php | 4 +- .../Account/Photo/DestroyPhotoTest.php | 4 +- .../Account/Photo/UploadPhotoTest.php | 6 +- .../Account/Place/CreatePlaceTest.php | 4 +- .../Account/Place/DestroyPlaceTest.php | 4 +- .../Account/Place/UpdatePlaceTest.php | 4 +- .../PopulateContactFieldTypesTableTest.php | 4 +- .../Auth/PopulateLifeEventsTableTest.php | 4 +- .../Auth/PopulateModulesTableTest.php | 4 +- .../Contact/Address/CreateAddressTest.php | 4 +- .../Contact/Address/DestroyAddressTest.php | 4 +- .../Contact/Address/UpdateAddressTest.php | 4 +- .../Services/Contact/Call/CreateCallTest.php | 4 +- .../Services/Contact/Call/UpdateCallTest.php | 4 +- .../Contact/Contact/CreateContactTest.php | 6 +- .../Contact/Contact/DestroyContactTest.php | 4 +- .../Contact/UpdateBirthdayInformationTest.php | 6 +- .../Contact/Contact/UpdateContactTest.php | 6 +- .../Contact/UpdateDeceasedInformationTest.php | 6 +- .../AddMessageToConversationTest.php | 4 +- .../Conversation/CreateConversationTest.php | 4 +- .../Conversation/DestroyConversationTest.php | 4 +- .../Conversation/DestroyMessageTest.php | 4 +- .../Conversation/UpdateConversationTest.php | 4 +- .../Conversation/UpdateMessageTest.php | 4 +- .../Contact/Document/DestroyDocumentTest.php | 4 +- .../Contact/Document/UploadDocumentTest.php | 4 +- .../LifeEvent/AddReminderToLifeEventTest.php | 4 +- .../Contact/LifeEvent/CreateLifeEventTest.php | 4 +- .../LifeEvent/DestroyLifeEventTest.php | 4 +- .../Contact/LifeEvent/UpdateLifeEventTest.php | 4 +- .../Occupation/CreateOccupationTest.php | 4 +- .../Occupation/UpdateOccupationTest.php | 4 +- .../Relationship/DestroyRelationshipTest.php | 4 +- .../Contact/Reminder/CreateReminderTest.php | 10 +-- .../Services/Contact/Tag/AssociateTagTest.php | 4 +- .../Services/Contact/Tag/CreateTagTest.php | 4 +- .../Services/Contact/Tag/DestroyTagTest.php | 4 +- .../Services/Contact/Tag/DetachTagTest.php | 4 +- .../Services/Contact/Tag/UpdateTagTest.php | 4 +- .../Geolocalization/GetGPSCoordinateTest.php | 4 +- .../Weather/GetWeatherInformationTest.php | 4 +- tests/Unit/Services/Task/CreateTaskTest.php | 4 +- tests/Unit/Services/Task/DestroyTaskTest.php | 4 +- tests/Unit/Services/Task/UpdateTaskTest.php | 4 +- tests/Unit/Services/User/EmailChangeTest.php | 4 +- 88 files changed, 317 insertions(+), 336 deletions(-) delete mode 100644 app/Exceptions/MissingParameterException.php diff --git a/CHANGELOG b/CHANGELOG index a093980b9..a2e229cb1 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -11,6 +11,7 @@ Enhancements: Fixes: +* Fix validation fails with Services * Fix getting birthday reminders about related contacts * Fix default temperature scale setting * Fix API methods for Occupation object diff --git a/app/Exceptions/MissingParameterException.php b/app/Exceptions/MissingParameterException.php deleted file mode 100644 index 3f4349fd4..000000000 --- a/app/Exceptions/MissingParameterException.php +++ /dev/null @@ -1,24 +0,0 @@ -errors = $errors; - parent::__construct($message, $code, $previous); - } -} diff --git a/app/Http/Controllers/Api/Account/ApiCompanyController.php b/app/Http/Controllers/Api/Account/ApiCompanyController.php index 3f31df932..948753c42 100644 --- a/app/Http/Controllers/Api/Account/ApiCompanyController.php +++ b/app/Http/Controllers/Api/Account/ApiCompanyController.php @@ -6,7 +6,7 @@ use Illuminate\Http\Request; use App\Models\Account\Company; use Illuminate\Database\QueryException; use App\Http\Controllers\Api\ApiController; -use App\Exceptions\MissingParameterException; +use Illuminate\Validation\ValidationException; use App\Services\Account\Company\CreateCompany; use App\Services\Account\Company\UpdateCompany; use App\Services\Account\Company\DestroyCompany; @@ -70,8 +70,8 @@ class ApiCompanyController extends ApiController ); } catch (ModelNotFoundException $e) { return $this->respondNotFound(); - } catch (MissingParameterException $e) { - return $this->respondInvalidParameters($e->errors); + } catch (ValidationException $e) { + return $this->respondValidatorFailed($e->validator); } catch (QueryException $e) { return $this->respondInvalidQuery(); } @@ -99,8 +99,8 @@ class ApiCompanyController extends ApiController ); } catch (ModelNotFoundException $e) { return $this->respondNotFound(); - } catch (MissingParameterException $e) { - return $this->respondInvalidParameters($e->errors); + } catch (ValidationException $e) { + return $this->respondValidatorFailed($e->validator); } catch (QueryException $e) { return $this->respondInvalidQuery(); } @@ -123,8 +123,8 @@ class ApiCompanyController extends ApiController ]); } catch (ModelNotFoundException $e) { return $this->respondNotFound(); - } catch (MissingParameterException $e) { - return $this->respondInvalidParameters($e->errors); + } catch (ValidationException $e) { + return $this->respondValidatorFailed($e->validator); } catch (QueryException $e) { return $this->respondInvalidQuery(); } diff --git a/app/Http/Controllers/Api/Account/ApiGenderController.php b/app/Http/Controllers/Api/Account/ApiGenderController.php index df6576563..cea7a3546 100644 --- a/app/Http/Controllers/Api/Account/ApiGenderController.php +++ b/app/Http/Controllers/Api/Account/ApiGenderController.php @@ -6,10 +6,10 @@ use Illuminate\Http\Request; use App\Models\Contact\Gender; use Illuminate\Database\QueryException; use App\Http\Controllers\Api\ApiController; -use App\Exceptions\MissingParameterException; use App\Services\Account\Gender\CreateGender; use App\Services\Account\Gender\UpdateGender; use App\Services\Account\Gender\DestroyGender; +use Illuminate\Validation\ValidationException; use App\Http\Resources\Gender\Gender as GenderResource; use Illuminate\Database\Eloquent\ModelNotFoundException; @@ -70,8 +70,8 @@ class ApiGenderController extends ApiController ); } catch (ModelNotFoundException $e) { return $this->respondNotFound(); - } catch (MissingParameterException $e) { - return $this->respondInvalidParameters($e->errors); + } catch (ValidationException $e) { + return $this->respondValidatorFailed($e->validator); } catch (QueryException $e) { return $this->respondInvalidQuery(); } @@ -99,8 +99,8 @@ class ApiGenderController extends ApiController ); } catch (ModelNotFoundException $e) { return $this->respondNotFound(); - } catch (MissingParameterException $e) { - return $this->respondInvalidParameters($e->errors); + } catch (ValidationException $e) { + return $this->respondValidatorFailed($e->validator); } catch (QueryException $e) { return $this->respondInvalidQuery(); } @@ -123,8 +123,8 @@ class ApiGenderController extends ApiController ]); } catch (ModelNotFoundException $e) { return $this->respondNotFound(); - } catch (MissingParameterException $e) { - return $this->respondInvalidParameters($e->errors); + } catch (ValidationException $e) { + return $this->respondValidatorFailed($e->validator); } catch (QueryException $e) { return $this->respondInvalidQuery(); } diff --git a/app/Http/Controllers/Api/Account/ApiPlaceController.php b/app/Http/Controllers/Api/Account/ApiPlaceController.php index 6d60bc96f..572833921 100644 --- a/app/Http/Controllers/Api/Account/ApiPlaceController.php +++ b/app/Http/Controllers/Api/Account/ApiPlaceController.php @@ -9,7 +9,7 @@ use App\Http\Controllers\Api\ApiController; use App\Services\Account\Place\CreatePlace; use App\Services\Account\Place\UpdatePlace; use App\Services\Account\Place\DestroyPlace; -use App\Exceptions\MissingParameterException; +use Illuminate\Validation\ValidationException; use App\Http\Resources\Place\Place as PlaceResource; use Illuminate\Database\Eloquent\ModelNotFoundException; @@ -70,8 +70,8 @@ class ApiPlaceController extends ApiController ); } catch (ModelNotFoundException $e) { return $this->respondNotFound(); - } catch (MissingParameterException $e) { - return $this->respondInvalidParameters($e->errors); + } catch (ValidationException $e) { + return $this->respondValidatorFailed($e->validator); } catch (QueryException $e) { return $this->respondInvalidQuery(); } @@ -99,8 +99,8 @@ class ApiPlaceController extends ApiController ); } catch (ModelNotFoundException $e) { return $this->respondNotFound(); - } catch (MissingParameterException $e) { - return $this->respondInvalidParameters($e->errors); + } catch (ValidationException $e) { + return $this->respondValidatorFailed($e->validator); } catch (QueryException $e) { return $this->respondInvalidQuery(); } @@ -123,8 +123,8 @@ class ApiPlaceController extends ApiController ]); } catch (ModelNotFoundException $e) { return $this->respondNotFound(); - } catch (MissingParameterException $e) { - return $this->respondInvalidParameters($e->errors); + } catch (ValidationException $e) { + return $this->respondValidatorFailed($e->validator); } catch (QueryException $e) { return $this->respondInvalidQuery(); } diff --git a/app/Http/Controllers/Api/ApiContactController.php b/app/Http/Controllers/Api/ApiContactController.php index 9665b0217..048098d83 100644 --- a/app/Http/Controllers/Api/ApiContactController.php +++ b/app/Http/Controllers/Api/ApiContactController.php @@ -7,7 +7,7 @@ use App\Helpers\SearchHelper; use App\Models\Contact\Contact; use Illuminate\Support\Collection; use Illuminate\Database\QueryException; -use App\Exceptions\MissingParameterException; +use Illuminate\Validation\ValidationException; use App\Services\Contact\Contact\CreateContact; use App\Services\Contact\Contact\UpdateContact; use App\Services\Contact\Contact\DestroyContact; @@ -101,8 +101,8 @@ class ApiContactController extends ApiController ); } catch (ModelNotFoundException $e) { return $this->respondNotFound(); - } catch (MissingParameterException $e) { - return $this->respondInvalidParameters($e->errors); + } catch (ValidationException $e) { + return $this->respondValidatorFailed($e->validator); } catch (QueryException $e) { return $this->respondInvalidQuery(); } @@ -128,8 +128,8 @@ class ApiContactController extends ApiController ); } catch (ModelNotFoundException $e) { return $this->respondNotFound(); - } catch (MissingParameterException $e) { - return $this->respondInvalidParameters($e->errors); + } catch (ValidationException $e) { + return $this->respondValidatorFailed($e->validator); } catch (QueryException $e) { return $this->respondInvalidQuery(); } diff --git a/app/Http/Controllers/Api/ApiTagController.php b/app/Http/Controllers/Api/ApiTagController.php index e42185818..4b83de9ba 100644 --- a/app/Http/Controllers/Api/ApiTagController.php +++ b/app/Http/Controllers/Api/ApiTagController.php @@ -8,8 +8,8 @@ use App\Services\Contact\Tag\CreateTag; use App\Services\Contact\Tag\UpdateTag; use Illuminate\Database\QueryException; use App\Services\Contact\Tag\DestroyTag; -use App\Exceptions\MissingParameterException; use App\Http\Resources\Tag\Tag as TagResource; +use Illuminate\Validation\ValidationException; use Illuminate\Database\Eloquent\ModelNotFoundException; class ApiTagController extends ApiController @@ -69,8 +69,8 @@ class ApiTagController extends ApiController ); } catch (ModelNotFoundException $e) { return $this->respondNotFound(); - } catch (MissingParameterException $e) { - return $this->respondInvalidParameters($e->errors); + } catch (ValidationException $e) { + return $this->respondValidatorFailed($e->validator); } return new TagResource($tag); @@ -94,8 +94,8 @@ class ApiTagController extends ApiController ); } catch (ModelNotFoundException $e) { return $this->respondNotFound(); - } catch (MissingParameterException $e) { - return $this->respondInvalidParameters($e->errors); + } catch (ValidationException $e) { + return $this->respondValidatorFailed($e->validator); } return new TagResource($tag); @@ -115,8 +115,8 @@ class ApiTagController extends ApiController ]); } catch (ModelNotFoundException $e) { return $this->respondNotFound(); - } catch (MissingParameterException $e) { - return $this->respondInvalidParameters($e->errors); + } catch (ValidationException $e) { + return $this->respondValidatorFailed($e->validator); } return $this->respondObjectDeleted($id); diff --git a/app/Http/Controllers/Api/ApiTaskController.php b/app/Http/Controllers/Api/ApiTaskController.php index def22c08e..556accc32 100644 --- a/app/Http/Controllers/Api/ApiTaskController.php +++ b/app/Http/Controllers/Api/ApiTaskController.php @@ -9,7 +9,7 @@ use App\Services\Task\CreateTask; use App\Services\Task\UpdateTask; use App\Services\Task\DestroyTask; use Illuminate\Database\QueryException; -use App\Exceptions\MissingParameterException; +use Illuminate\Validation\ValidationException; use App\Http\Resources\Task\Task as TaskResource; use Illuminate\Database\Eloquent\ModelNotFoundException; @@ -67,8 +67,8 @@ class ApiTaskController extends ApiController ]); } catch (ModelNotFoundException $e) { return $this->respondNotFound(); - } catch (MissingParameterException $e) { - return $this->respondInvalidParameters($e->errors); + } catch (ValidationException $e) { + return $this->respondValidatorFailed($e->validator); } return new TaskResource($task); @@ -93,8 +93,8 @@ class ApiTaskController extends ApiController ); } catch (ModelNotFoundException $e) { return $this->respondNotFound(); - } catch (MissingParameterException $e) { - return $this->respondInvalidParameters($e->errors); + } catch (ValidationException $e) { + return $this->respondValidatorFailed($e->validator); } return new TaskResource($task); @@ -114,8 +114,8 @@ class ApiTaskController extends ApiController ]); } catch (ModelNotFoundException $e) { return $this->respondNotFound(); - } catch (MissingParameterException $e) { - return $this->respondInvalidParameters($e->errors); + } catch (ValidationException $e) { + return $this->respondValidatorFailed($e->validator); } return $this->respondObjectDeleted($taskId); diff --git a/app/Http/Controllers/Api/Contact/ApiAddressController.php b/app/Http/Controllers/Api/Contact/ApiAddressController.php index 97ee8ddd8..1cf221ab2 100644 --- a/app/Http/Controllers/Api/Contact/ApiAddressController.php +++ b/app/Http/Controllers/Api/Contact/ApiAddressController.php @@ -7,7 +7,7 @@ use App\Models\Contact\Address; use App\Models\Contact\Contact; use Illuminate\Database\QueryException; use App\Http\Controllers\Api\ApiController; -use App\Exceptions\MissingParameterException; +use Illuminate\Validation\ValidationException; use App\Services\Contact\Address\CreateAddress; use App\Services\Contact\Address\UpdateAddress; use App\Services\Contact\Address\DestroyAddress; @@ -70,8 +70,8 @@ class ApiAddressController extends ApiController ); } catch (ModelNotFoundException $e) { return $this->respondNotFound(); - } catch (MissingParameterException $e) { - return $this->respondInvalidParameters($e->errors); + } catch (ValidationException $e) { + return $this->respondValidatorFailed($e->validator); } catch (QueryException $e) { return $this->respondInvalidQuery(); } @@ -98,8 +98,8 @@ class ApiAddressController extends ApiController ); } catch (ModelNotFoundException $e) { return $this->respondNotFound(); - } catch (MissingParameterException $e) { - return $this->respondInvalidParameters($e->errors); + } catch (ValidationException $e) { + return $this->respondValidatorFailed($e->validator); } catch (QueryException $e) { return $this->respondInvalidQuery(); } @@ -121,8 +121,8 @@ class ApiAddressController extends ApiController ]); } catch (ModelNotFoundException $e) { return $this->respondNotFound(); - } catch (MissingParameterException $e) { - return $this->respondInvalidParameters($e->errors); + } catch (ValidationException $e) { + return $this->respondValidatorFailed($e->validator); } catch (QueryException $e) { return $this->respondInvalidQuery(); } diff --git a/app/Http/Controllers/Api/Contact/ApiCallController.php b/app/Http/Controllers/Api/Contact/ApiCallController.php index a6b831d9a..cff7b014e 100644 --- a/app/Http/Controllers/Api/Contact/ApiCallController.php +++ b/app/Http/Controllers/Api/Contact/ApiCallController.php @@ -10,7 +10,7 @@ use App\Services\Contact\Call\CreateCall; use App\Services\Contact\Call\UpdateCall; use App\Services\Contact\Call\DestroyCall; use App\Http\Controllers\Api\ApiController; -use App\Exceptions\MissingParameterException; +use Illuminate\Validation\ValidationException; use App\Http\Resources\Call\Call as CallResource; use Illuminate\Database\Eloquent\ModelNotFoundException; @@ -71,8 +71,8 @@ class ApiCallController extends ApiController ); } catch (ModelNotFoundException $e) { return $this->respondNotFound(); - } catch (MissingParameterException $e) { - return $this->respondInvalidParameters($e->errors); + } catch (ValidationException $e) { + return $this->respondValidatorFailed($e->validator); } catch (QueryException $e) { return $this->respondInvalidQuery(); } @@ -100,8 +100,8 @@ class ApiCallController extends ApiController ); } catch (ModelNotFoundException $e) { return $this->respondNotFound(); - } catch (MissingParameterException $e) { - return $this->respondInvalidParameters($e->errors); + } catch (ValidationException $e) { + return $this->respondValidatorFailed($e->validator); } catch (QueryException $e) { return $this->respondInvalidQuery(); } @@ -124,8 +124,8 @@ class ApiCallController extends ApiController ]); } catch (ModelNotFoundException $e) { return $this->respondNotFound(); - } catch (MissingParameterException $e) { - return $this->respondInvalidParameters($e->errors); + } catch (ValidationException $e) { + return $this->respondValidatorFailed($e->validator); } catch (QueryException $e) { return $this->respondInvalidQuery(); } diff --git a/app/Http/Controllers/Api/Contact/ApiConversationController.php b/app/Http/Controllers/Api/Contact/ApiConversationController.php index 08e7a5939..1c142ac9b 100644 --- a/app/Http/Controllers/Api/Contact/ApiConversationController.php +++ b/app/Http/Controllers/Api/Contact/ApiConversationController.php @@ -7,7 +7,7 @@ use App\Models\Contact\Contact; use App\Models\Contact\Conversation; use Illuminate\Database\QueryException; use App\Http\Controllers\Api\ApiController; -use App\Exceptions\MissingParameterException; +use Illuminate\Validation\ValidationException; use Illuminate\Database\Eloquent\ModelNotFoundException; use App\Services\Contact\Conversation\CreateConversation; use App\Services\Contact\Conversation\UpdateConversation; @@ -97,8 +97,8 @@ class ApiConversationController extends ApiController ); } catch (ModelNotFoundException $e) { return $this->respondNotFound(); - } catch (MissingParameterException $e) { - return $this->respondInvalidParameters($e->errors); + } catch (ValidationException $e) { + return $this->respondValidatorFailed($e->validator); } catch (QueryException $e) { return $this->respondInvalidQuery(); } @@ -126,8 +126,8 @@ class ApiConversationController extends ApiController ); } catch (ModelNotFoundException $e) { return $this->respondNotFound(); - } catch (MissingParameterException $e) { - return $this->respondInvalidParameters($e->errors); + } catch (ValidationException $e) { + return $this->respondValidatorFailed($e->validator); } catch (QueryException $e) { return $this->respondInvalidQuery(); } @@ -151,8 +151,8 @@ class ApiConversationController extends ApiController ]); } catch (ModelNotFoundException $e) { return $this->respondNotFound(); - } catch (MissingParameterException $e) { - return $this->respondInvalidParameters($e->errors); + } catch (ValidationException $e) { + return $this->respondValidatorFailed($e->validator); } catch (QueryException $e) { return $this->respondInvalidQuery(); } diff --git a/app/Http/Controllers/Api/Contact/ApiLifeEventController.php b/app/Http/Controllers/Api/Contact/ApiLifeEventController.php index 3a8ee942d..c9d86da6b 100644 --- a/app/Http/Controllers/Api/Contact/ApiLifeEventController.php +++ b/app/Http/Controllers/Api/Contact/ApiLifeEventController.php @@ -5,7 +5,7 @@ namespace App\Http\Controllers\Api\Contact; use Illuminate\Http\Request; use App\Models\Contact\LifeEvent; use App\Http\Controllers\Api\ApiController; -use App\Exceptions\MissingParameterException; +use Illuminate\Validation\ValidationException; use App\Services\Contact\LifeEvent\CreateLifeEvent; use App\Services\Contact\LifeEvent\UpdateLifeEvent; use App\Services\Contact\LifeEvent\DestroyLifeEvent; @@ -64,8 +64,8 @@ class ApiLifeEventController extends ApiController ); } catch (ModelNotFoundException $e) { return $this->respondNotFound(); - } catch (MissingParameterException $e) { - return $this->respondInvalidParameters($e->errors); + } catch (ValidationException $e) { + return $this->respondValidatorFailed($e->validator); } return new LifeEventResource($lifeEvent); @@ -91,8 +91,8 @@ class ApiLifeEventController extends ApiController ); } catch (ModelNotFoundException $e) { return $this->respondNotFound(); - } catch (MissingParameterException $e) { - return $this->respondInvalidParameters($e->errors); + } catch (ValidationException $e) { + return $this->respondValidatorFailed($e->validator); } return new LifeEventResource($lifeEvent); diff --git a/app/Http/Controllers/Api/Contact/ApiMessageController.php b/app/Http/Controllers/Api/Contact/ApiMessageController.php index ef5e07af1..d651db0d4 100644 --- a/app/Http/Controllers/Api/Contact/ApiMessageController.php +++ b/app/Http/Controllers/Api/Contact/ApiMessageController.php @@ -7,7 +7,7 @@ use App\Models\Contact\Message; use App\Models\Contact\Conversation; use Illuminate\Database\QueryException; use App\Http\Controllers\Api\ApiController; -use App\Exceptions\MissingParameterException; +use Illuminate\Validation\ValidationException; use App\Services\Contact\Conversation\UpdateMessage; use App\Services\Contact\Conversation\DestroyMessage; use Illuminate\Database\Eloquent\ModelNotFoundException; @@ -42,8 +42,8 @@ class ApiMessageController extends ApiController ); } catch (ModelNotFoundException $e) { return $this->respondNotFound(); - } catch (MissingParameterException $e) { - return $this->respondInvalidParameters($e->errors); + } catch (ValidationException $e) { + return $this->respondValidatorFailed($e->validator); } catch (QueryException $e) { return $this->respondInvalidQuery(); } @@ -81,8 +81,8 @@ class ApiMessageController extends ApiController ); } catch (ModelNotFoundException $e) { return $this->respondNotFound(); - } catch (MissingParameterException $e) { - return $this->respondInvalidParameters($e->errors); + } catch (ValidationException $e) { + return $this->respondValidatorFailed($e->validator); } catch (QueryException $e) { return $this->respondInvalidQuery(); } @@ -115,8 +115,8 @@ class ApiMessageController extends ApiController ]); } catch (ModelNotFoundException $e) { return $this->respondNotFound(); - } catch (MissingParameterException $e) { - return $this->respondInvalidParameters($e->errors); + } catch (ValidationException $e) { + return $this->respondValidatorFailed($e->validator); } catch (QueryException $e) { return $this->respondInvalidQuery(); } diff --git a/app/Http/Controllers/Api/Contact/ApiOccupationController.php b/app/Http/Controllers/Api/Contact/ApiOccupationController.php index f701850f3..5f476dc5e 100644 --- a/app/Http/Controllers/Api/Contact/ApiOccupationController.php +++ b/app/Http/Controllers/Api/Contact/ApiOccupationController.php @@ -6,7 +6,7 @@ use Illuminate\Http\Request; use App\Models\Contact\Occupation; use Illuminate\Database\QueryException; use App\Http\Controllers\Api\ApiController; -use App\Exceptions\MissingParameterException; +use Illuminate\Validation\ValidationException; use App\Services\Contact\Occupation\CreateOccupation; use App\Services\Contact\Occupation\UpdateOccupation; use App\Services\Contact\Occupation\DestroyOccupation; @@ -70,8 +70,8 @@ class ApiOccupationController extends ApiController ); } catch (ModelNotFoundException $e) { return $this->respondNotFound(); - } catch (MissingParameterException $e) { - return $this->respondInvalidParameters($e->errors); + } catch (ValidationException $e) { + return $this->respondValidatorFailed($e->validator); } catch (QueryException $e) { return $this->respondInvalidQuery(); } @@ -99,8 +99,8 @@ class ApiOccupationController extends ApiController ); } catch (ModelNotFoundException $e) { return $this->respondNotFound(); - } catch (MissingParameterException $e) { - return $this->respondInvalidParameters($e->errors); + } catch (ValidationException $e) { + return $this->respondValidatorFailed($e->validator); } catch (QueryException $e) { return $this->respondInvalidQuery(); } @@ -123,8 +123,8 @@ class ApiOccupationController extends ApiController ]); } catch (ModelNotFoundException $e) { return $this->respondNotFound(); - } catch (MissingParameterException $e) { - return $this->respondInvalidParameters($e->errors); + } catch (ValidationException $e) { + return $this->respondValidatorFailed($e->validator); } catch (QueryException $e) { return $this->respondInvalidQuery(); } diff --git a/app/Http/Controllers/Contacts/AddressesController.php b/app/Http/Controllers/Contacts/AddressesController.php index 921a51cd0..f68b03986 100644 --- a/app/Http/Controllers/Contacts/AddressesController.php +++ b/app/Http/Controllers/Contacts/AddressesController.php @@ -9,6 +9,7 @@ use App\Models\Contact\Contact; use App\Helpers\CountriesHelper; use App\Http\Controllers\Controller; use Illuminate\Support\Facades\Auth; +use App\Traits\JsonRespondController; use Illuminate\Support\Facades\Cache; use App\Services\Contact\Address\CreateAddress; use App\Services\Contact\Address\UpdateAddress; @@ -16,6 +17,8 @@ use App\Services\Contact\Address\DestroyAddress; class AddressesController extends Controller { + use JsonRespondController; + /** * Get all the addresses for this contact. */ @@ -66,20 +69,21 @@ class AddressesController extends Controller */ public function store(Request $request, Contact $contact) { - $request = [ - 'account_id' => auth()->user()->account->id, + $datas = [ + 'account_id' => auth()->user()->account_id, 'contact_id' => $contact->id, - 'name' => $request->get('name'), - 'country' => $request->get('country'), - 'street' => $request->get('street'), - 'city' => $request->get('city'), - 'province' => $request->get('province'), - 'postal_code' => $request->get('postal_code'), - 'latitude' => $request->get('latitude'), - 'longitude' => $request->get('longitude'), - ]; + ] + $request->only([ + 'name', + 'country', + 'street', + 'city', + 'province', + 'postal_code', + 'latitude', + 'longitude', + ]); - return (new CreateAddress)->execute($request); + return (new CreateAddress)->execute($datas); } /** @@ -87,21 +91,22 @@ class AddressesController extends Controller */ public function edit(Request $request, Contact $contact, Address $address) { - $request = [ - 'account_id' => auth()->user()->account->id, + $datas = [ + 'account_id' => auth()->user()->account_id, 'contact_id' => $contact->id, 'address_id' => $address->id, - 'name' => $request->get('name'), - 'country' => $request->get('country'), - 'street' => $request->get('street'), - 'city' => $request->get('city'), - 'province' => $request->get('province'), - 'postal_code' => $request->get('postal_code'), - 'latitude' => $request->get('latitude'), - 'longitude' => $request->get('longitude'), - ]; + ] + $request->only([ + 'name', + 'country', + 'street', + 'city', + 'province', + 'postal_code', + 'latitude', + 'longitude', + ]); - return (new UpdateAddress)->execute($request); + return (new UpdateAddress)->execute($datas); } /** @@ -114,11 +119,13 @@ class AddressesController extends Controller */ public function destroy(Request $request, Contact $contact, Address $address) { - $request = [ - 'account_id' => auth()->user()->account->id, + $datas = [ + 'account_id' => auth()->user()->account_id, 'address_id' => $address->id, ]; - (new DestroyAddress)->execute($request); + if ((new DestroyAddress)->execute($datas)) { + return $this->respondObjectDeleted($address->id); + } } } diff --git a/app/Http/Controllers/ContactsController.php b/app/Http/Controllers/ContactsController.php index be70cf1e8..5e89c095a 100644 --- a/app/Http/Controllers/ContactsController.php +++ b/app/Http/Controllers/ContactsController.php @@ -13,6 +13,7 @@ use App\Services\VCard\ExportVCard; use Illuminate\Support\Facades\Auth; use App\Models\Relationship\Relationship; use Barryvdh\Debugbar\Facade as Debugbar; +use Illuminate\Validation\ValidationException; use App\Services\Contact\Contact\CreateContact; use App\Services\Contact\Contact\UpdateContact; use App\Services\Contact\Contact\DestroyContact; @@ -172,16 +173,22 @@ class ContactsController extends Controller */ public function store(Request $request) { - $contact = (new CreateContact)->execute([ - 'account_id' => auth()->user()->account->id, - 'first_name' => $request->get('first_name'), - 'last_name' => $request->input('last_name', null), - 'nickname' => $request->input('nickname', null), - 'gender_id' => $request->get('gender'), - 'is_birthdate_known' => false, - 'is_deceased' => false, - 'is_deceased_date_known' => false, - ]); + try { + $contact = (new CreateContact)->execute([ + 'account_id' => auth()->user()->account->id, + 'first_name' => $request->get('first_name'), + 'last_name' => $request->input('last_name', null), + 'nickname' => $request->input('nickname', null), + 'gender_id' => $request->get('gender'), + 'is_birthdate_known' => false, + 'is_deceased' => false, + 'is_deceased_date_known' => false, + ]); + } catch (ValidationException $e) { + return back() + ->withInput() + ->withErrors($e->validator); + } // Did the user press "Save" or "Submit and add another person" if (! is_null($request->get('save'))) { diff --git a/app/Models/Account/ImportJob.php b/app/Models/Account/ImportJob.php index 41a835feb..964282c0f 100644 --- a/app/Models/Account/ImportJob.php +++ b/app/Models/Account/ImportJob.php @@ -8,7 +8,7 @@ use Sabre\VObject\Component\VCard; use App\Services\VCard\ImportVCard; use Illuminate\Database\Eloquent\Model; use Illuminate\Support\Facades\Storage; -use App\Exceptions\MissingParameterException; +use Illuminate\Validation\ValidationException; use Illuminate\Database\Eloquent\Relations\HasMany; use Illuminate\Database\Eloquent\Relations\BelongsTo; use Illuminate\Contracts\Filesystem\FileNotFoundException; @@ -211,7 +211,7 @@ class ImportJob extends Model 'entry' => $entry, 'behaviour' => $behaviour, ]); - } catch (MissingParameterException $e) { + } catch (ValidationException $e) { $this->fail((string) $e); return; diff --git a/app/Services/BaseService.php b/app/Services/BaseService.php index c159201eb..57461e2cf 100644 --- a/app/Services/BaseService.php +++ b/app/Services/BaseService.php @@ -4,7 +4,6 @@ namespace App\Services; use Carbon\Carbon; use Illuminate\Support\Facades\Validator; -use App\Exceptions\MissingParameterException; abstract class BaseService { @@ -26,11 +25,8 @@ abstract class BaseService */ public function validate(array $data) : bool { - $validator = Validator::make($data, $this->rules()); - - if ($validator->fails()) { - throw new MissingParameterException('Missing parameters', $validator->errors()->all()); - } + Validator::make($data, $this->rules()) + ->validate(); return true; } diff --git a/app/Services/Instance/Weather/GetWeatherInformation.php b/app/Services/Instance/Weather/GetWeatherInformation.php index 27ecfbd19..1f2e88736 100644 --- a/app/Services/Instance/Weather/GetWeatherInformation.php +++ b/app/Services/Instance/Weather/GetWeatherInformation.php @@ -30,7 +30,7 @@ class GetWeatherInformation extends BaseService * * @param array $data * @return Weather|null - * @throws App\Exceptions\MissingParameterException if the array that is given in parameter is not valid + * @throws Illuminate\Validation\ValidationException if the array that is given in parameter is not valid * @throws App\Exceptions\MissingEnvVariableException if the weather services are not enabled * @throws Illuminate\Database\Eloquent\ModelNotFoundException if the Place object is not found * @throws GuzzleHttp\Exception\ClientException if the request to Darksky crashed diff --git a/app/Traits/JsonRespondController.php b/app/Traits/JsonRespondController.php index 066293937..4c474095f 100644 --- a/app/Traits/JsonRespondController.php +++ b/app/Traits/JsonRespondController.php @@ -76,21 +76,9 @@ trait JsonRespondController return response()->json($data, $this->getHTTPStatusCode(), $headers); } - /** - * Sends a response unauthorized (401) to the request. - * - * @param string $message - * @return JsonResponse - */ - public function respondUnauthorized($message = null) - { - return $this->setHTTPStatusCode(401) - ->setErrorCode(42) - ->respondWithError($message); - } - /** * Sends a response not found (404) to the request. + * Error Code = 31. * * @param string $message * @return JsonResponse @@ -103,21 +91,23 @@ trait JsonRespondController } /** - * Sends a response invalid query (http 500) to the request. + * Sends an error when the validator failed. + * Error Code = 32. * - * @param string $message + * @param Validator $validator * @return JsonResponse */ - public function respondInvalidQuery($message = null) + public function respondValidatorFailed(Validator $validator) { - return $this->setHTTPStatusCode(500) - ->setErrorCode(40) - ->respondWithError($message); + return $this->setHTTPStatusCode(422) + ->setErrorCode(32) + ->respondWithError($validator->errors()->all()); } /** * Sends an error when the query didn't have the right parameters for * creating an object. + * Error Code = 33. * * @param string $message * @return JsonResponse @@ -129,30 +119,46 @@ trait JsonRespondController ->respondWithError($message); } + /** + * Sends a response invalid query (http 500) to the request. + * Error Code = 40. + * + * @param string $message + * @return JsonResponse + */ + public function respondInvalidQuery($message = null) + { + return $this->setHTTPStatusCode(500) + ->setErrorCode(40) + ->respondWithError($message); + } + /** * Sends an error when the query contains invalid parameters. + * Error Code = 41. * * @param string $message * @return JsonResponse */ public function respondInvalidParameters($message = null) { - return $this->setHTTPStatusCode(400) + return $this->setHTTPStatusCode(422) ->setErrorCode(41) ->respondWithError($message); } /** - * Sends an error when the validator failed. + * Sends a response unauthorized (401) to the request. + * Error Code = 42. * - * @param Validator $validator + * @param string $message * @return JsonResponse */ - public function respondValidatorFailed(Validator $validator) + public function respondUnauthorized($message = null) { - return $this->setHTTPStatusCode(400) - ->setErrorCode(32) - ->respondWithError($validator->errors()->all()); + return $this->setHTTPStatusCode(401) + ->setErrorCode(42) + ->respondWithError($message); } /** diff --git a/config/logging.php b/config/logging.php index 59b00dedd..2b3f6e4d7 100644 --- a/config/logging.php +++ b/config/logging.php @@ -78,7 +78,7 @@ return [ ], 'testing' => [ 'driver' => 'errorlog', - 'level' => 'info', + 'level' => 'emergency', ], ], ]; diff --git a/tests/Api/Account/ApiCompanyControllerTest.php b/tests/Api/Account/ApiCompanyControllerTest.php index 6eec01dfe..ee6d15e33 100644 --- a/tests/Api/Account/ApiCompanyControllerTest.php +++ b/tests/Api/Account/ApiCompanyControllerTest.php @@ -200,7 +200,7 @@ class ApiCompanyControllerTest extends ApiTestCase $response = $this->json('delete', '/api/companies/0'); - $this->expectInvalidParameter($response, [ + $this->expectDataError($response, [ 'The selected company id is invalid.', ]); } diff --git a/tests/Api/Account/ApiGenderControllerTest.php b/tests/Api/Account/ApiGenderControllerTest.php index 736aacd4f..d598dfa97 100644 --- a/tests/Api/Account/ApiGenderControllerTest.php +++ b/tests/Api/Account/ApiGenderControllerTest.php @@ -195,7 +195,7 @@ class ApiGenderControllerTest extends ApiTestCase $response = $this->json('delete', '/api/genders/0'); - $this->expectInvalidParameter($response, [ + $this->expectDataError($response, [ 'The selected gender id is invalid.', ]); } diff --git a/tests/Api/Account/ApiPlaceControllerTest.php b/tests/Api/Account/ApiPlaceControllerTest.php index 7b78b2453..4e2063573 100644 --- a/tests/Api/Account/ApiPlaceControllerTest.php +++ b/tests/Api/Account/ApiPlaceControllerTest.php @@ -203,7 +203,7 @@ class ApiPlaceControllerTest extends ApiTestCase $response = $this->json('delete', '/api/places/0'); - $this->expectInvalidParameter($response, [ + $this->expectDataError($response, [ 'The selected place id is invalid.', ]); } diff --git a/tests/Api/Activity/ApiActivityTypeCategoryControllerTest.php b/tests/Api/Activity/ApiActivityTypeCategoryControllerTest.php index 5b738897a..3184e6916 100644 --- a/tests/Api/Activity/ApiActivityTypeCategoryControllerTest.php +++ b/tests/Api/Activity/ApiActivityTypeCategoryControllerTest.php @@ -89,13 +89,10 @@ class ApiActivityTypeCategoryControllerTest extends ApiTestCase { $user = $this->signin(); - $response = $this->json('POST', '/api/activitytypecategories', []); + $response = $this->json('POST', '/api/activitytypecategories'); - $response->assertStatus(400); - - $response->assertJsonFragment([ - 'message' => ['The name field is required.'], - 'error_code' => 32, + $this->expectDataError($response, [ + 'The name field is required.', ]); } @@ -150,11 +147,8 @@ class ApiActivityTypeCategoryControllerTest extends ApiTestCase $response = $this->json('PUT', '/api/activitytypecategories/'.$activityTypeCategory->id, [ ]); - $response->assertStatus(400); - - $response->assertJsonFragment([ - 'message' => ['The name field is required.'], - 'error_code' => 32, + $this->expectDataError($response, [ + 'The name field is required.', ]); } diff --git a/tests/Api/Activity/ApiActivityTypeControllerTest.php b/tests/Api/Activity/ApiActivityTypeControllerTest.php index 7b4aa8084..5eea49656 100644 --- a/tests/Api/Activity/ApiActivityTypeControllerTest.php +++ b/tests/Api/Activity/ApiActivityTypeControllerTest.php @@ -107,17 +107,11 @@ class ApiActivityTypeControllerTest extends ApiTestCase { $user = $this->signin(); - $response = $this->json('POST', '/api/activitytypes', [ - ]); + $response = $this->json('POST', '/api/activitytypes'); - $response->assertStatus(400); - - $response->assertJsonFragment([ - 'message' => [ - 'The activity type category id field is required.', - 'The name field is required.', - ], - 'error_code' => 32, + $this->expectDataError($response, [ + 'The name field is required.', + 'The activity type category id field is required.', ]); } @@ -179,11 +173,8 @@ class ApiActivityTypeControllerTest extends ApiTestCase 'activity_type_category_id' => 3, ]); - $response->assertStatus(400); - - $response->assertJsonFragment([ - 'message' => ['The name field is required.'], - 'error_code' => 32, + $this->expectDataError($response, [ + 'The name field is required.', ]); } diff --git a/tests/Api/ApiTaskControllerTest.php b/tests/Api/ApiTaskControllerTest.php index 9b07b4587..b2b02f66e 100644 --- a/tests/Api/ApiTaskControllerTest.php +++ b/tests/Api/ApiTaskControllerTest.php @@ -225,7 +225,7 @@ class ApiTaskControllerTest extends ApiTestCase 'contact_id' => $contact->id, ]); - $this->expectInvalidParameter($response, [ + $this->expectDataError($response, [ 'The title field is required.', ]); } @@ -297,7 +297,7 @@ class ApiTaskControllerTest extends ApiTestCase 'contact_id' => $task->contact_id, ]); - $this->expectInvalidParameter($response, [ + $this->expectDataError($response, [ 'The title field is required.', 'The completed field is required.', ]); diff --git a/tests/Api/Contact/ApiAdressesControllerTest.php b/tests/Api/Contact/ApiAdressesControllerTest.php index a11b33bed..f522d3c35 100644 --- a/tests/Api/Contact/ApiAdressesControllerTest.php +++ b/tests/Api/Contact/ApiAdressesControllerTest.php @@ -194,7 +194,7 @@ class ApiAdressesControllerTest extends ApiTestCase $response = $this->json('POST', '/api/addresses', [ ]); - $this->expectInvalidParameter($response, [ + $this->expectDataError($response, [ 'The contact id field is required.', ]); } @@ -268,7 +268,7 @@ class ApiAdressesControllerTest extends ApiTestCase $response = $this->json('PUT', '/api/addresses/'.$address->id, []); - $this->expectInvalidParameter($response, [ + $this->expectDataError($response, [ 'The contact id field is required.', ]); } @@ -320,7 +320,7 @@ class ApiAdressesControllerTest extends ApiTestCase $response = $this->json('DELETE', '/api/addresses/0'); - $this->expectInvalidParameter($response, [ + $this->expectDataError($response, [ 'The selected address id is invalid.', ]); } diff --git a/tests/Api/Contact/ApiCallControllerTest.php b/tests/Api/Contact/ApiCallControllerTest.php index 3ae810aec..4b0e93660 100644 --- a/tests/Api/Contact/ApiCallControllerTest.php +++ b/tests/Api/Contact/ApiCallControllerTest.php @@ -188,7 +188,7 @@ class ApiCallControllerTest extends ApiTestCase 'contact_id' => $contact->id, ]); - $this->expectInvalidParameter($response, [ + $this->expectDataError($response, [ 'The called at field is required.', ]); } @@ -260,7 +260,7 @@ class ApiCallControllerTest extends ApiTestCase 'contact_id' => $call->contact_id, ]); - $this->expectInvalidParameter($response, [ + $this->expectDataError($response, [ 'The called at field is required.', ]); } diff --git a/tests/Api/Contact/ApiContactControllerTest.php b/tests/Api/Contact/ApiContactControllerTest.php index aada35881..b63e61f01 100644 --- a/tests/Api/Contact/ApiContactControllerTest.php +++ b/tests/Api/Contact/ApiContactControllerTest.php @@ -731,7 +731,7 @@ class ApiContactControllerTest extends ApiTestCase 'last_name' => 'Doe', ]); - $this->expectInvalidParameter($response, [ + $this->expectDataError($response, [ 'The gender id field is required.', 'The is birthdate known field is required.', 'The is deceased field is required.', @@ -1112,7 +1112,7 @@ class ApiContactControllerTest extends ApiTestCase 'last_name' => 'Doe', ]); - $this->expectInvalidParameter($response, [ + $this->expectDataError($response, [ 'The gender id field is required.', 'The is birthdate known field is required.', 'The is deceased date known field is required.', diff --git a/tests/Api/Contact/ApiLifeEventControllerTest.php b/tests/Api/Contact/ApiLifeEventControllerTest.php index 329f54103..39b156f79 100644 --- a/tests/Api/Contact/ApiLifeEventControllerTest.php +++ b/tests/Api/Contact/ApiLifeEventControllerTest.php @@ -220,7 +220,7 @@ class ApiLifeEventControllerTest extends ApiTestCase 'note' => 'This is a text', ]); - $this->expectInvalidParameter($response, [ + $this->expectDataError($response, [ 'The happened at field is required.', 'The has reminder field is required.', 'The happened at month unknown field is required.', @@ -294,7 +294,7 @@ class ApiLifeEventControllerTest extends ApiTestCase 'note' => 'This is a text', ]); - $this->expectInvalidParameter($response, [ + $this->expectDataError($response, [ 'The happened at field is required.', ]); } diff --git a/tests/Api/Contact/ApiOccupationControllerTest.php b/tests/Api/Contact/ApiOccupationControllerTest.php index 1c2914592..3e19589ec 100644 --- a/tests/Api/Contact/ApiOccupationControllerTest.php +++ b/tests/Api/Contact/ApiOccupationControllerTest.php @@ -221,7 +221,7 @@ class ApiOccupationControllerTest extends ApiTestCase $response = $this->json('delete', '/api/occupations/0'); - $this->expectInvalidParameter($response, [ + $this->expectDataError($response, [ 'The selected occupation id is invalid.', ]); } diff --git a/tests/Api/ContactField/ApiContactFieldControllerTest.php b/tests/Api/ContactField/ApiContactFieldControllerTest.php index 2bd6f53c7..1a41748e9 100644 --- a/tests/Api/ContactField/ApiContactFieldControllerTest.php +++ b/tests/Api/ContactField/ApiContactFieldControllerTest.php @@ -1,6 +1,6 @@ assertStatus(400); + $response->assertStatus(422); $response->assertJson([ 'error' => [ @@ -45,14 +45,14 @@ class ApiTestCase extends TestCase } /** - * Test that the response contains a not found notification. + * Test that the response contains an invalid parameter notification. * * @param TestResponse $response * @param string|array $message */ public function expectInvalidParameter(TestResponse $response, $message = '') { - $response->assertStatus(400); + $response->assertStatus(422); $response->assertJson([ 'error' => [ diff --git a/tests/Feature/InstanceTest.php b/tests/Feature/InstanceTest.php index a7528209d..5c39d695d 100644 --- a/tests/Feature/InstanceTest.php +++ b/tests/Feature/InstanceTest.php @@ -3,6 +3,7 @@ namespace Tests\Feature; use Tests\TestCase; +use App\Models\Account\Account; use Illuminate\Foundation\Testing\DatabaseTransactions; class InstanceTest extends TestCase @@ -18,6 +19,7 @@ class InstanceTest extends TestCase public function test_disable_signup_set_to_false_shows_signup_button() { config(['monica.disable_signup' => false]); + factory(Account::class)->create(); $response = $this->get('/'); @@ -36,6 +38,7 @@ class InstanceTest extends TestCase public function test_disable_signup_set_to_true_hides_signup_button_and_register_page() { config(['monica.disable_signup' => true]); + factory(Account::class)->create(); $response = $this->get('/'); $response->assertDontSee( diff --git a/tests/Unit/Services/Account/Company/CreateCompanyTest.php b/tests/Unit/Services/Account/Company/CreateCompanyTest.php index 43d9cf9aa..934aae2f8 100644 --- a/tests/Unit/Services/Account/Company/CreateCompanyTest.php +++ b/tests/Unit/Services/Account/Company/CreateCompanyTest.php @@ -5,7 +5,7 @@ namespace Tests\Unit\Services\Account\Place; use Tests\TestCase; use App\Models\Account\Account; use App\Models\Account\Company; -use App\Exceptions\MissingParameterException; +use Illuminate\Validation\ValidationException; use App\Services\Account\Company\CreateCompany; use Illuminate\Foundation\Testing\DatabaseTransactions; @@ -49,7 +49,7 @@ class CreateCompanyTest extends TestCase 'street' => '199 Lafayette Street', ]; - $this->expectException(MissingParameterException::class); + $this->expectException(ValidationException::class); (new CreateCompany)->execute($request); } } diff --git a/tests/Unit/Services/Account/Company/DestroyCompanyTest.php b/tests/Unit/Services/Account/Company/DestroyCompanyTest.php index 03a02cb43..4879b5cf2 100644 --- a/tests/Unit/Services/Account/Company/DestroyCompanyTest.php +++ b/tests/Unit/Services/Account/Company/DestroyCompanyTest.php @@ -5,7 +5,7 @@ namespace Tests\Unit\Services\Account\Company; use Tests\TestCase; use App\Models\Account\Account; use App\Models\Account\Company; -use App\Exceptions\MissingParameterException; +use Illuminate\Validation\ValidationException; use App\Services\Account\Company\DestroyCompany; use Illuminate\Foundation\Testing\DatabaseTransactions; use Illuminate\Database\Eloquent\ModelNotFoundException; @@ -52,7 +52,7 @@ class DestroyCompanyTest extends TestCase 'company_id' => 11111111, ]; - $this->expectException(MissingParameterException::class); + $this->expectException(ValidationException::class); (new DestroyCompany)->execute($request); } } diff --git a/tests/Unit/Services/Account/Company/UpdateCompanyTest.php b/tests/Unit/Services/Account/Company/UpdateCompanyTest.php index 5d62d269b..671e1b59c 100644 --- a/tests/Unit/Services/Account/Company/UpdateCompanyTest.php +++ b/tests/Unit/Services/Account/Company/UpdateCompanyTest.php @@ -5,7 +5,7 @@ namespace Tests\Unit\Services\Account\Place; use Tests\TestCase; use App\Models\Account\Account; use App\Models\Account\Company; -use App\Exceptions\MissingParameterException; +use Illuminate\Validation\ValidationException; use App\Services\Account\Company\UpdateCompany; use Illuminate\Foundation\Testing\DatabaseTransactions; use Illuminate\Database\Eloquent\ModelNotFoundException; @@ -51,7 +51,7 @@ class UpdateCompanyTest extends TestCase 'name' => '199 Lafayette Street', ]; - $this->expectException(MissingParameterException::class); + $this->expectException(ValidationException::class); (new UpdateCompany)->execute($request); } diff --git a/tests/Unit/Services/Account/DestroyAllDocumentsTest.php b/tests/Unit/Services/Account/DestroyAllDocumentsTest.php index 4f565ef03..7c3e3f244 100644 --- a/tests/Unit/Services/Account/DestroyAllDocumentsTest.php +++ b/tests/Unit/Services/Account/DestroyAllDocumentsTest.php @@ -7,8 +7,8 @@ use App\Models\Contact\Contact; use App\Models\Contact\Document; use Illuminate\Http\UploadedFile; use Illuminate\Support\Facades\Storage; -use App\Exceptions\MissingParameterException; use App\Services\Account\DestroyAllDocuments; +use Illuminate\Validation\ValidationException; use App\Services\Contact\Document\UploadDocument; use Illuminate\Foundation\Testing\DatabaseTransactions; @@ -43,7 +43,7 @@ class DestroyAllDocumentsTest extends TestCase $request = [ ]; - $this->expectException(MissingParameterException::class); + $this->expectException(ValidationException::class); $destroyAllDocumentsService = new DestroyAllDocuments; $result = $destroyAllDocumentsService->execute($request); diff --git a/tests/Unit/Services/Account/Gender/CreateGenderTest.php b/tests/Unit/Services/Account/Gender/CreateGenderTest.php index f82a7b6a9..96b27c727 100644 --- a/tests/Unit/Services/Account/Gender/CreateGenderTest.php +++ b/tests/Unit/Services/Account/Gender/CreateGenderTest.php @@ -5,8 +5,8 @@ namespace Tests\Unit\Services\Account\Gender; use Tests\TestCase; use App\Models\Contact\Gender; use App\Models\Account\Account; -use App\Exceptions\MissingParameterException; use App\Services\Account\Gender\CreateGender; +use Illuminate\Validation\ValidationException; use Illuminate\Foundation\Testing\DatabaseTransactions; class CreateGenderTest extends TestCase @@ -45,7 +45,7 @@ class CreateGenderTest extends TestCase 'name' => 'man', ]; - $this->expectException(MissingParameterException::class); + $this->expectException(ValidationException::class); (new CreateGender)->execute($request); } } diff --git a/tests/Unit/Services/Account/Gender/DestroyGenderTest.php b/tests/Unit/Services/Account/Gender/DestroyGenderTest.php index 73f54f253..0e9c10ea9 100644 --- a/tests/Unit/Services/Account/Gender/DestroyGenderTest.php +++ b/tests/Unit/Services/Account/Gender/DestroyGenderTest.php @@ -5,8 +5,8 @@ namespace Tests\Unit\Services\Account\gender; use Tests\TestCase; use App\Models\Contact\Gender; use App\Models\Account\Account; -use App\Exceptions\MissingParameterException; use App\Services\Account\Gender\DestroyGender; +use Illuminate\Validation\ValidationException; use Illuminate\Foundation\Testing\DatabaseTransactions; use Illuminate\Database\Eloquent\ModelNotFoundException; @@ -52,7 +52,7 @@ class DestroyGenderTest extends TestCase 'gender_id' => 11111111, ]; - $this->expectException(MissingParameterException::class); + $this->expectException(ValidationException::class); (new DestroyGender)->execute($request); } } diff --git a/tests/Unit/Services/Account/Gender/UpdateGenderTest.php b/tests/Unit/Services/Account/Gender/UpdateGenderTest.php index db29a791a..e0a14ddf4 100644 --- a/tests/Unit/Services/Account/Gender/UpdateGenderTest.php +++ b/tests/Unit/Services/Account/Gender/UpdateGenderTest.php @@ -5,8 +5,8 @@ namespace Tests\Unit\Services\Account\Gender; use Tests\TestCase; use App\Models\Contact\Gender; use App\Models\Account\Account; -use App\Exceptions\MissingParameterException; use App\Services\Account\Gender\UpdateGender; +use Illuminate\Validation\ValidationException; use Illuminate\Foundation\Testing\DatabaseTransactions; use Illuminate\Database\Eloquent\ModelNotFoundException; @@ -47,7 +47,7 @@ class UpdateGenderTest extends TestCase 'name' => 'man', ]; - $this->expectException(MissingParameterException::class); + $this->expectException(ValidationException::class); (new UpdateGender)->execute($request); } diff --git a/tests/Unit/Services/Account/Photo/DestroyPhotoTest.php b/tests/Unit/Services/Account/Photo/DestroyPhotoTest.php index 7cb2acc29..6f31bf21c 100644 --- a/tests/Unit/Services/Account/Photo/DestroyPhotoTest.php +++ b/tests/Unit/Services/Account/Photo/DestroyPhotoTest.php @@ -9,7 +9,7 @@ use Illuminate\Http\UploadedFile; use Illuminate\Support\Facades\Storage; use App\Services\Account\Photo\UploadPhoto; use App\Services\Account\Photo\DestroyPhoto; -use App\Exceptions\MissingParameterException; +use Illuminate\Validation\ValidationException; use Illuminate\Foundation\Testing\DatabaseTransactions; use Illuminate\Database\Eloquent\ModelNotFoundException; @@ -47,7 +47,7 @@ class DestroyPhotoTest extends TestCase 'photo_id' => 2, ]; - $this->expectException(MissingParameterException::class); + $this->expectException(ValidationException::class); $destroyPhotoService = new DestroyPhoto; $result = $destroyPhotoService->execute($request); diff --git a/tests/Unit/Services/Account/Photo/UploadPhotoTest.php b/tests/Unit/Services/Account/Photo/UploadPhotoTest.php index 1394c24e1..7f502aaaf 100644 --- a/tests/Unit/Services/Account/Photo/UploadPhotoTest.php +++ b/tests/Unit/Services/Account/Photo/UploadPhotoTest.php @@ -9,7 +9,7 @@ use App\Models\Contact\Document; use Illuminate\Http\UploadedFile; use Illuminate\Support\Facades\Storage; use App\Services\Account\Photo\UploadPhoto; -use App\Exceptions\MissingParameterException; +use Illuminate\Validation\ValidationException; use Illuminate\Foundation\Testing\DatabaseTransactions; class UploadPhotoTest extends TestCase @@ -50,7 +50,7 @@ class UploadPhotoTest extends TestCase 'account_id' => 1, ]; - $this->expectException(MissingParameterException::class); + $this->expectException(ValidationException::class); $uploadService = new UploadPhoto; $photo = $uploadService->execute($request); @@ -65,7 +65,7 @@ class UploadPhotoTest extends TestCase 'photo' => UploadedFile::fake()->image('document.pdf'), ]; - $this->expectException(MissingParameterException::class); + $this->expectException(ValidationException::class); $uploadService = (new UploadPhoto)->execute($request); } diff --git a/tests/Unit/Services/Account/Place/CreatePlaceTest.php b/tests/Unit/Services/Account/Place/CreatePlaceTest.php index ebb19550e..ab4d67483 100644 --- a/tests/Unit/Services/Account/Place/CreatePlaceTest.php +++ b/tests/Unit/Services/Account/Place/CreatePlaceTest.php @@ -6,7 +6,7 @@ use Tests\TestCase; use App\Models\Account\Place; use App\Models\Account\Account; use App\Services\Account\Place\CreatePlace; -use App\Exceptions\MissingParameterException; +use Illuminate\Validation\ValidationException; use Illuminate\Foundation\Testing\DatabaseTransactions; class CreatePlaceTest extends TestCase @@ -90,7 +90,7 @@ class CreatePlaceTest extends TestCase 'street' => '199 Lafayette Street', ]; - $this->expectException(MissingParameterException::class); + $this->expectException(ValidationException::class); (new CreatePlace)->execute($request); } } diff --git a/tests/Unit/Services/Account/Place/DestroyPlaceTest.php b/tests/Unit/Services/Account/Place/DestroyPlaceTest.php index dbb64d44b..bb287e931 100644 --- a/tests/Unit/Services/Account/Place/DestroyPlaceTest.php +++ b/tests/Unit/Services/Account/Place/DestroyPlaceTest.php @@ -6,7 +6,7 @@ use Tests\TestCase; use App\Models\Account\Place; use App\Models\Account\Account; use App\Services\Account\Place\DestroyPlace; -use App\Exceptions\MissingParameterException; +use Illuminate\Validation\ValidationException; use Illuminate\Foundation\Testing\DatabaseTransactions; use Illuminate\Database\Eloquent\ModelNotFoundException; @@ -52,7 +52,7 @@ class DestroyPlaceTest extends TestCase 'place_id' => 11111111, ]; - $this->expectException(MissingParameterException::class); + $this->expectException(ValidationException::class); (new DestroyPlace)->execute($request); } } diff --git a/tests/Unit/Services/Account/Place/UpdatePlaceTest.php b/tests/Unit/Services/Account/Place/UpdatePlaceTest.php index 9c951ddfe..750cbf234 100644 --- a/tests/Unit/Services/Account/Place/UpdatePlaceTest.php +++ b/tests/Unit/Services/Account/Place/UpdatePlaceTest.php @@ -6,7 +6,7 @@ use Tests\TestCase; use App\Models\Account\Place; use App\Models\Account\Account; use App\Services\Account\Place\UpdatePlace; -use App\Exceptions\MissingParameterException; +use Illuminate\Validation\ValidationException; use Illuminate\Foundation\Testing\DatabaseTransactions; use Illuminate\Database\Eloquent\ModelNotFoundException; @@ -93,7 +93,7 @@ class UpdatePlaceTest extends TestCase 'street' => '199 Lafayette Street', ]; - $this->expectException(MissingParameterException::class); + $this->expectException(ValidationException::class); (new UpdatePlace)->execute($request); } diff --git a/tests/Unit/Services/Auth/PopulateContactFieldTypesTableTest.php b/tests/Unit/Services/Auth/PopulateContactFieldTypesTableTest.php index f9dc838f0..0c3a8a5b8 100644 --- a/tests/Unit/Services/Auth/PopulateContactFieldTypesTableTest.php +++ b/tests/Unit/Services/Auth/PopulateContactFieldTypesTableTest.php @@ -6,7 +6,7 @@ use Tests\TestCase; use App\Models\User\User; use App\Models\Account\Account; use Illuminate\Support\Facades\DB; -use App\Exceptions\MissingParameterException; +use Illuminate\Validation\ValidationException; use Illuminate\Foundation\Testing\DatabaseTransactions; use App\Services\Auth\Population\PopulateContactFieldTypesTable; @@ -27,7 +27,7 @@ class PopulateContactFieldTypesTableTest extends TestCase 'migrate_existing_data' => false, ]; - $this->expectException(MissingParameterException::class); + $this->expectException(ValidationException::class); (new PopulateContactFieldTypesTable)->execute($request); } diff --git a/tests/Unit/Services/Auth/PopulateLifeEventsTableTest.php b/tests/Unit/Services/Auth/PopulateLifeEventsTableTest.php index 3d3a29dd5..68d894ca5 100644 --- a/tests/Unit/Services/Auth/PopulateLifeEventsTableTest.php +++ b/tests/Unit/Services/Auth/PopulateLifeEventsTableTest.php @@ -6,7 +6,7 @@ use Tests\TestCase; use App\Models\User\User; use App\Models\Account\Account; use Illuminate\Support\Facades\DB; -use App\Exceptions\MissingParameterException; +use Illuminate\Validation\ValidationException; use Illuminate\Foundation\Testing\DatabaseTransactions; use App\Services\Auth\Population\PopulateLifeEventsTable; @@ -29,7 +29,7 @@ class PopulateLifeEventsTableTest extends TestCase 'migrate_existing_data' => false, ]; - $this->expectException(MissingParameterException::class); + $this->expectException(ValidationException::class); $populateLifeEventService = new PopulateLifeEventsTable; $populateLifeEventService->execute($request); diff --git a/tests/Unit/Services/Auth/PopulateModulesTableTest.php b/tests/Unit/Services/Auth/PopulateModulesTableTest.php index ffa2184ae..3f1a1a068 100644 --- a/tests/Unit/Services/Auth/PopulateModulesTableTest.php +++ b/tests/Unit/Services/Auth/PopulateModulesTableTest.php @@ -6,7 +6,7 @@ use Tests\TestCase; use App\Models\User\User; use App\Models\Account\Account; use Illuminate\Support\Facades\DB; -use App\Exceptions\MissingParameterException; +use Illuminate\Validation\ValidationException; use App\Services\Auth\Population\PopulateModulesTable; use Illuminate\Foundation\Testing\DatabaseTransactions; @@ -29,7 +29,7 @@ class PopulateModulesTableTest extends TestCase 'migrate_existing_data' => false, ]; - $this->expectException(MissingParameterException::class); + $this->expectException(ValidationException::class); $populateModulesService = new PopulateModulesTable; $populateModulesService->execute($request); diff --git a/tests/Unit/Services/Contact/Address/CreateAddressTest.php b/tests/Unit/Services/Contact/Address/CreateAddressTest.php index 127bac1d9..176067632 100644 --- a/tests/Unit/Services/Contact/Address/CreateAddressTest.php +++ b/tests/Unit/Services/Contact/Address/CreateAddressTest.php @@ -6,7 +6,7 @@ use Tests\TestCase; use App\Models\Account\Account; use App\Models\Contact\Address; use App\Models\Contact\Contact; -use App\Exceptions\MissingParameterException; +use Illuminate\Validation\ValidationException; use App\Services\Contact\Address\CreateAddress; use Illuminate\Foundation\Testing\DatabaseTransactions; use Illuminate\Database\Eloquent\ModelNotFoundException; @@ -60,7 +60,7 @@ class CreateAddressTest extends TestCase 'name' => '199 Lafayette Street', ]; - $this->expectException(MissingParameterException::class); + $this->expectException(ValidationException::class); (new CreateAddress)->execute($request); } diff --git a/tests/Unit/Services/Contact/Address/DestroyAddressTest.php b/tests/Unit/Services/Contact/Address/DestroyAddressTest.php index 6b2491029..3b4d4de5a 100644 --- a/tests/Unit/Services/Contact/Address/DestroyAddressTest.php +++ b/tests/Unit/Services/Contact/Address/DestroyAddressTest.php @@ -5,7 +5,7 @@ namespace Tests\Unit\Services\Contact\Address; use Tests\TestCase; use App\Models\Contact\Address; use App\Models\Contact\Contact; -use App\Exceptions\MissingParameterException; +use Illuminate\Validation\ValidationException; use App\Services\Contact\Address\DestroyAddress; use Illuminate\Foundation\Testing\DatabaseTransactions; use Illuminate\Database\Eloquent\ModelNotFoundException; @@ -51,7 +51,7 @@ class DestroyAddressTest extends TestCase 'address_id' => 11111111, ]; - $this->expectException(MissingParameterException::class); + $this->expectException(ValidationException::class); (new DestroyAddress)->execute($request); } } diff --git a/tests/Unit/Services/Contact/Address/UpdateAddressTest.php b/tests/Unit/Services/Contact/Address/UpdateAddressTest.php index 0faf229bd..8f3e089a9 100644 --- a/tests/Unit/Services/Contact/Address/UpdateAddressTest.php +++ b/tests/Unit/Services/Contact/Address/UpdateAddressTest.php @@ -6,7 +6,7 @@ use Tests\TestCase; use App\Models\Account\Account; use App\Models\Contact\Address; use App\Models\Contact\Contact; -use App\Exceptions\MissingParameterException; +use Illuminate\Validation\ValidationException; use App\Services\Contact\Address\UpdateAddress; use Illuminate\Foundation\Testing\DatabaseTransactions; use Illuminate\Database\Eloquent\ModelNotFoundException; @@ -61,7 +61,7 @@ class UpdateAddressTest extends TestCase 'street' => '199 Lafayette Street', ]; - $this->expectException(MissingParameterException::class); + $this->expectException(ValidationException::class); (new UpdateAddress)->execute($request); } diff --git a/tests/Unit/Services/Contact/Call/CreateCallTest.php b/tests/Unit/Services/Contact/Call/CreateCallTest.php index ebb05abfb..d2b804d48 100644 --- a/tests/Unit/Services/Contact/Call/CreateCallTest.php +++ b/tests/Unit/Services/Contact/Call/CreateCallTest.php @@ -9,7 +9,7 @@ use App\Models\Account\Account; use App\Models\Contact\Contact; use App\Models\Instance\Emotion\Emotion; use App\Services\Contact\Call\CreateCall; -use App\Exceptions\MissingParameterException; +use Illuminate\Validation\ValidationException; use Illuminate\Foundation\Testing\DatabaseTransactions; use Illuminate\Database\Eloquent\ModelNotFoundException; @@ -211,7 +211,7 @@ class CreateCallTest extends TestCase 'called_at' => Carbon::now(), ]; - $this->expectException(MissingParameterException::class); + $this->expectException(ValidationException::class); (new CreateCall)->execute($request); } diff --git a/tests/Unit/Services/Contact/Call/UpdateCallTest.php b/tests/Unit/Services/Contact/Call/UpdateCallTest.php index 0c5d7b3d4..3e026d2ef 100644 --- a/tests/Unit/Services/Contact/Call/UpdateCallTest.php +++ b/tests/Unit/Services/Contact/Call/UpdateCallTest.php @@ -10,7 +10,7 @@ use App\Models\Contact\Contact; use Illuminate\Support\Facades\DB; use App\Models\Instance\Emotion\Emotion; use App\Services\Contact\Call\UpdateCall; -use App\Exceptions\MissingParameterException; +use Illuminate\Validation\ValidationException; use Illuminate\Foundation\Testing\DatabaseTransactions; use Illuminate\Database\Eloquent\ModelNotFoundException; @@ -289,7 +289,7 @@ class UpdateCallTest extends TestCase 'called_at' => Carbon::now(), ]; - $this->expectException(MissingParameterException::class); + $this->expectException(ValidationException::class); $createConversation = new UpdateCall; $call = $createConversation->execute($request); diff --git a/tests/Unit/Services/Contact/Contact/CreateContactTest.php b/tests/Unit/Services/Contact/Contact/CreateContactTest.php index f72638e2b..d617ae45b 100644 --- a/tests/Unit/Services/Contact/Contact/CreateContactTest.php +++ b/tests/Unit/Services/Contact/Contact/CreateContactTest.php @@ -6,7 +6,7 @@ use Tests\TestCase; use App\Models\Contact\Gender; use App\Models\Account\Account; use App\Models\Contact\Contact; -use App\Exceptions\MissingParameterException; +use Illuminate\Validation\ValidationException; use App\Services\Contact\Contact\CreateContact; use Illuminate\Foundation\Testing\DatabaseTransactions; @@ -68,7 +68,7 @@ class CreateContactTest extends TestCase 'is_deceased_date_known' => false, ]; - $this->expectException(MissingParameterException::class); + $this->expectException(ValidationException::class); (new CreateContact)->execute($request); } @@ -88,7 +88,7 @@ class CreateContactTest extends TestCase 'is_deceased_date_known' => false, ]; - $this->expectException(MissingParameterException::class); + $this->expectException(ValidationException::class); (new CreateContact)->execute($request); } diff --git a/tests/Unit/Services/Contact/Contact/DestroyContactTest.php b/tests/Unit/Services/Contact/Contact/DestroyContactTest.php index f4f4e64d8..fb72f6f14 100644 --- a/tests/Unit/Services/Contact/Contact/DestroyContactTest.php +++ b/tests/Unit/Services/Contact/Contact/DestroyContactTest.php @@ -5,7 +5,7 @@ namespace Tests\Unit\Services\Contact\Contact; use Tests\TestCase; use App\Models\Account\Account; use App\Models\Contact\Contact; -use App\Exceptions\MissingParameterException; +use Illuminate\Validation\ValidationException; use App\Services\Contact\Contact\DestroyContact; use Illuminate\Foundation\Testing\DatabaseTransactions; use Illuminate\Database\Eloquent\ModelNotFoundException; @@ -39,7 +39,7 @@ class DestroyContactTest extends TestCase 'account_id' => $contact->account_id, ]; - $this->expectException(MissingParameterException::class); + $this->expectException(ValidationException::class); (new DestroyContact)->execute($request); } diff --git a/tests/Unit/Services/Contact/Contact/UpdateBirthdayInformationTest.php b/tests/Unit/Services/Contact/Contact/UpdateBirthdayInformationTest.php index 5f3f7dcfa..d3d75e3ac 100644 --- a/tests/Unit/Services/Contact/Contact/UpdateBirthdayInformationTest.php +++ b/tests/Unit/Services/Contact/Contact/UpdateBirthdayInformationTest.php @@ -5,7 +5,7 @@ namespace Tests\Unit\Services\Contact\Contact; use Tests\TestCase; use App\Models\Contact\Contact; use App\Models\Instance\SpecialDate; -use App\Exceptions\MissingParameterException; +use Illuminate\Validation\ValidationException; use Illuminate\Foundation\Testing\DatabaseTransactions; use App\Services\Contact\Contact\UpdateBirthdayInformation; @@ -167,7 +167,7 @@ class UpdateBirthdayInformationTest extends TestCase 'add_reminder' => false, ]; - $this->expectException(MissingParameterException::class); + $this->expectException(ValidationException::class); $updateContact = new UpdateBirthdayInformation; $updateContact->execute($request); @@ -188,7 +188,7 @@ class UpdateBirthdayInformationTest extends TestCase 'add_reminder' => false, ]; - $this->expectException(MissingParameterException::class); + $this->expectException(ValidationException::class); (new UpdateBirthdayInformation)->execute($request); } diff --git a/tests/Unit/Services/Contact/Contact/UpdateContactTest.php b/tests/Unit/Services/Contact/Contact/UpdateContactTest.php index 0e01284b9..3fff1052c 100644 --- a/tests/Unit/Services/Contact/Contact/UpdateContactTest.php +++ b/tests/Unit/Services/Contact/Contact/UpdateContactTest.php @@ -4,7 +4,7 @@ namespace Tests\Unit\Services\Contact\Contact; use Tests\TestCase; use App\Models\Contact\Contact; -use App\Exceptions\MissingParameterException; +use Illuminate\Validation\ValidationException; use App\Services\Contact\Contact\UpdateContact; use Illuminate\Foundation\Testing\DatabaseTransactions; @@ -82,7 +82,7 @@ class UpdateContactTest extends TestCase 'deceased_date_add_reminder' => true, ]; - $this->expectException(MissingParameterException::class); + $this->expectException(ValidationException::class); (new UpdateContact)->execute($request); } @@ -114,7 +114,7 @@ class UpdateContactTest extends TestCase 'deceased_date_add_reminder' => true, ]; - $this->expectException(MissingParameterException::class); + $this->expectException(ValidationException::class); (new UpdateContact)->execute($request); } } diff --git a/tests/Unit/Services/Contact/Contact/UpdateDeceasedInformationTest.php b/tests/Unit/Services/Contact/Contact/UpdateDeceasedInformationTest.php index 477ae4737..74d1b551f 100644 --- a/tests/Unit/Services/Contact/Contact/UpdateDeceasedInformationTest.php +++ b/tests/Unit/Services/Contact/Contact/UpdateDeceasedInformationTest.php @@ -5,7 +5,7 @@ namespace Tests\Unit\Services\Contact\Contact; use Tests\TestCase; use App\Models\Contact\Contact; use App\Models\Instance\SpecialDate; -use App\Exceptions\MissingParameterException; +use Illuminate\Validation\ValidationException; use Illuminate\Foundation\Testing\DatabaseTransactions; use App\Services\Contact\Contact\UpdateDeceasedInformation; @@ -161,7 +161,7 @@ class UpdateDeceasedInformationTest extends TestCase 'add_reminder' => false, ]; - $this->expectException(MissingParameterException::class); + $this->expectException(ValidationException::class); $deceasedService = new UpdateDeceasedInformation; $contact = $deceasedService->execute($request); @@ -182,7 +182,7 @@ class UpdateDeceasedInformationTest extends TestCase 'add_reminder' => false, ]; - $this->expectException(MissingParameterException::class); + $this->expectException(ValidationException::class); (new UpdateDeceasedInformation)->execute($request); } diff --git a/tests/Unit/Services/Contact/Conversation/AddMessageToConversationTest.php b/tests/Unit/Services/Contact/Conversation/AddMessageToConversationTest.php index 9acd8cf7e..88a0c14ee 100644 --- a/tests/Unit/Services/Contact/Conversation/AddMessageToConversationTest.php +++ b/tests/Unit/Services/Contact/Conversation/AddMessageToConversationTest.php @@ -8,7 +8,7 @@ use App\Models\Account\Account; use App\Models\Contact\Contact; use App\Models\Contact\Message; use App\Models\Contact\Conversation; -use App\Exceptions\MissingParameterException; +use Illuminate\Validation\ValidationException; use Illuminate\Foundation\Testing\DatabaseTransactions; use Illuminate\Database\Eloquent\ModelNotFoundException; use App\Services\Contact\Conversation\AddMessageToConversation; @@ -24,7 +24,7 @@ class AddMessageToConversationTest extends TestCase 'happened_at' => Carbon::now(), ]; - $this->expectException(MissingParameterException::class); + $this->expectException(ValidationException::class); $addMessageToConversation = new AddMessageToConversation; $conversation = $addMessageToConversation->execute($request); diff --git a/tests/Unit/Services/Contact/Conversation/CreateConversationTest.php b/tests/Unit/Services/Contact/Conversation/CreateConversationTest.php index 129f2ec3e..4a4d3cbba 100644 --- a/tests/Unit/Services/Contact/Conversation/CreateConversationTest.php +++ b/tests/Unit/Services/Contact/Conversation/CreateConversationTest.php @@ -8,7 +8,7 @@ use App\Models\Account\Account; use App\Models\Contact\Contact; use App\Models\Contact\Conversation; use App\Models\Contact\ContactFieldType; -use App\Exceptions\MissingParameterException; +use Illuminate\Validation\ValidationException; use Illuminate\Foundation\Testing\DatabaseTransactions; use Illuminate\Database\Eloquent\ModelNotFoundException; use App\Services\Contact\Conversation\CreateConversation; @@ -56,7 +56,7 @@ class CreateConversationTest extends TestCase 'happened_at' => Carbon::now(), ]; - $this->expectException(MissingParameterException::class); + $this->expectException(ValidationException::class); $createConversation = new CreateConversation; $conversation = $createConversation->execute($request); diff --git a/tests/Unit/Services/Contact/Conversation/DestroyConversationTest.php b/tests/Unit/Services/Contact/Conversation/DestroyConversationTest.php index ba323fe67..ddf1de3e0 100644 --- a/tests/Unit/Services/Contact/Conversation/DestroyConversationTest.php +++ b/tests/Unit/Services/Contact/Conversation/DestroyConversationTest.php @@ -6,7 +6,7 @@ use Tests\TestCase; use App\Models\Account\Account; use App\Models\Contact\Message; use App\Models\Contact\Conversation; -use App\Exceptions\MissingParameterException; +use Illuminate\Validation\ValidationException; use Illuminate\Foundation\Testing\DatabaseTransactions; use Illuminate\Database\Eloquent\ModelNotFoundException; use App\Services\Contact\Conversation\DestroyConversation; @@ -79,7 +79,7 @@ class DestroyConversationTest extends TestCase 'account_id' => $conversation->account->id, ]; - $this->expectException(MissingParameterException::class); + $this->expectException(ValidationException::class); $conversationService = (new DestroyConversation)->execute($request); } diff --git a/tests/Unit/Services/Contact/Conversation/DestroyMessageTest.php b/tests/Unit/Services/Contact/Conversation/DestroyMessageTest.php index baeb01355..dcccf1520 100644 --- a/tests/Unit/Services/Contact/Conversation/DestroyMessageTest.php +++ b/tests/Unit/Services/Contact/Conversation/DestroyMessageTest.php @@ -5,7 +5,7 @@ namespace Tests\Unit\Services\Contact\Conversation; use Tests\TestCase; use App\Models\Contact\Message; use App\Models\Contact\Conversation; -use App\Exceptions\MissingParameterException; +use Illuminate\Validation\ValidationException; use App\Services\Contact\Conversation\DestroyMessage; use Illuminate\Foundation\Testing\DatabaseTransactions; use Illuminate\Database\Eloquent\ModelNotFoundException; @@ -52,7 +52,7 @@ class DestroyMessageTest extends TestCase 'message_id' => 3, ]; - $this->expectException(MissingParameterException::class); + $this->expectException(ValidationException::class); $destroyMessage = new DestroyMessage; $result = $destroyMessage->execute($request); diff --git a/tests/Unit/Services/Contact/Conversation/UpdateConversationTest.php b/tests/Unit/Services/Contact/Conversation/UpdateConversationTest.php index eb7f57d79..74c65ad14 100644 --- a/tests/Unit/Services/Contact/Conversation/UpdateConversationTest.php +++ b/tests/Unit/Services/Contact/Conversation/UpdateConversationTest.php @@ -8,7 +8,7 @@ use App\Models\Account\Account; use App\Models\Contact\Contact; use App\Models\Contact\Conversation; use App\Models\Contact\ContactFieldType; -use App\Exceptions\MissingParameterException; +use Illuminate\Validation\ValidationException; use Illuminate\Foundation\Testing\DatabaseTransactions; use Illuminate\Database\Eloquent\ModelNotFoundException; use App\Services\Contact\Conversation\UpdateConversation; @@ -57,7 +57,7 @@ class UpdateConversationTest extends TestCase 'happened_at' => Carbon::now(), ]; - $this->expectException(MissingParameterException::class); + $this->expectException(ValidationException::class); $updateConversation = new UpdateConversation; $conversation = $updateConversation->execute($request); diff --git a/tests/Unit/Services/Contact/Conversation/UpdateMessageTest.php b/tests/Unit/Services/Contact/Conversation/UpdateMessageTest.php index 18542b2e9..5b69206c2 100644 --- a/tests/Unit/Services/Contact/Conversation/UpdateMessageTest.php +++ b/tests/Unit/Services/Contact/Conversation/UpdateMessageTest.php @@ -7,7 +7,7 @@ use Tests\TestCase; use App\Models\Account\Account; use App\Models\Contact\Message; use App\Models\Contact\Conversation; -use App\Exceptions\MissingParameterException; +use Illuminate\Validation\ValidationException; use App\Services\Contact\Conversation\UpdateMessage; use Illuminate\Foundation\Testing\DatabaseTransactions; use Illuminate\Database\Eloquent\ModelNotFoundException; @@ -68,7 +68,7 @@ class UpdateMessageTest extends TestCase 'content' => 'lorem', ]; - $this->expectException(MissingParameterException::class); + $this->expectException(ValidationException::class); $updateMessage = (new UpdateMessage)->execute($request); } diff --git a/tests/Unit/Services/Contact/Document/DestroyDocumentTest.php b/tests/Unit/Services/Contact/Document/DestroyDocumentTest.php index 95ff2bacc..6fead19de 100644 --- a/tests/Unit/Services/Contact/Document/DestroyDocumentTest.php +++ b/tests/Unit/Services/Contact/Document/DestroyDocumentTest.php @@ -7,7 +7,7 @@ use App\Models\Contact\Contact; use App\Models\Contact\Document; use Illuminate\Http\UploadedFile; use Illuminate\Support\Facades\Storage; -use App\Exceptions\MissingParameterException; +use Illuminate\Validation\ValidationException; use App\Services\Contact\Document\UploadDocument; use App\Services\Contact\Document\DestroyDocument; use Illuminate\Foundation\Testing\DatabaseTransactions; @@ -47,7 +47,7 @@ class DestroyDocumentTest extends TestCase 'document_id' => 2, ]; - $this->expectException(MissingParameterException::class); + $this->expectException(ValidationException::class); $destroyDocumentService = new DestroyDocument; $result = $destroyDocumentService->execute($request); diff --git a/tests/Unit/Services/Contact/Document/UploadDocumentTest.php b/tests/Unit/Services/Contact/Document/UploadDocumentTest.php index 314daa791..1b0d3b4c0 100644 --- a/tests/Unit/Services/Contact/Document/UploadDocumentTest.php +++ b/tests/Unit/Services/Contact/Document/UploadDocumentTest.php @@ -8,7 +8,7 @@ use App\Models\Contact\Contact; use App\Models\Contact\Document; use Illuminate\Http\UploadedFile; use Illuminate\Support\Facades\Storage; -use App\Exceptions\MissingParameterException; +use Illuminate\Validation\ValidationException; use App\Services\Contact\Document\UploadDocument; use Illuminate\Foundation\Testing\DatabaseTransactions; use Illuminate\Database\Eloquent\ModelNotFoundException; @@ -54,7 +54,7 @@ class UploadDocumentTest extends TestCase 'contact_id' => 2, ]; - $this->expectException(MissingParameterException::class); + $this->expectException(ValidationException::class); $uploadService = new UploadDocument; $document = $uploadService->execute($request); diff --git a/tests/Unit/Services/Contact/LifeEvent/AddReminderToLifeEventTest.php b/tests/Unit/Services/Contact/LifeEvent/AddReminderToLifeEventTest.php index 893bd7ce8..eb3e43787 100644 --- a/tests/Unit/Services/Contact/LifeEvent/AddReminderToLifeEventTest.php +++ b/tests/Unit/Services/Contact/LifeEvent/AddReminderToLifeEventTest.php @@ -5,7 +5,7 @@ namespace Tests\Unit\Services\Contact\LifeEvent; use Tests\TestCase; use App\Models\Contact\Reminder; use App\Models\Contact\LifeEvent; -use App\Exceptions\MissingParameterException; +use Illuminate\Validation\ValidationException; use Illuminate\Foundation\Testing\DatabaseTransactions; use Illuminate\Database\Eloquent\ModelNotFoundException; use App\Services\Contact\LifeEvent\AddReminderToLifeEvent; @@ -51,7 +51,7 @@ class AddReminderToLifeEventTest extends TestCase 'frequency_number' => 1, ]; - $this->expectException(MissingParameterException::class); + $this->expectException(ValidationException::class); $reminderService = new AddReminderToLifeEvent; $reminder = $reminderService->execute($request); diff --git a/tests/Unit/Services/Contact/LifeEvent/CreateLifeEventTest.php b/tests/Unit/Services/Contact/LifeEvent/CreateLifeEventTest.php index 6b933efd8..e932d86d8 100644 --- a/tests/Unit/Services/Contact/LifeEvent/CreateLifeEventTest.php +++ b/tests/Unit/Services/Contact/LifeEvent/CreateLifeEventTest.php @@ -8,7 +8,7 @@ use App\Models\Account\Account; use App\Models\Contact\Contact; use App\Models\Contact\LifeEvent; use App\Models\Contact\LifeEventType; -use App\Exceptions\MissingParameterException; +use Illuminate\Validation\ValidationException; use App\Services\Contact\LifeEvent\CreateLifeEvent; use Illuminate\Foundation\Testing\DatabaseTransactions; use Illuminate\Database\Eloquent\ModelNotFoundException; @@ -95,7 +95,7 @@ class CreateLifeEventTest extends TestCase 'happened_at' => Carbon::now(), ]; - $this->expectException(MissingParameterException::class); + $this->expectException(ValidationException::class); $createLifeEvent = new CreateLifeEvent; $lifeEvent = $createLifeEvent->execute($request); diff --git a/tests/Unit/Services/Contact/LifeEvent/DestroyLifeEventTest.php b/tests/Unit/Services/Contact/LifeEvent/DestroyLifeEventTest.php index 2c8f2d1c9..2f2dde1d6 100644 --- a/tests/Unit/Services/Contact/LifeEvent/DestroyLifeEventTest.php +++ b/tests/Unit/Services/Contact/LifeEvent/DestroyLifeEventTest.php @@ -6,7 +6,7 @@ use Tests\TestCase; use App\Models\Account\Account; use App\Models\Contact\Reminder; use App\Models\Contact\LifeEvent; -use App\Exceptions\MissingParameterException; +use Illuminate\Validation\ValidationException; use App\Services\Contact\LifeEvent\DestroyLifeEvent; use Illuminate\Foundation\Testing\DatabaseTransactions; use Illuminate\Database\Eloquent\ModelNotFoundException; @@ -64,7 +64,7 @@ class DestroyLifeEventTest extends TestCase 'account_id' => 1, ]; - $this->expectException(MissingParameterException::class); + $this->expectException(ValidationException::class); $destroyMessage = (new DestroyLifeEvent)->execute($request); } diff --git a/tests/Unit/Services/Contact/LifeEvent/UpdateLifeEventTest.php b/tests/Unit/Services/Contact/LifeEvent/UpdateLifeEventTest.php index 8cd28f2e7..9a4e65070 100644 --- a/tests/Unit/Services/Contact/LifeEvent/UpdateLifeEventTest.php +++ b/tests/Unit/Services/Contact/LifeEvent/UpdateLifeEventTest.php @@ -8,7 +8,7 @@ use App\Models\Account\Account; use App\Models\Contact\Contact; use App\Models\Contact\LifeEvent; use App\Models\Contact\LifeEventType; -use App\Exceptions\MissingParameterException; +use Illuminate\Validation\ValidationException; use App\Services\Contact\LifeEvent\UpdateLifeEvent; use Illuminate\Foundation\Testing\DatabaseTransactions; use Illuminate\Database\Eloquent\ModelNotFoundException; @@ -63,7 +63,7 @@ class UpdateLifeEventTest extends TestCase 'happened_at' => Carbon::now(), ]; - $this->expectException(MissingParameterException::class); + $this->expectException(ValidationException::class); $updateConversation = (new UpdateLifeEvent)->execute($request); } diff --git a/tests/Unit/Services/Contact/Occupation/CreateOccupationTest.php b/tests/Unit/Services/Contact/Occupation/CreateOccupationTest.php index 9fc4cf05d..036840736 100644 --- a/tests/Unit/Services/Contact/Occupation/CreateOccupationTest.php +++ b/tests/Unit/Services/Contact/Occupation/CreateOccupationTest.php @@ -7,7 +7,7 @@ use App\Models\Account\Account; use App\Models\Account\Company; use App\Models\Contact\Contact; use App\Models\Contact\Occupation; -use App\Exceptions\MissingParameterException; +use Illuminate\Validation\ValidationException; use App\Services\Contact\Occupation\CreateOccupation; use Illuminate\Foundation\Testing\DatabaseTransactions; @@ -56,7 +56,7 @@ class CreateOccupationTest extends TestCase 'street' => '199 Lafayette Street', ]; - $this->expectException(MissingParameterException::class); + $this->expectException(ValidationException::class); (new CreateOccupation)->execute($request); } } diff --git a/tests/Unit/Services/Contact/Occupation/UpdateOccupationTest.php b/tests/Unit/Services/Contact/Occupation/UpdateOccupationTest.php index e34bb2c81..8f82c92b3 100644 --- a/tests/Unit/Services/Contact/Occupation/UpdateOccupationTest.php +++ b/tests/Unit/Services/Contact/Occupation/UpdateOccupationTest.php @@ -5,7 +5,7 @@ namespace Tests\Unit\Services\Account\Place; use Tests\TestCase; use App\Models\Account\Account; use App\Models\Contact\Occupation; -use App\Exceptions\MissingParameterException; +use Illuminate\Validation\ValidationException; use App\Services\Contact\Occupation\UpdateOccupation; use Illuminate\Foundation\Testing\DatabaseTransactions; use Illuminate\Database\Eloquent\ModelNotFoundException; @@ -54,7 +54,7 @@ class UpdateOccupationTest extends TestCase 'name' => '199 Lafayette Street', ]; - $this->expectException(MissingParameterException::class); + $this->expectException(ValidationException::class); (new UpdateOccupation)->execute($request); } diff --git a/tests/Unit/Services/Contact/Relationship/DestroyRelationshipTest.php b/tests/Unit/Services/Contact/Relationship/DestroyRelationshipTest.php index 2a1342686..92b557db0 100644 --- a/tests/Unit/Services/Contact/Relationship/DestroyRelationshipTest.php +++ b/tests/Unit/Services/Contact/Relationship/DestroyRelationshipTest.php @@ -6,7 +6,7 @@ use Tests\TestCase; use App\Models\Account\Account; use App\Models\Contact\Contact; use App\Models\Relationship\Relationship; -use App\Exceptions\MissingParameterException; +use Illuminate\Validation\ValidationException; use Illuminate\Foundation\Testing\DatabaseTransactions; use Illuminate\Database\Eloquent\ModelNotFoundException; use App\Services\Contact\Relationship\DestroyRelationship; @@ -49,7 +49,7 @@ class DestroyRelationshipTest extends TestCase 'account_id' => $account->id, ]; - $this->expectException(MissingParameterException::class); + $this->expectException(ValidationException::class); (new DestroyRelationship)->execute($request); } diff --git a/tests/Unit/Services/Contact/Reminder/CreateReminderTest.php b/tests/Unit/Services/Contact/Reminder/CreateReminderTest.php index 64362772d..9e4a2c1d0 100644 --- a/tests/Unit/Services/Contact/Reminder/CreateReminderTest.php +++ b/tests/Unit/Services/Contact/Reminder/CreateReminderTest.php @@ -8,7 +8,7 @@ use App\Models\Account\Account; use App\Models\Contact\Contact; use App\Models\Contact\Reminder; use App\Models\Instance\SpecialDate; -use App\Exceptions\MissingParameterException; +use Illuminate\Validation\ValidationException; use App\Services\Contact\Reminder\CreateReminder; use Illuminate\Foundation\Testing\DatabaseTransactions; use Illuminate\Database\Eloquent\ModelNotFoundException; @@ -88,7 +88,7 @@ class CreateReminderTest extends TestCase 'date' => Carbon::now(), ]; - $this->expectException(MissingParameterException::class); + $this->expectException(ValidationException::class); $reminderService = (new CreateReminder)->execute($request); } @@ -144,12 +144,12 @@ class CreateReminderTest extends TestCase 'special_date_id' => null, ]; - $this->expectException(MissingParameterException::class); + $this->expectException(ValidationException::class); try { $reminderService = (new CreateReminder)->execute($request); - } catch (MissingParameterException $e) { - $this->assertEquals(['The selected frequency type is invalid.'], $e->errors); + } catch (ValidationException $e) { + $this->assertEquals(['The selected frequency type is invalid.'], $e->validator->errors()->all()); throw $e; } } diff --git a/tests/Unit/Services/Contact/Tag/AssociateTagTest.php b/tests/Unit/Services/Contact/Tag/AssociateTagTest.php index 24cafd3f8..fc418fa23 100644 --- a/tests/Unit/Services/Contact/Tag/AssociateTagTest.php +++ b/tests/Unit/Services/Contact/Tag/AssociateTagTest.php @@ -7,7 +7,7 @@ use App\Models\Contact\Tag; use App\Models\Account\Account; use App\Models\Contact\Contact; use App\Services\Contact\Tag\AssociateTag; -use App\Exceptions\MissingParameterException; +use Illuminate\Validation\ValidationException; use Illuminate\Foundation\Testing\DatabaseTransactions; use Illuminate\Database\Eloquent\ModelNotFoundException; @@ -99,7 +99,7 @@ class AssociateTagTest extends TestCase 'contact_id' => 2, ]; - $this->expectException(MissingParameterException::class); + $this->expectException(ValidationException::class); $associateTagService = new AssociateTag; $tag = $associateTagService->execute($request); diff --git a/tests/Unit/Services/Contact/Tag/CreateTagTest.php b/tests/Unit/Services/Contact/Tag/CreateTagTest.php index 23f49f8de..190cf9b05 100644 --- a/tests/Unit/Services/Contact/Tag/CreateTagTest.php +++ b/tests/Unit/Services/Contact/Tag/CreateTagTest.php @@ -5,7 +5,7 @@ namespace Tests\Unit\Services\Contact\Conversation; use Tests\TestCase; use App\Models\Contact\Tag; use App\Services\Contact\Tag\CreateTag; -use App\Exceptions\MissingParameterException; +use Illuminate\Validation\ValidationException; use Illuminate\Foundation\Testing\DatabaseTransactions; class CreateTagTest extends TestCase @@ -43,7 +43,7 @@ class CreateTagTest extends TestCase 'tag_id' => 2, ]; - $this->expectException(MissingParameterException::class); + $this->expectException(ValidationException::class); $createTagService = new CreateTag; $tag = $createTagService->execute($request); diff --git a/tests/Unit/Services/Contact/Tag/DestroyTagTest.php b/tests/Unit/Services/Contact/Tag/DestroyTagTest.php index 97fadd7db..1a9080428 100644 --- a/tests/Unit/Services/Contact/Tag/DestroyTagTest.php +++ b/tests/Unit/Services/Contact/Tag/DestroyTagTest.php @@ -7,7 +7,7 @@ use App\Models\Contact\Tag; use App\Models\Account\Account; use App\Models\Contact\Contact; use App\Services\Contact\Tag\DestroyTag; -use App\Exceptions\MissingParameterException; +use Illuminate\Validation\ValidationException; use Illuminate\Foundation\Testing\DatabaseTransactions; use Illuminate\Database\Eloquent\ModelNotFoundException; @@ -61,7 +61,7 @@ class DestroyTagTest extends TestCase 'account_id' => 1, ]; - $this->expectException(MissingParameterException::class); + $this->expectException(ValidationException::class); $destroyTagService = new DestroyTag; $tag = $destroyTagService->execute($request); diff --git a/tests/Unit/Services/Contact/Tag/DetachTagTest.php b/tests/Unit/Services/Contact/Tag/DetachTagTest.php index aad25292f..6fc551d43 100644 --- a/tests/Unit/Services/Contact/Tag/DetachTagTest.php +++ b/tests/Unit/Services/Contact/Tag/DetachTagTest.php @@ -7,7 +7,7 @@ use App\Models\Contact\Tag; use App\Models\Account\Account; use App\Models\Contact\Contact; use App\Services\Contact\Tag\DetachTag; -use App\Exceptions\MissingParameterException; +use Illuminate\Validation\ValidationException; use Illuminate\Foundation\Testing\DatabaseTransactions; use Illuminate\Database\Eloquent\ModelNotFoundException; @@ -56,7 +56,7 @@ class DetachTagTest extends TestCase 'account_id' => 1, ]; - $this->expectException(MissingParameterException::class); + $this->expectException(ValidationException::class); $detachTagService = new DetachTag; $detachTagService->execute($request); diff --git a/tests/Unit/Services/Contact/Tag/UpdateTagTest.php b/tests/Unit/Services/Contact/Tag/UpdateTagTest.php index 5b202c8a9..149b80619 100644 --- a/tests/Unit/Services/Contact/Tag/UpdateTagTest.php +++ b/tests/Unit/Services/Contact/Tag/UpdateTagTest.php @@ -6,7 +6,7 @@ use Tests\TestCase; use App\Models\Contact\Tag; use App\Models\Account\Account; use App\Services\Contact\Tag\UpdateTag; -use App\Exceptions\MissingParameterException; +use Illuminate\Validation\ValidationException; use Illuminate\Foundation\Testing\DatabaseTransactions; use Illuminate\Database\Eloquent\ModelNotFoundException; @@ -46,7 +46,7 @@ class UpdateTagTest extends TestCase 'tag_id' => 2, ]; - $this->expectException(MissingParameterException::class); + $this->expectException(ValidationException::class); $updateTagService = new UpdateTag; $tag = $updateTagService->execute($request); diff --git a/tests/Unit/Services/Instance/Geolocalization/GetGPSCoordinateTest.php b/tests/Unit/Services/Instance/Geolocalization/GetGPSCoordinateTest.php index 38674bdb8..6851c2714 100644 --- a/tests/Unit/Services/Instance/Geolocalization/GetGPSCoordinateTest.php +++ b/tests/Unit/Services/Instance/Geolocalization/GetGPSCoordinateTest.php @@ -4,7 +4,7 @@ namespace Tests\Unit\Services\Instance\Geolocalization; use Tests\TestCase; use App\Models\Account\Place; -use App\Exceptions\MissingParameterException; +use Illuminate\Validation\ValidationException; use Illuminate\Foundation\Testing\DatabaseTransactions; use App\Services\Instance\Geolocalization\GetGPSCoordinate; @@ -99,7 +99,7 @@ class GetGPSCoordinateTest extends TestCase 'account_id' => 111, ]; - $this->expectException(MissingParameterException::class); + $this->expectException(ValidationException::class); $geocodingService = new GetGPSCoordinate; $place = $geocodingService->execute($request); diff --git a/tests/Unit/Services/Instance/Weather/GetWeatherInformationTest.php b/tests/Unit/Services/Instance/Weather/GetWeatherInformationTest.php index 651b06751..f00351098 100644 --- a/tests/Unit/Services/Instance/Weather/GetWeatherInformationTest.php +++ b/tests/Unit/Services/Instance/Weather/GetWeatherInformationTest.php @@ -5,7 +5,7 @@ namespace Tests\Unit\Services\Instance\Weather; use Tests\TestCase; use App\Models\Account\Place; use App\Models\Account\Weather; -use App\Exceptions\MissingParameterException; +use Illuminate\Validation\ValidationException; use App\Exceptions\MissingEnvVariableException; use Illuminate\Foundation\Testing\DatabaseTransactions; use App\Services\Instance\Weather\GetWeatherInformation; @@ -112,7 +112,7 @@ class GetWeatherInformationTest extends TestCase $request = []; - $this->expectException(MissingParameterException::class); + $this->expectException(ValidationException::class); (new GetWeatherInformation)->execute($request); } } diff --git a/tests/Unit/Services/Task/CreateTaskTest.php b/tests/Unit/Services/Task/CreateTaskTest.php index 95102127c..53292fcc2 100644 --- a/tests/Unit/Services/Task/CreateTaskTest.php +++ b/tests/Unit/Services/Task/CreateTaskTest.php @@ -7,7 +7,7 @@ use App\Models\Contact\Task; use App\Models\Account\Account; use App\Models\Contact\Contact; use App\Services\Task\CreateTask; -use App\Exceptions\MissingParameterException; +use Illuminate\Validation\ValidationException; use Illuminate\Foundation\Testing\DatabaseTransactions; use Illuminate\Database\Eloquent\ModelNotFoundException; @@ -103,7 +103,7 @@ class CreateTaskTest extends TestCase 'account_id' => $contact->account->id, ]; - $this->expectException(MissingParameterException::class); + $this->expectException(ValidationException::class); $createTask = new CreateTask; $task = $createTask->execute($request); diff --git a/tests/Unit/Services/Task/DestroyTaskTest.php b/tests/Unit/Services/Task/DestroyTaskTest.php index 1588aa844..5a940d831 100644 --- a/tests/Unit/Services/Task/DestroyTaskTest.php +++ b/tests/Unit/Services/Task/DestroyTaskTest.php @@ -6,7 +6,7 @@ use Tests\TestCase; use App\Models\Contact\Task; use App\Models\Account\Account; use App\Services\Task\DestroyTask; -use App\Exceptions\MissingParameterException; +use Illuminate\Validation\ValidationException; use Illuminate\Foundation\Testing\DatabaseTransactions; use Illuminate\Database\Eloquent\ModelNotFoundException; @@ -41,7 +41,7 @@ class DestroyTaskTest extends TestCase 'task_id' => 2, ]; - $this->expectException(MissingParameterException::class); + $this->expectException(ValidationException::class); $destroyTaskService = new DestroyTask; $result = $destroyTaskService->execute($request); diff --git a/tests/Unit/Services/Task/UpdateTaskTest.php b/tests/Unit/Services/Task/UpdateTaskTest.php index daa69c8bd..7f5c3bc40 100644 --- a/tests/Unit/Services/Task/UpdateTaskTest.php +++ b/tests/Unit/Services/Task/UpdateTaskTest.php @@ -7,7 +7,7 @@ use App\Models\Contact\Task; use App\Models\Account\Account; use App\Models\Contact\Contact; use App\Services\Task\UpdateTask; -use App\Exceptions\MissingParameterException; +use Illuminate\Validation\ValidationException; use Illuminate\Foundation\Testing\DatabaseTransactions; use Illuminate\Database\Eloquent\ModelNotFoundException; @@ -87,7 +87,7 @@ class UpdateTaskTest extends TestCase 'description' => 'description', ]; - $this->expectException(MissingParameterException::class); + $this->expectException(ValidationException::class); $updateTask = new UpdateTask; $task = $updateTask->execute($request); diff --git a/tests/Unit/Services/User/EmailChangeTest.php b/tests/Unit/Services/User/EmailChangeTest.php index 9e76f7a3c..82c966012 100644 --- a/tests/Unit/Services/User/EmailChangeTest.php +++ b/tests/Unit/Services/User/EmailChangeTest.php @@ -7,7 +7,7 @@ use App\Models\User\User; use App\Models\Account\Account; use App\Services\User\EmailChange; use App\Notifications\ConfirmEmail; -use App\Exceptions\MissingParameterException; +use Illuminate\Validation\ValidationException; use Illuminate\Foundation\Testing\DatabaseTransactions; use Illuminate\Database\Eloquent\ModelNotFoundException; use Illuminate\Support\Facades\Notification as NotificationFacade; @@ -55,7 +55,7 @@ class EmailChangeTest extends TestCase 'email' => 'email@email.com', ]; - $this->expectException(MissingParameterException::class); + $this->expectException(ValidationException::class); $emailChangeService = new EmailChange; $user = $emailChangeService->execute($request);