diff --git a/app/Exceptions/Handler.php b/app/Exceptions/Handler.php index cfebc70..e4b94d2 100644 --- a/app/Exceptions/Handler.php +++ b/app/Exceptions/Handler.php @@ -155,7 +155,7 @@ class Handler extends ExceptionHandler // @codeCoverageIgnoreStart if (config('app.env') === 'testing') { // phpcs:ignore Squiz.PHP.DiscouragedFunctions.Found - print_r((string)$e); + print_r((string) $e); } return $this->getReponse($request, 500, \intval($e->getCode()), $e->getMessage()); // @codeCoverageIgnoreEnd @@ -181,12 +181,12 @@ class Handler extends ExceptionHandler if (Helper::isRequestForApiV2($request)) { return (new V2ApiResponse( ApiStatus::KO, - (object)array_merge($data, ['message' => $message, 'code' => $apiCode]), + (object) array_merge($data, ['message' => $message, 'code' => $apiCode]), ))->toResponse($request)->setStatusCode($httpCode); } return (new V4ApiResponse( ApiStatus::KO, - (object)array_merge($data, ['message' => $message, 'code' => $apiCode]), + (object) array_merge($data, ['message' => $message, 'code' => $apiCode]), ))->toResponse($request)->setStatusCode($httpCode); } } diff --git a/app/Http/Controllers/Api/V2/CustomerController.php b/app/Http/Controllers/Api/V2/CustomerController.php index c6ba58e..e5a3e7e 100644 --- a/app/Http/Controllers/Api/V2/CustomerController.php +++ b/app/Http/Controllers/Api/V2/CustomerController.php @@ -34,7 +34,7 @@ class CustomerController extends Controller */ public function store(StoreCustomerRequest $request, Service $service): JsonResource { - $data = (object)$request->validated(); + $data = (object) $request->validated(); /** @var \App\Models\Customer */ $customer = Customer::query()->where('email', $data->email)->firstOrCreate([ diff --git a/app/Http/Controllers/Api/V4/CustomerController.php b/app/Http/Controllers/Api/V4/CustomerController.php index c58ec24..4b2f1e3 100644 --- a/app/Http/Controllers/Api/V4/CustomerController.php +++ b/app/Http/Controllers/Api/V4/CustomerController.php @@ -34,7 +34,7 @@ class CustomerController extends Controller */ public function store(StoreCustomerRequest $request, Service $service): JsonResource { - $data = (object)$request->validated(); + $data = (object) $request->validated(); /** @var \App\Models\Customer */ $customer = Customer::query()->where('email', $data->email)->firstOrCreate([ diff --git a/app/Http/Controllers/Bo/BrandController.php b/app/Http/Controllers/Bo/BrandController.php index fc666af..f55343b 100644 --- a/app/Http/Controllers/Bo/BrandController.php +++ b/app/Http/Controllers/Bo/BrandController.php @@ -148,7 +148,7 @@ class BrandController extends Controller $models = CollectionHelper::paginateManually( Brand::getUserAssociatedBrands(), $this->jsonItemPerPagination, - (int)$request->validated('page'), + (int) $request->validated('page'), ); return \response()->json($models); } diff --git a/app/Http/Controllers/Bo/StatsController.php b/app/Http/Controllers/Bo/StatsController.php index b7b7afc..7cd7a46 100644 --- a/app/Http/Controllers/Bo/StatsController.php +++ b/app/Http/Controllers/Bo/StatsController.php @@ -70,7 +70,7 @@ class StatsController extends Controller } $w->insertOne($cols); } - return response((string)$w, 200, [ + return response((string) $w, 200, [ 'Content-Encoding' => 'none', 'Content-Type' => 'text/csv; charset=UTF-8', // phpcs:ignore Generic.Files.LineLength.TooLong @@ -135,7 +135,7 @@ class StatsController extends Controller $dayAnswers->values()->all() )); } - return response((string)$w, 200, [ + return response((string) $w, 200, [ 'Content-Encoding' => 'none', 'Content-Type' => 'text/csv; charset=UTF-8', // phpcs:ignore Generic.Files.LineLength.TooLong diff --git a/app/Http/Middleware/ApiResponse.php b/app/Http/Middleware/ApiResponse.php index 568bdd8..6e8398b 100644 --- a/app/Http/Middleware/ApiResponse.php +++ b/app/Http/Middleware/ApiResponse.php @@ -57,8 +57,8 @@ class ApiResponse $status = intval($response->getStatusCode() / 100) == 2 ? ApiStatus::OK : ApiStatus::KO; if (Helper::isRequestForApiV2($request)) { - return $response->setData(new V2ApiResponse($status, (object)$data)); + return $response->setData(new V2ApiResponse($status, (object) $data)); } - return $response->setData(new V4ApiResponse($status, (object)$data)); + return $response->setData(new V4ApiResponse($status, (object) $data)); } } diff --git a/app/Http/Requests/Bo/UpdateMiniCrudRequest.php b/app/Http/Requests/Bo/UpdateMiniCrudRequest.php index f845c96..d483c90 100644 --- a/app/Http/Requests/Bo/UpdateMiniCrudRequest.php +++ b/app/Http/Requests/Bo/UpdateMiniCrudRequest.php @@ -100,11 +100,11 @@ abstract class UpdateMiniCrudRequest extends FormRequest }) : $input['dimensions']; // * Adapt dimensions - $sizes = (object)[ + $sizes = (object) [ 'minHeight' => $dim['height'], 'maxHeight' => $dim['height'], - 'minWith' => $dim['width'], - 'maxWith' => $dim['width'], + 'minWith' => $dim['width'], + 'maxWith' => $dim['width'], ]; $rules = array_merge($rules, [ "data.$iptName.value" => [ diff --git a/app/Http/Resources/Api/V2/ApiResponse.php b/app/Http/Resources/Api/V2/ApiResponse.php index 5209420..a84880e 100644 --- a/app/Http/Resources/Api/V2/ApiResponse.php +++ b/app/Http/Resources/Api/V2/ApiResponse.php @@ -37,7 +37,7 @@ class ApiResponse extends JsonResource //phpcs:enable return [ 'status' => $this->status->value(), - 'data' => (array)($this->data ?? []), + 'data' => (array) ($this->data ?? []), 'version' => '3.0.6' ]; } diff --git a/app/Http/Resources/Api/V4/ApiResponse.php b/app/Http/Resources/Api/V4/ApiResponse.php index 1c1ca23..80b2dc2 100644 --- a/app/Http/Resources/Api/V4/ApiResponse.php +++ b/app/Http/Resources/Api/V4/ApiResponse.php @@ -37,7 +37,7 @@ class ApiResponse extends JsonResource //phpcs:enable return [ 'status' => $this->status->value(), - 'data' => (array)($this->data ?? []), + 'data' => (array) ($this->data ?? []), 'version' => config('api.version') ]; } diff --git a/app/Lib/Helpers/ToolboxHelper.php b/app/Lib/Helpers/ToolboxHelper.php index b520a65..21b9e24 100644 --- a/app/Lib/Helpers/ToolboxHelper.php +++ b/app/Lib/Helpers/ToolboxHelper.php @@ -369,7 +369,7 @@ class ToolboxHelper { // Only process if it's an object or array being passed to the function. if (is_object($input) or is_array($input)) { - $ret = (array)$input; + $ret = (array) $input; foreach ($ret as &$item) { // Recursively process EACH element only if not scalar. $item = (is_object($item) or is_array($item)) ? @@ -392,7 +392,7 @@ class ToolboxHelper { // Only process if it's an object or array being passed to the function. if (is_object($input) or is_array($input)) { - $ret = (object)$input; + $ret = (object) $input; foreach ($ret as &$item) { // Recursively process EACH element only if not scalar. $item = (is_object($item) or is_array($item)) ? diff --git a/config/app.php b/config/app.php index aa7f33f..6072907 100644 --- a/config/app.php +++ b/config/app.php @@ -41,7 +41,7 @@ return [ | */ - 'debug' => (bool)env('APP_DEBUG', false), + 'debug' => (bool) env('APP_DEBUG', false), /* |-------------------------------------------------------------------------- diff --git a/config/sentry.php b/config/sentry.php index 29627fe..2e47564 100644 --- a/config/sentry.php +++ b/config/sentry.php @@ -55,7 +55,7 @@ return [ 'send_default_pii' => env('SENTRY_SEND_DEFAULT_PII', false), // @see: https://docs.sentry.io/platforms/php/guides/laravel/configuration/options/#traces-sample-rate. - 'traces_sample_rate' => env('SENTRY_TRACES_SAMPLE_RATE') === null ? null : (float)env('SENTRY_TRACES_SAMPLE_RATE'), + 'traces_sample_rate' => env('SENTRY_TRACES_SAMPLE_RATE') === null ? null : (float) env('SENTRY_TRACES_SAMPLE_RATE'), 'before_send' => [\App\Lib\Helpers\ExceptionsHelper::class, 'sentryEventHandler'], ]; diff --git a/database/migrations/2014_10_12_000000_create_users_table.php b/database/migrations/2014_10_12_000000_create_users_table.php index 51015b6..d74887c 100644 --- a/database/migrations/2014_10_12_000000_create_users_table.php +++ b/database/migrations/2014_10_12_000000_create_users_table.php @@ -4,14 +4,14 @@ use Illuminate\Database\Migrations\Migration; use Illuminate\Database\Schema\Blueprint; use Illuminate\Support\Facades\Schema; -class CreateUsersTable extends Migration +return new class extends Migration { /** * Run the migrations. * * @return void */ - public function up() + public function up(): void { Schema::create('users', function (Blueprint $table) { $table->id(); @@ -29,8 +29,8 @@ class CreateUsersTable extends Migration * * @return void */ - public function down() + public function down(): void { Schema::dropIfExists('users'); } -} +}; diff --git a/database/migrations/2019_08_19_000000_create_failed_jobs_table.php b/database/migrations/2019_08_19_000000_create_failed_jobs_table.php index 69b2335..db96e7d 100644 --- a/database/migrations/2019_08_19_000000_create_failed_jobs_table.php +++ b/database/migrations/2019_08_19_000000_create_failed_jobs_table.php @@ -4,15 +4,14 @@ use Illuminate\Database\Migrations\Migration; use Illuminate\Database\Schema\Blueprint; use Illuminate\Support\Facades\Schema; -// phpcs:ignore PSR1.Classes.ClassDeclaration.MissingNamespace -class CreateFailedJobsTable extends Migration +return new class extends Migration { /** * Run the migrations. * * @return void */ - public function up() + public function up(): void { Schema::create('failed_jobs', function (Blueprint $table) { $table->id(); @@ -30,8 +29,8 @@ class CreateFailedJobsTable extends Migration * * @return void */ - public function down() + public function down(): void { Schema::dropIfExists('failed_jobs'); } -} +}; diff --git a/database/migrations/2020_11_26_152638_create_customers.php b/database/migrations/2020_11_26_152638_create_customers.php index 015ce55..9020139 100644 --- a/database/migrations/2020_11_26_152638_create_customers.php +++ b/database/migrations/2020_11_26_152638_create_customers.php @@ -4,15 +4,14 @@ use Illuminate\Database\Migrations\Migration; use Illuminate\Database\Schema\Blueprint; use Illuminate\Support\Facades\Schema; -// phpcs:ignore PSR1.Classes.ClassDeclaration.MissingNamespace -class CreateCustomers extends Migration +return new class extends Migration { /** * Run the migrations. * * @return void */ - public function up() + public function up(): void { Schema::create('customers', function (Blueprint $table) { $table->id(); @@ -26,8 +25,8 @@ class CreateCustomers extends Migration * * @return void */ - public function down() + public function down(): void { Schema::dropIfExists('customers'); } -} +}; diff --git a/database/migrations/2020_11_26_152901_create_brands.php b/database/migrations/2020_11_26_152901_create_brands.php index caa88c6..4d2fe22 100644 --- a/database/migrations/2020_11_26_152901_create_brands.php +++ b/database/migrations/2020_11_26_152901_create_brands.php @@ -4,15 +4,14 @@ use Illuminate\Database\Migrations\Migration; use Illuminate\Database\Schema\Blueprint; use Illuminate\Support\Facades\Schema; -// phpcs:ignore PSR1.Classes.ClassDeclaration.MissingNamespace -class CreateBrands extends Migration +return new class extends Migration { /** * Run the migrations. * * @return void */ - public function up() + public function up(): void { Schema::create('brands', function (Blueprint $table) { $table->id(); @@ -26,8 +25,8 @@ class CreateBrands extends Migration * * @return void */ - public function down() + public function down(): void { Schema::dropIfExists('brands'); } -} +}; diff --git a/database/migrations/2020_11_26_152941_create_customer_infos.php b/database/migrations/2020_11_26_152941_create_customer_infos.php index 8c69232..2de9ac3 100644 --- a/database/migrations/2020_11_26_152941_create_customer_infos.php +++ b/database/migrations/2020_11_26_152941_create_customer_infos.php @@ -4,15 +4,14 @@ use Illuminate\Database\Migrations\Migration; use Illuminate\Database\Schema\Blueprint; use Illuminate\Support\Facades\Schema; -// phpcs:ignore PSR1.Classes.ClassDeclaration.MissingNamespace -class CreateCustomerInfos extends Migration +return new class extends Migration { /** * Run the migrations. * * @return void */ - public function up() + public function up(): void { Schema::create('customer_infos', function (Blueprint $table) { $table->id(); @@ -38,8 +37,8 @@ class CreateCustomerInfos extends Migration * * @return void */ - public function down() + public function down(): void { Schema::dropIfExists('customer_infos'); } -} +}; diff --git a/database/migrations/2020_11_26_153521_create_customer_login.php b/database/migrations/2020_11_26_153521_create_customer_login.php index 1b95593..38c13a2 100644 --- a/database/migrations/2020_11_26_153521_create_customer_login.php +++ b/database/migrations/2020_11_26_153521_create_customer_login.php @@ -4,15 +4,14 @@ use Illuminate\Database\Migrations\Migration; use Illuminate\Database\Schema\Blueprint; use Illuminate\Support\Facades\Schema; -// phpcs:ignore PSR1.Classes.ClassDeclaration.MissingNamespace -class CreateCustomerLogin extends Migration +return new class extends Migration { /** * Run the migrations. * * @return void */ - public function up() + public function up(): void { Schema::create('customer_login', function (Blueprint $table) { $table->id(); @@ -30,8 +29,8 @@ class CreateCustomerLogin extends Migration * * @return void */ - public function down() + public function down(): void { Schema::dropIfExists('customer_login'); } -} +}; diff --git a/database/migrations/2020_11_26_153929_create_single_optin.php b/database/migrations/2020_11_26_153929_create_single_optin.php index cbbbc44..419fd4c 100644 --- a/database/migrations/2020_11_26_153929_create_single_optin.php +++ b/database/migrations/2020_11_26_153929_create_single_optin.php @@ -4,15 +4,14 @@ use Illuminate\Database\Migrations\Migration; use Illuminate\Database\Schema\Blueprint; use Illuminate\Support\Facades\Schema; -// phpcs:ignore PSR1.Classes.ClassDeclaration.MissingNamespace -class CreateSingleOptin extends Migration +return new class extends Migration { /** * Run the migrations. * * @return void */ - public function up() + public function up(): void { Schema::create('single_optin', function (Blueprint $table) { $table->id(); @@ -27,8 +26,8 @@ class CreateSingleOptin extends Migration * * @return void */ - public function down() + public function down(): void { Schema::dropIfExists('single_optin'); } -} +}; diff --git a/database/migrations/2020_11_26_154226_create_customer_opt_in_history.php b/database/migrations/2020_11_26_154226_create_customer_opt_in_history.php index 2f8a5c4..f6e5b66 100644 --- a/database/migrations/2020_11_26_154226_create_customer_opt_in_history.php +++ b/database/migrations/2020_11_26_154226_create_customer_opt_in_history.php @@ -4,15 +4,14 @@ use Illuminate\Database\Migrations\Migration; use Illuminate\Database\Schema\Blueprint; use Illuminate\Support\Facades\Schema; -// phpcs:ignore PSR1.Classes.ClassDeclaration.MissingNamespace -class CreateCustomerOptInHistory extends Migration +return new class extends Migration { /** * Run the migrations. * * @return void */ - public function up() + public function up(): void { Schema::create('customer_opt_in_history', function (Blueprint $table) { $table->id(); @@ -28,8 +27,8 @@ class CreateCustomerOptInHistory extends Migration * * @return void */ - public function down() + public function down(): void { Schema::dropIfExists('customer_opt_in_history'); } -} +}; diff --git a/database/migrations/2020_11_27_122842_create_services.php b/database/migrations/2020_11_27_122842_create_services.php index ec8e280..eec36eb 100644 --- a/database/migrations/2020_11_27_122842_create_services.php +++ b/database/migrations/2020_11_27_122842_create_services.php @@ -4,15 +4,14 @@ use Illuminate\Database\Migrations\Migration; use Illuminate\Database\Schema\Blueprint; use Illuminate\Support\Facades\Schema; -// phpcs:ignore PSR1.Classes.ClassDeclaration.MissingNamespace -class CreateServices extends Migration +return new class extends Migration { /** * Run the migrations. * * @return void */ - public function up() + public function up(): void { Schema::create('services', function (Blueprint $table) { $table->id(); @@ -29,8 +28,8 @@ class CreateServices extends Migration * * @return void */ - public function down() + public function down(): void { Schema::dropIfExists('services'); } -} +}; diff --git a/database/migrations/2020_12_01_145010_create_services_stats.php b/database/migrations/2020_12_01_145010_create_services_stats.php index c61231d..dc3c27a 100644 --- a/database/migrations/2020_12_01_145010_create_services_stats.php +++ b/database/migrations/2020_12_01_145010_create_services_stats.php @@ -4,15 +4,14 @@ use Illuminate\Database\Migrations\Migration; use Illuminate\Database\Schema\Blueprint; use Illuminate\Support\Facades\Schema; -// phpcs:ignore PSR1.Classes.ClassDeclaration.MissingNamespace -class CreateServicesStats extends Migration +return new class extends Migration { /** * Run the migrations. * * @return void */ - public function up() + public function up(): void { Schema::create('services_stats', function (Blueprint $table) { $table->id(); @@ -29,8 +28,8 @@ class CreateServicesStats extends Migration * * @return void */ - public function down() + public function down(): void { Schema::dropIfExists('services_stats'); } -} +}; diff --git a/database/migrations/2021_02_28_101342_rename_services_stats_table_to_service_stats.php b/database/migrations/2021_02_28_101342_rename_services_stats_table_to_service_stats.php index d1fb129..07bb658 100644 --- a/database/migrations/2021_02_28_101342_rename_services_stats_table_to_service_stats.php +++ b/database/migrations/2021_02_28_101342_rename_services_stats_table_to_service_stats.php @@ -1,18 +1,16 @@ renameColumn('api_token', 'bearer_token'); @@ -25,11 +24,11 @@ class RenameApiTokenOnServicesTable extends Migration * * @return void */ - public function down() + public function down(): void { Schema::table('services', function (Blueprint $table) { $table->renameColumn('bearer_token', 'api_token'); $table->renameColumn('bearer_token_date', 'api_token_date'); }); } -} +}; diff --git a/database/migrations/2021_03_15_073250_re_add_api_token_to_services_table.php b/database/migrations/2021_03_15_073250_re_add_api_token_to_services_table.php index e603114..f2fafad 100644 --- a/database/migrations/2021_03_15_073250_re_add_api_token_to_services_table.php +++ b/database/migrations/2021_03_15_073250_re_add_api_token_to_services_table.php @@ -2,18 +2,16 @@ use Illuminate\Database\Migrations\Migration; use Illuminate\Database\Schema\Blueprint; -use Illuminate\Support\Facades\DB; use Illuminate\Support\Facades\Schema; -// phpcs:ignore PSR1.Classes.ClassDeclaration.MissingNamespace -class ReAddApiTokenToServicesTable extends Migration +return new class extends Migration { /** * Run the migrations. * * @return void */ - public function up() + public function up(): void { Schema::table('services', function (Blueprint $table) { $table->string('api_token')->nullable()->after('bearer_token_date'); @@ -26,7 +24,7 @@ class ReAddApiTokenToServicesTable extends Migration * * @return void */ - public function down() + public function down(): void { Schema::table('services', function (Blueprint $table) { $table->dropColumn('api_token'); @@ -35,4 +33,4 @@ class ReAddApiTokenToServicesTable extends Migration $table->dropColumn('api_token_date'); }); } -} +}; diff --git a/database/migrations/2021_08_02_103828_add_bearer_pwd_to_services_table.php b/database/migrations/2021_08_02_103828_add_bearer_pwd_to_services_table.php index 70ff424..3a3fb85 100644 --- a/database/migrations/2021_08_02_103828_add_bearer_pwd_to_services_table.php +++ b/database/migrations/2021_08_02_103828_add_bearer_pwd_to_services_table.php @@ -4,14 +4,14 @@ use Illuminate\Database\Migrations\Migration; use Illuminate\Database\Schema\Blueprint; use Illuminate\Support\Facades\Schema; -class AddBearerPwdToServicesTable extends Migration +return new class extends Migration { /** * Run the migrations. * * @return void */ - public function up() + public function up(): void { Schema::table('services', function (Blueprint $table) { $table->string('bearer_pwd')->after('bearer_token'); @@ -23,10 +23,10 @@ class AddBearerPwdToServicesTable extends Migration * * @return void */ - public function down() + public function down(): void { Schema::table('services', function (Blueprint $table) { $table->dropColumn('bearer_pwd'); }); } -} +}; diff --git a/database/migrations/2021_08_03_163527_add_newcountry_column_to_customer_infos_table.php b/database/migrations/2021_08_03_163527_add_newcountry_column_to_customer_infos_table.php index d11403a..2f64d36 100644 --- a/database/migrations/2021_08_03_163527_add_newcountry_column_to_customer_infos_table.php +++ b/database/migrations/2021_08_03_163527_add_newcountry_column_to_customer_infos_table.php @@ -4,14 +4,14 @@ use Illuminate\Database\Migrations\Migration; use Illuminate\Database\Schema\Blueprint; use Illuminate\Support\Facades\Schema; -class AddNewcountryColumnToCustomerInfosTable extends Migration +return new class extends Migration { /** * Run the migrations. * * @return void */ - public function up() + public function up(): void { Schema::table('customer_infos', function (Blueprint $table) { $table->smallInteger('newcountry')->default(76)->after('country'); @@ -23,10 +23,10 @@ class AddNewcountryColumnToCustomerInfosTable extends Migration * * @return void */ - public function down() + public function down(): void { Schema::table('customer_infos', function (Blueprint $table) { $table->dropColumn('newcountry'); }); } -} +}; diff --git a/database/migrations/2021_08_10_103745_create_questions_table.php b/database/migrations/2021_08_10_103745_create_questions_table.php index 90ec94e..5eaf085 100644 --- a/database/migrations/2021_08_10_103745_create_questions_table.php +++ b/database/migrations/2021_08_10_103745_create_questions_table.php @@ -4,19 +4,20 @@ use Illuminate\Database\Migrations\Migration; use Illuminate\Database\Schema\Blueprint; use Illuminate\Support\Facades\Schema; -class CreateQuestionsTable extends Migration +return new class extends Migration { /** * Run the migrations. * * @return void */ - public function up() + public function up(): void { Schema::create('questions', function (Blueprint $table) { $table->id(); $table->text('question'); - $table->tinyInteger('type'); // QuestionType + // QuestionType. + $table->tinyInteger('type'); $table->foreignId('brand_id')->constrained('brands'); $table->timestamps(); }); @@ -27,8 +28,8 @@ class CreateQuestionsTable extends Migration * * @return void */ - public function down() + public function down(): void { Schema::dropIfExists('questions'); } -} +}; diff --git a/database/migrations/2021_08_10_103757_create_answers_table.php b/database/migrations/2021_08_10_103757_create_answers_table.php index 79d038b..bf3ec7c 100644 --- a/database/migrations/2021_08_10_103757_create_answers_table.php +++ b/database/migrations/2021_08_10_103757_create_answers_table.php @@ -4,14 +4,14 @@ use Illuminate\Database\Migrations\Migration; use Illuminate\Database\Schema\Blueprint; use Illuminate\Support\Facades\Schema; -class CreateAnswersTable extends Migration +return new class extends Migration { /** * Run the migrations. * * @return void */ - public function up() + public function up(): void { Schema::create('answers', function (Blueprint $table) { $table->id(); @@ -26,8 +26,8 @@ class CreateAnswersTable extends Migration * * @return void */ - public function down() + public function down(): void { Schema::dropIfExists('answers'); } -} +}; diff --git a/database/migrations/2021_08_10_104859_create_customer_answer_table.php b/database/migrations/2021_08_10_104859_create_customer_answer_table.php index 6f092c5..20c1a45 100644 --- a/database/migrations/2021_08_10_104859_create_customer_answer_table.php +++ b/database/migrations/2021_08_10_104859_create_customer_answer_table.php @@ -4,14 +4,14 @@ use Illuminate\Database\Migrations\Migration; use Illuminate\Database\Schema\Blueprint; use Illuminate\Support\Facades\Schema; -class CreateCustomerAnswerTable extends Migration +return new class extends Migration { /** * Run the migrations. * * @return void */ - public function up() + public function up(): void { Schema::create('customer_answer', function (Blueprint $table) { $table->foreignId('answer_id')->constrained('answers'); @@ -25,8 +25,8 @@ class CreateCustomerAnswerTable extends Migration * * @return void */ - public function down() + public function down(): void { Schema::dropIfExists('customer_answer'); } -} +}; diff --git a/database/migrations/2021_08_12_152220_hash_api_keys_in_services_table.php b/database/migrations/2021_08_12_152220_hash_api_keys_in_services_table.php index 2e683c4..193946b 100644 --- a/database/migrations/2021_08_12_152220_hash_api_keys_in_services_table.php +++ b/database/migrations/2021_08_12_152220_hash_api_keys_in_services_table.php @@ -4,14 +4,14 @@ use App\Models\Service; use Illuminate\Database\Migrations\Migration; use Illuminate\Support\Facades\Hash; -class HashApiKeysInServicesTable extends Migration +return new class extends Migration { /** * Run the migrations. * * @return void */ - public function up() + public function up(): void { foreach (Service::all() as $service) { $service->bearer_token = Hash::make($service->bearer_token); @@ -24,7 +24,8 @@ class HashApiKeysInServicesTable extends Migration * * @return void */ - public function down() + public function down(): void { + // Do nothing. } -} +}; diff --git a/database/migrations/2021_08_23_180427_create_jobs_table.php b/database/migrations/2021_08_23_180427_create_jobs_table.php index 1be9e8a..560ae54 100644 --- a/database/migrations/2021_08_23_180427_create_jobs_table.php +++ b/database/migrations/2021_08_23_180427_create_jobs_table.php @@ -4,14 +4,14 @@ use Illuminate\Database\Migrations\Migration; use Illuminate\Database\Schema\Blueprint; use Illuminate\Support\Facades\Schema; -class CreateJobsTable extends Migration +return new class extends Migration { /** * Run the migrations. * * @return void */ - public function up() + public function up(): void { Schema::create('jobs', function (Blueprint $table) { $table->bigIncrements('id'); @@ -29,8 +29,8 @@ class CreateJobsTable extends Migration * * @return void */ - public function down() + public function down(): void { Schema::dropIfExists('jobs'); } -} +}; diff --git a/database/migrations/2021_10_29_110018_create_brand_stats_table.php b/database/migrations/2021_10_29_110018_create_brand_stats_table.php index 57e53c6..fe28f98 100644 --- a/database/migrations/2021_10_29_110018_create_brand_stats_table.php +++ b/database/migrations/2021_10_29_110018_create_brand_stats_table.php @@ -4,32 +4,32 @@ use Illuminate\Database\Migrations\Migration; use Illuminate\Database\Schema\Blueprint; use Illuminate\Support\Facades\Schema; -class CreateBrandStatsTable extends Migration +return new class extends Migration { /** * Run the migrations. * * @return void */ - public function up() + public function up(): void { Schema::create('brand_stats', function (Blueprint $table) { - // Le nombre de comptes actifs (dernière connexion inférieure à 6 mois) + // Le nombre de comptes actifs (dernière connexion inférieure à 6 mois). $table->unsignedInteger('active'); - // Le nombre de comptes inactifs (dernière connexion supérieure à 6 mois) + // Le nombre de comptes inactifs (dernière connexion supérieure à 6 mois). $table->unsignedInteger('inactive'); - // Le nombre d’anciens comptes (date de création supérieure à 6 mois + // Le nombre d’anciens comptes (date de création supérieure à 6 mois. $table->unsignedInteger('old_accounts'); - // Le nombre de nouveaux comptes (date de création inférieure à 6 mois) + // Le nombre de nouveaux comptes (date de création inférieure à 6 mois). $table->unsignedInteger('new_accounts'); - // Le nombre de comptes total + // Le nombre de comptes total. $table->unsignedInteger('total_accounts'); - // Le nombre d’optins (single optin compris) + // Le nombre d’optins (single optin compris). $table->unsignedInteger('total_opt_in'); $table->timestamp('created_at')->nullable(); @@ -45,8 +45,8 @@ class CreateBrandStatsTable extends Migration * * @return void */ - public function down() + public function down(): void { Schema::dropIfExists('brand_stats'); } -} +}; diff --git a/database/migrations/2021_10_29_160416_repair_stats_jobs.php b/database/migrations/2021_10_29_160416_repair_stats_jobs.php index a1a900b..d33ef82 100644 --- a/database/migrations/2021_10_29_160416_repair_stats_jobs.php +++ b/database/migrations/2021_10_29_160416_repair_stats_jobs.php @@ -6,14 +6,14 @@ use Illuminate\Database\Migrations\Migration; use Illuminate\Support\Carbon; use Illuminate\Support\Facades\DB; -class RepairStatsJobs extends Migration +return new class extends Migration { /** * Run the migrations. * * @return void */ - public function up() + public function up(): void { $jobIDS = []; $page = 1; @@ -44,8 +44,8 @@ class RepairStatsJobs extends Migration } $serviceStat->nb_calls += 1; $serviceStat->saveOrFail(); - } - } + } //end if + } //end foreach DB::table('jobs')->whereIn('id', $jobIDS) ->delete(); $jobIDS = []; @@ -57,8 +57,8 @@ class RepairStatsJobs extends Migration * * @return void */ - public function down() + public function down(): void { - // + // Do nothing. } -} +}; diff --git a/database/migrations/2021_12_07_203437_drop_api_token_from_services.php b/database/migrations/2021_12_07_203437_drop_api_token_from_services.php index 9068601..b32814d 100644 --- a/database/migrations/2021_12_07_203437_drop_api_token_from_services.php +++ b/database/migrations/2021_12_07_203437_drop_api_token_from_services.php @@ -4,14 +4,14 @@ use Illuminate\Database\Migrations\Migration; use Illuminate\Database\Schema\Blueprint; use Illuminate\Support\Facades\Schema; -class DropApiTokenFromServices extends Migration +return new class extends Migration { /** * Run the migrations. * * @return void */ - public function up() + public function up(): void { Schema::table('services', function (Blueprint $table) { $table->dropColumn('api_token'); @@ -24,11 +24,11 @@ class DropApiTokenFromServices extends Migration * * @return void */ - public function down() + public function down(): void { Schema::table('services', function (Blueprint $table) { $table->string('api_token')->nullable()->after('bearer_token_date'); $table->timestamp('api_token_date')->after('api_token')->useCurrent(); }); } -} +}; diff --git a/database/migrations/2021_12_07_211411_set_unique_constrain_on_api_token_on_services.php b/database/migrations/2021_12_07_211411_set_unique_constrain_on_api_token_on_services.php index 229aa73..278ddf4 100644 --- a/database/migrations/2021_12_07_211411_set_unique_constrain_on_api_token_on_services.php +++ b/database/migrations/2021_12_07_211411_set_unique_constrain_on_api_token_on_services.php @@ -4,14 +4,14 @@ use Illuminate\Database\Migrations\Migration; use Illuminate\Database\Schema\Blueprint; use Illuminate\Support\Facades\Schema; -class SetUniqueConstrainOnApiTokenOnServices extends Migration +return new class extends Migration { /** * Run the migrations. * * @return void */ - public function up() + public function up(): void { Schema::table('services', function (Blueprint $table) { $table->unique('bearer_token'); @@ -23,10 +23,10 @@ class SetUniqueConstrainOnApiTokenOnServices extends Migration * * @return void */ - public function down() + public function down(): void { Schema::table('services', function (Blueprint $table) { $table->dropUnique(['bearer_token']); }); } -} +}; diff --git a/database/migrations/2021_12_08_000551_increase_bearer_pwd_on_services.php b/database/migrations/2021_12_08_000551_increase_bearer_pwd_on_services.php index c5404ce..3880d30 100644 --- a/database/migrations/2021_12_08_000551_increase_bearer_pwd_on_services.php +++ b/database/migrations/2021_12_08_000551_increase_bearer_pwd_on_services.php @@ -4,14 +4,14 @@ use Illuminate\Database\Migrations\Migration; use Illuminate\Database\Schema\Blueprint; use Illuminate\Support\Facades\Schema; -class IncreaseBearerPwdOnServices extends Migration +return new class extends Migration { /** * Run the migrations. * * @return void */ - public function up() + public function up(): void { Schema::table('services', function (Blueprint $table) { $table->string('bearer_pwd', 312)->change(); @@ -23,9 +23,9 @@ class IncreaseBearerPwdOnServices extends Migration * * @return void */ - public function down() + public function down(): void { // Dont revert this, could break things with truncated // columns, wont harm. } -} +}; diff --git a/database/migrations/2021_12_26_152449_parse_country_on_customer_infos.php b/database/migrations/2021_12_26_152449_parse_country_on_customer_infos.php index 1ef5564..06bc1ff 100644 --- a/database/migrations/2021_12_26_152449_parse_country_on_customer_infos.php +++ b/database/migrations/2021_12_26_152449_parse_country_on_customer_infos.php @@ -8,14 +8,14 @@ use Illuminate\Support\Facades\DB; use Illuminate\Support\Facades\Schema; use Illuminate\Support\Str; -class ParseCountryOnCustomerInfos extends Migration +return new class extends Migration { /** * Run the migrations. * * @return void */ - public function up() + public function up(): void { $perPage = 10000; $currentPage = 0; @@ -56,8 +56,8 @@ class ParseCountryOnCustomerInfos extends Migration * * @return void */ - public function down() + public function down(): void { // Do nothing. } -} +}; diff --git a/database/migrations/2021_12_28_010744_set_customer_id_nullable_on_customer_answer.php b/database/migrations/2021_12_28_010744_set_customer_id_nullable_on_customer_answer.php index b21e272..8eb381a 100644 --- a/database/migrations/2021_12_28_010744_set_customer_id_nullable_on_customer_answer.php +++ b/database/migrations/2021_12_28_010744_set_customer_id_nullable_on_customer_answer.php @@ -4,14 +4,14 @@ use Illuminate\Database\Migrations\Migration; use Illuminate\Database\Schema\Blueprint; use Illuminate\Support\Facades\Schema; -class SetCustomerIdNullableOnCustomerAnswer extends Migration +return new class extends Migration { /** * Run the migrations. * * @return void */ - public function up() + public function up(): void { Schema::disableForeignKeyConstraints(); Schema::table('customer_answer', function (Blueprint $table) { @@ -28,7 +28,7 @@ class SetCustomerIdNullableOnCustomerAnswer extends Migration * * @return void */ - public function down() + public function down(): void { Schema::disableForeignKeyConstraints(); Schema::table('customer_answer', function (Blueprint $table) { @@ -39,4 +39,4 @@ class SetCustomerIdNullableOnCustomerAnswer extends Migration }); Schema::enableForeignKeyConstraints(); } -} +}; diff --git a/database/migrations/2022_12_01_173016_cascade_delete_question_answers.php b/database/migrations/2022_12_01_173016_cascade_delete_question_answers.php index 37e5431..9ff9ba0 100644 --- a/database/migrations/2022_12_01_173016_cascade_delete_question_answers.php +++ b/database/migrations/2022_12_01_173016_cascade_delete_question_answers.php @@ -4,14 +4,14 @@ use Illuminate\Database\Migrations\Migration; use Illuminate\Database\Schema\Blueprint; use Illuminate\Support\Facades\Schema; -class CascadeDeleteQuestionAnswers extends Migration +return new class extends Migration { /** * Run the migrations. * * @return void */ - public function up() + public function up(): void { // * Add cascade delete Schema::table('answers', function (Blueprint $table) { @@ -25,7 +25,7 @@ class CascadeDeleteQuestionAnswers extends Migration * * @return void */ - public function down() + public function down(): void { // * Undo cascade delete (restrict as default) Schema::table('answers', function (Blueprint $table) { @@ -33,4 +33,4 @@ class CascadeDeleteQuestionAnswers extends Migration $table->foreign('question_id')->references('id')->on('questions'); }); } -} +}; diff --git a/database/migrations/2023_06_23_134010_cascade_delete_customer_answer.php b/database/migrations/2023_06_23_134010_cascade_delete_customer_answer.php index b048a0f..58ba982 100644 --- a/database/migrations/2023_06_23_134010_cascade_delete_customer_answer.php +++ b/database/migrations/2023_06_23_134010_cascade_delete_customer_answer.php @@ -4,14 +4,14 @@ use Illuminate\Database\Migrations\Migration; use Illuminate\Database\Schema\Blueprint; use Illuminate\Support\Facades\Schema; -class CascadeDeleteCustomerAnswer extends Migration +return new class extends Migration { /** * Run the migrations. * * @return void */ - public function up() + public function up(): void { // * Add cascade delete Schema::table('customer_answer', function (Blueprint $table) { @@ -25,7 +25,7 @@ class CascadeDeleteCustomerAnswer extends Migration * * @return void */ - public function down() + public function down(): void { // * Undo cascade delete (restrict as default) Schema::table('customer_answer', function (Blueprint $table) { @@ -33,4 +33,4 @@ class CascadeDeleteCustomerAnswer extends Migration $table->foreign('answer_id')->references('id')->on('answers'); }); } -} +}; diff --git a/database/migrations/2023_06_23_171318_add_change_single_optin_to_use_hashcode.php b/database/migrations/2023_06_23_171318_add_change_single_optin_to_use_hashcode.php index 9c174fc..e5edea2 100644 --- a/database/migrations/2023_06_23_171318_add_change_single_optin_to_use_hashcode.php +++ b/database/migrations/2023_06_23_171318_add_change_single_optin_to_use_hashcode.php @@ -6,14 +6,14 @@ use Illuminate\Support\Facades\DB; use Illuminate\Support\Facades\Schema; use Illuminate\Support\Str; -class AddChangeSingleOptinToUseHashcode extends Migration +return new class extends Migration { /** * Run the migrations. * * @return void */ - public function up() + public function up(): void { Schema::table('single_optins', function (Blueprint $table) { $table->uuid('hashcode')->comment('Single optin hashcode')->after('id'); @@ -37,7 +37,7 @@ class AddChangeSingleOptinToUseHashcode extends Migration * * @return void */ - public function down() + public function down(): void { Schema::table('single_optins', function (Blueprint $table) { $table->id()->after('hashcode'); @@ -46,4 +46,4 @@ class AddChangeSingleOptinToUseHashcode extends Migration $table->dropColumn('hashcode'); }); } -} +}; diff --git a/database/migrations/2023_06_23_172216_enhance_customer_infos_hashcode.php b/database/migrations/2023_06_23_172216_enhance_customer_infos_hashcode.php index 241b1a0..731e2fd 100644 --- a/database/migrations/2023_06_23_172216_enhance_customer_infos_hashcode.php +++ b/database/migrations/2023_06_23_172216_enhance_customer_infos_hashcode.php @@ -4,14 +4,14 @@ use Illuminate\Database\Migrations\Migration; use Illuminate\Database\Schema\Blueprint; use Illuminate\Support\Facades\Schema; -class EnhanceCustomerInfosHashcode extends Migration +return new class extends Migration { /** * Run the migrations. * * @return void */ - public function up() + public function up(): void { Schema::table('customer_infos', function (Blueprint $table) { $table->uuid('hashcode') @@ -24,8 +24,8 @@ class EnhanceCustomerInfosHashcode extends Migration * * @return void */ - public function down() + public function down(): void { // * No need to undo that. } -} +}; diff --git a/phpcs.xml b/phpcs.xml index 80914bd..9cca483 100644 --- a/phpcs.xml +++ b/phpcs.xml @@ -10,6 +10,7 @@ database/seeders routes/ tests/ + */vendor/* @@ -31,8 +32,7 @@ - - + @@ -46,9 +46,6 @@ - - - @@ -81,7 +78,7 @@ - + diff --git a/tests/CRM/ApiV2/ApiBase.php b/tests/CRM/ApiV2/ApiBase.php index c0cd66a..991ebca 100644 --- a/tests/CRM/ApiV2/ApiBase.php +++ b/tests/CRM/ApiV2/ApiBase.php @@ -24,13 +24,13 @@ class ApiBase extends BaseTestCase * @param \App\Enums\ApiStatus $status * @return void */ - protected function assertApiResponseStatusIs(AssertableJsonString $json, ApiStatus $status) + protected function assertApiResponseStatusIs(AssertableJsonString $json, ApiStatus $status): void { $json->assertFragment(['status' => $status->value()]); } /** - * Raw Function to call api + * Raw Function to call api. * * @param string $method * @param string $uri @@ -51,7 +51,7 @@ class ApiBase extends BaseTestCase } /** - * Raw Function to call api with Token + * Raw Function to call api with Token. * * @param \App\Models\Service $service * @param string $method @@ -81,7 +81,7 @@ class ApiBase extends BaseTestCase } /** - * Get Customer models with given status (active or not) + * Get Customer models with given status (active or not). * * @param boolean $status The customer status for a brand. * @param boolean $random Randomize the customer to get. diff --git a/tests/CRM/ApiV2/ArcadiaTest.php b/tests/CRM/ApiV2/ArcadiaTest.php index d8e530f..f5f9cf2 100644 --- a/tests/CRM/ApiV2/ArcadiaTest.php +++ b/tests/CRM/ApiV2/ArcadiaTest.php @@ -74,7 +74,7 @@ class ArcadiaTest extends ApiBase 'order_date' => date('Y/m/d H:i:s'), 'support_code' => 32, 'label_type_support' => 'Jeux Reghalal', - 'code_unique' => \strtoupper(\str_replace('-', '', (string)Str::uuid())), + 'code_unique' => \strtoupper(\str_replace('-', '', (string) Str::uuid())), 'code_on_pack' => '2563547' ]; $response = $this->callApiWithToken($service, 'post', route( diff --git a/tests/CRM/ApiV2/CustomerTest.php b/tests/CRM/ApiV2/CustomerTest.php index c23a006..7bd5d49 100644 --- a/tests/CRM/ApiV2/CustomerTest.php +++ b/tests/CRM/ApiV2/CustomerTest.php @@ -639,7 +639,7 @@ class CustomerTest extends ApiBase }); $this->assertTrue( - (bool)$customer->logins()->count(), + (bool) $customer->logins()->count(), 'This test assumes customer belongs to multiple brand.' ); diff --git a/tests/CRM/ApiV4/ArcadiaTest.php b/tests/CRM/ApiV4/ArcadiaTest.php index c781959..8d24255 100644 --- a/tests/CRM/ApiV4/ArcadiaTest.php +++ b/tests/CRM/ApiV4/ArcadiaTest.php @@ -74,7 +74,7 @@ class ArcadiaTest extends ApiBase 'order_date' => date('Y/m/d H:i:s'), 'support_code' => 32, 'label_type_support' => 'Jeux Reghalal', - 'code_unique' => \strtoupper(\str_replace('-', '', (string)Str::uuid())), + 'code_unique' => \strtoupper(\str_replace('-', '', (string) Str::uuid())), 'code_on_pack' => '2563547' ]; $response = $this->callApiWithToken($service, 'post', route( diff --git a/tests/CRM/ApiV4/ClaimTest.php b/tests/CRM/ApiV4/ClaimTest.php index 431aee9..7ad687d 100644 --- a/tests/CRM/ApiV4/ClaimTest.php +++ b/tests/CRM/ApiV4/ClaimTest.php @@ -9,6 +9,7 @@ use App\Models\ClaimSubject; use App\Models\Customer; use Illuminate\Http\UploadedFile; use Illuminate\Support\Arr; +use Illuminate\Support\Facades\Storage; class ClaimTest extends ApiBase { @@ -66,6 +67,14 @@ class ClaimTest extends ApiBase $json = $response->decodeResponseJson(); $this->assertApiResponseStatusIs($json, ApiStatus::OK); $this->assertTrue($claimModel, 'Claim should have been stored.'); + + // Assert file stored. + $claimModel = Claim::query()->where('email', 'claim@hotmail.fr')->firstOrFail(); + $this->assertNotEmpty($claimModel->file, 'The "file" field is empty on the Claim model.'); + $this->assertTrue( + Storage::exists(ltrim($claimModel->file, '/')), + "The file does not exist: {$claimModel->file}" + ); } /** @@ -100,8 +109,7 @@ class ClaimTest extends ApiBase public function testSendClaimWithoutOptionnalFieldsShouldWork(): void { extract($this->getCustomer(true, false)); - $subject = ClaimSubject::query()->firstOrNew(); - $customer = Customer::query()->firstOrNew(); + $subject = ClaimSubject::query()->firstOrNew(); $response = $this->callApiWithToken($service, 'post', route('apiV4.claim.store'), \array_merge( Arr::except($this->skeleton, ['address', 'city', 'postcode', 'file']), diff --git a/tests/CRM/ApiV4/CustomerTest.php b/tests/CRM/ApiV4/CustomerTest.php index 6bbe7c6..1958d18 100644 --- a/tests/CRM/ApiV4/CustomerTest.php +++ b/tests/CRM/ApiV4/CustomerTest.php @@ -21,7 +21,7 @@ class CustomerTest extends ApiBase use DatabaseTransactions; /** - * Test Customer relations to its related models + * Test Customer relations to its related models. * * @return void */ @@ -172,7 +172,7 @@ class CustomerTest extends ApiBase } /** - * Customer store ok + * Customer store ok. * route: apiV4.customers.store * * @return void @@ -639,7 +639,7 @@ class CustomerTest extends ApiBase }); $this->assertTrue( - (bool)$customer->logins()->count(), + (bool) $customer->logins()->count(), 'This test assumes customer belongs to multiple brand.' ); diff --git a/tests/Client/CrmClientArcadiaTest.php b/tests/Client/CrmClientArcadiaTest.php index 532aedb..727ef18 100644 --- a/tests/Client/CrmClientArcadiaTest.php +++ b/tests/Client/CrmClientArcadiaTest.php @@ -17,7 +17,7 @@ class CrmClientArcadiaTest extends CrmClientTester * * @return void */ - public function testArcadiaSendOrderDefault() + public function testArcadiaSendOrderDefault(): void { $api = new CrmApiV4(); $customer = $api->getCustomerOrNew(static::$info->hashcode); @@ -44,11 +44,11 @@ class CrmClientArcadiaTest extends CrmClientTester } /** - * Test arcadia default mail can serialize to json + * Test arcadia default mail can serialize to json. * * @return void */ - public function testArcadiaOrderDefaultJson() + public function testArcadiaOrderDefaultJson(): void { $data = [ 'email' => static::$customer->email, @@ -95,7 +95,7 @@ class CrmClientArcadiaTest extends CrmClientTester * * @return void */ - public function testArcadiaSendOrderGame() + public function testArcadiaSendOrderGame(): void { $api = new CrmApiV4(); $customer = $api->getCustomerOrNew(static::$info->hashcode); @@ -112,7 +112,7 @@ class CrmClientArcadiaTest extends CrmClientTester 'order_date' => date('Y/m/d H:i:s'), 'support_code' => 32, 'label_type_support' => 'Jeux Reghalal', - 'code_unique' => \strtoupper(\str_replace('-', '', (string)Str::uuid())), + 'code_unique' => \strtoupper(\str_replace('-', '', (string) Str::uuid())), 'code_on_pack' => '12365214587562' ]); $this->assertTrue($arcadiaOrderMail->send($customer)); @@ -123,7 +123,7 @@ class CrmClientArcadiaTest extends CrmClientTester * * @return void */ - public function testArcadiaSendOrderGameNullString() + public function testArcadiaSendOrderGameNullString(): void { $api = new CrmApiV4(); $customer = $api->getCustomerOrNew(static::$info->hashcode); @@ -147,11 +147,11 @@ class CrmClientArcadiaTest extends CrmClientTester } /** - * Test arcadia game mail can serialize to json + * Test arcadia game mail can serialize to json. * * @return void */ - public function testArcadiaOrderGameJson() + public function testArcadiaOrderGameJson(): void { $data = [ 'email' => static::$customer->email, @@ -166,7 +166,7 @@ class CrmClientArcadiaTest extends CrmClientTester 'order_date' => date('Y/m/d H:i:s'), 'support_code' => 32, 'label_type_support' => 'Jeux Reghalal', - 'code_unique' => \strtoupper(\str_replace('-', '', (string)Str::uuid())), + 'code_unique' => \strtoupper(\str_replace('-', '', (string) Str::uuid())), 'code_on_pack' => '12365214587562' ]; @@ -196,7 +196,7 @@ class CrmClientArcadiaTest extends CrmClientTester * * @return void */ - public function testValidateGeneratedXmlDefault() + public function testValidateGeneratedXmlDefault(): void { $fileFound = false; @@ -225,7 +225,7 @@ class CrmClientArcadiaTest extends CrmClientTester * * @return void */ - public function testValidateGeneratedXmlGame() + public function testValidateGeneratedXmlGame(): void { $fileFound = false; @@ -250,7 +250,7 @@ class CrmClientArcadiaTest extends CrmClientTester } /** - * Render a \LibXMLError + * Render a \LibXMLError. * * @param \LibXMLError $error * @return string @@ -283,7 +283,7 @@ class CrmClientArcadiaTest extends CrmClientTester * * @return void */ - private function libxmlDisplayErrors() + private function libxmlDisplayErrors(): void { $errors = libxml_get_errors(); foreach ($errors as $error) { diff --git a/tests/Client/CrmClientClaimTest.php b/tests/Client/CrmClientClaimTest.php index d8308e5..4f8e133 100644 --- a/tests/Client/CrmClientClaimTest.php +++ b/tests/Client/CrmClientClaimTest.php @@ -3,9 +3,10 @@ namespace Tests\Client; use App\Models\Claim as ModelsClaim; -use LDC\LDCCRM\Models\Claim; use Illuminate\Http\UploadedFile; +use Illuminate\Support\Facades\Storage; use LDC\LDCCRM\Exceptions\ValidationException; +use LDC\LDCCRM\Models\Claim; class CrmClientClaimTest extends CrmClientTester { @@ -16,7 +17,8 @@ class CrmClientClaimTest extends CrmClientTester */ public function testCreateClaim(): void { - $image = UploadedFile::fake()->image('photo.jpg'); + $image = UploadedFile::fake()->image('photo.jpg'); + $base64 = base64_encode(file_get_contents($image->getRealPath())); $this->assertTrue(Claim::setClaim( 'Jean', 'Bond', @@ -27,9 +29,16 @@ class CrmClientClaimTest extends CrmClientTester '10 rue des totos', 'Le Mans', '72100', - base64_encode(file_get_contents($image->getRealPath())), + $base64, )); $this->assertTrue(ModelsClaim::query()->where('email', 'claim@hotmail.fr')->exists()); + + $claimModel = ModelsClaim::query()->where('email', 'claim@hotmail.fr')->firstOrFail(); + $this->assertNotEmpty($claimModel->file, 'The "file" field is empty on the Claim model.'); + $this->assertTrue( + Storage::exists(ltrim($claimModel->file, '/')), + "The file does not exist: {$claimModel->file}" + ); } /** diff --git a/tests/Client/CrmClientClientTest.php b/tests/Client/CrmClientClientTest.php index e12ad76..51ce5fb 100644 --- a/tests/Client/CrmClientClientTest.php +++ b/tests/Client/CrmClientClientTest.php @@ -17,7 +17,7 @@ class CrmClientClientTest extends CrmClientTester * * @return void */ - public function testApiInterface() + public function testApiInterface(): void { $routes = $this->getClientRoutes(); $interface = new ApiInterface(); @@ -37,18 +37,18 @@ class CrmClientClientTest extends CrmClientTester * * @return void */ - public function testClientPing() + public function testClientPing(): void { $api = new CrmApiV4(); $this->assertTrue($api->ping()); } /** - * Set unknown attribute set + * Set unknown attribute set. * * @return void */ - public function testCrmModelSetUnknownAttribute() + public function testCrmModelSetUnknownAttribute(): void { $this->expectException(AccessError::class); $customer = new Customer(); diff --git a/tests/Client/CrmClientConfigTest.php b/tests/Client/CrmClientConfigTest.php index 011d566..414030f 100644 --- a/tests/Client/CrmClientConfigTest.php +++ b/tests/Client/CrmClientConfigTest.php @@ -7,11 +7,11 @@ use LDC\LDCCRM\Utils; class CrmClientConfigTest extends CrmClientTester { /** - * Test Utils::getConfig + * Test Utils::getConfig. * * @return void */ - public function testConfigGet() + public function testConfigGet(): void { $this->assertEquals(null, Utils::getConfig('totot')); } diff --git a/tests/Client/CrmClientCustomerTest.php b/tests/Client/CrmClientCustomerTest.php index 3c653fa..3c6feea 100644 --- a/tests/Client/CrmClientCustomerTest.php +++ b/tests/Client/CrmClientCustomerTest.php @@ -21,7 +21,7 @@ class CrmClientCustomerTest extends CrmClientTester * * @return void */ - public function testGetter() + public function testGetter(): void { $this->expectNotToPerformAssertions(); $client = new Customer(); @@ -29,11 +29,11 @@ class CrmClientCustomerTest extends CrmClientTester } /** - * Test set customer prop + * Test set customer prop. * * @return void */ - public function testSetter() + public function testSetter(): void { $this->expectNotToPerformAssertions(); $client = new Customer(); @@ -47,7 +47,7 @@ class CrmClientCustomerTest extends CrmClientTester * * @return void */ - public function testSetterFailWrongType() + public function testSetterFailWrongType(): void { $this->expectException(ValidationException::class); $client = new Customer(); @@ -60,7 +60,7 @@ class CrmClientCustomerTest extends CrmClientTester * * @return void */ - public function testSetterFailWrongTypeCountry() + public function testSetterFailWrongTypeCountry(): void { $this->expectException(ValidationException::class); $client = new Customer(); @@ -73,13 +73,13 @@ class CrmClientCustomerTest extends CrmClientTester * * @return void */ - public function testPropsAllSetOk() + public function testPropsAllSetOk(): void { $this->expectNotToPerformAssertions(); $client = new Customer(); $propTypes = [ - 'hashcode' => (string)Str::uuid(), + 'hashcode' => (string) Str::uuid(), 'email' => 'toto@gmail.com', 'firstname' => 'string', 'lastname' => 'string', @@ -105,12 +105,12 @@ class CrmClientCustomerTest extends CrmClientTester * * @return void */ - public function testJsonSerialize() + public function testJsonSerialize(): void { $client = new Customer(); $propTypes = [ - 'hashcode' => (string)Str::uuid(), + 'hashcode' => (string) Str::uuid(), 'email' => 'toto@gmail.com', 'firstname' => 'string', 'lastname' => 'string', @@ -144,13 +144,13 @@ class CrmClientCustomerTest extends CrmClientTester * * @return void */ - public function testPropsAllSetNotOk() + public function testPropsAllSetNotOk(): void { $this->expectException(ValidationException::class); $client = new Customer(); $propTypes = [ - 'hashcode' => (string)Str::uuid(), + 'hashcode' => (string) Str::uuid(), 'email' => 'toto@gmail.com', 'firstname' => 'string', 'lastname' => 'string', @@ -172,16 +172,16 @@ class CrmClientCustomerTest extends CrmClientTester } /** - * Test set unkown prop fail + * Test set unkown prop fail. * * @return void */ - public function testPropsAssignUnknown() + public function testPropsAssignUnknown(): void { $this->expectException(AccessError::class); $customer = new Customer([ - 'hashcode' => (string)Str::uuid(), + 'hashcode' => (string) Str::uuid(), 'email' => 'toto@gmail.com', 'firstname' => 'string', 'lastname' => 'string', @@ -201,16 +201,16 @@ class CrmClientCustomerTest extends CrmClientTester } /** - * Test set prop fail wrong type + * Test set prop fail wrong type. * * @return void */ - public function testPropsAssignWrongType() + public function testPropsAssignWrongType(): void { $this->expectException(ValidationException::class); $customer = new Customer([ - 'hashcode' => (string)Str::uuid(), + 'hashcode' => (string) Str::uuid(), 'email' => 'toto@gmail.com', 'firstname' => 'string', 'lastname' => 'string', @@ -234,7 +234,7 @@ class CrmClientCustomerTest extends CrmClientTester * * @return void */ - public function testCustomerGet() + public function testCustomerGet(): void { $api = new CrmApiV4(); $customer = $api->getCustomerOrNew(static::$info->hashcode); @@ -259,7 +259,7 @@ class CrmClientCustomerTest extends CrmClientTester * * @return void */ - public function testCustomerActivate() + public function testCustomerActivate(): void { // Get non activated customer. /** @var \App\Models\Customer */ @@ -283,11 +283,11 @@ class CrmClientCustomerTest extends CrmClientTester } /** - * Test customer update + * Test customer update. * * @return void */ - public function testCustomerUpdateProps() + public function testCustomerUpdateProps(): void { $api = new CrmApiV4(); $customer = $api->getCustomerOrNew(static::$info->hashcode); @@ -340,7 +340,7 @@ class CrmClientCustomerTest extends CrmClientTester * * @return void */ - public function testCustomerToggleOptin() + public function testCustomerToggleOptin(): void { $api = new CrmApiV4(); $customer = $api->getCustomerOrNew(static::$info->hashcode); @@ -359,11 +359,11 @@ class CrmClientCustomerTest extends CrmClientTester } /** - * test customer store + * Test customer store. * * @return void */ - public function testCustomerStoreProps() + public function testCustomerStoreProps(): void { $customer = new Customer(); @@ -385,11 +385,11 @@ class CrmClientCustomerTest extends CrmClientTester } /** - * test customer login + * Test customer login. * * @return void */ - public function testCustomerLogin() + public function testCustomerLogin(): void { $api = new CrmApiV4(); $customer = $api->getCustomerOrNew('toto.delarogerie@gmail.com'); @@ -404,7 +404,7 @@ class CrmClientCustomerTest extends CrmClientTester * * @return void */ - public function testCustomerLoginUsingCustomerfromAnotherBrand() + public function testCustomerLoginUsingCustomerfromAnotherBrand(): void { $this->expectException(ApiErrorException::class); $this->expectExceptionCode(ApiError::authFailed->value()); @@ -439,7 +439,7 @@ class CrmClientCustomerTest extends CrmClientTester * * @return void */ - public function testCustomerStorePropsFails() + public function testCustomerStorePropsFails(): void { $this->expectException(ValidationException::class); $customer = new Customer(); @@ -469,7 +469,7 @@ class CrmClientCustomerTest extends CrmClientTester * * @return void */ - public function testCustomerDelete() + public function testCustomerDelete(): void { $customer = new Customer(); @@ -496,13 +496,13 @@ class CrmClientCustomerTest extends CrmClientTester } /** - * Make sute a customer exists and contains data + * Make sute a customer exists and contains data. * * @param array $data * @param \App\Models\Brand $brand * @return void */ - private function createNewCustomer(array $data, Brand $brand) + private function createNewCustomer(array $data, Brand $brand): void { $customer = \App\Models\Customer::whereEmail($data['email']) ->whereHas('brands', function ($q) use ($brand) { diff --git a/tests/Client/CrmClientQuestionTest.php b/tests/Client/CrmClientQuestionTest.php index f0fdee9..95f0a13 100644 --- a/tests/Client/CrmClientQuestionTest.php +++ b/tests/Client/CrmClientQuestionTest.php @@ -12,11 +12,11 @@ use LDC\LDCCRM\Models\Question; class CrmClientQuestionTest extends CrmClientTester { /** - * Get All Questions + * Get all questions. * * @return void */ - public function testGetAllQuestions() + public function testGetAllQuestions(): void { $questions = Question::all(); $this->assertIsArray($questions, 'Should have returned an array'); @@ -38,11 +38,11 @@ class CrmClientQuestionTest extends CrmClientTester * * @return void */ - public function testJsonSerialize() + public function testJsonSerialize(): void { $questions = Question::all(); $this->assertIsArray($questions); - $this->assertTrue((bool)count($questions)); + $this->assertTrue((bool) count($questions)); foreach ($questions as $question) { $jsonDecoded = \json_decode(\json_encode($question), true); $this->assertArrayHasKey('id', $jsonDecoded); @@ -64,11 +64,11 @@ class CrmClientQuestionTest extends CrmClientTester } /** - * Get all question with user answers + * Get all question with user answers. * * @return void */ - public function testGetAllQuestionsWithCustomerAnswers() + public function testGetAllQuestionsWithCustomerAnswers(): void { /** @var \App\Models\Question $answeredQuestion */ $answeredQuestion = ModelsQuestion::whereHas('brand', function ($q) { @@ -127,11 +127,11 @@ class CrmClientQuestionTest extends CrmClientTester } /** - * Get all unanswered questions + * Get all unanswered questions. * * @return void */ - public function testGetAllCustomerUnAnsweredQuestions() + public function testGetAllCustomerUnAnsweredQuestions(): void { /** @var \App\Models\Question $answeredQuestion */ $answeredQuestion = ModelsQuestion::whereHas('brand', function ($q) { @@ -179,7 +179,7 @@ class CrmClientQuestionTest extends CrmClientTester * * @return void */ - public function testSubmitCustomerAnswer() + public function testSubmitCustomerAnswer(): void { /** @var \App\Models\Question $answeredQuestion */ $answeredQuestion = ModelsQuestion::whereHas('brand', function ($q) { @@ -224,11 +224,11 @@ class CrmClientQuestionTest extends CrmClientTester } /** - * Test unansweredBy + * Test to get all customer unanswered questions should not contain first. * * @return void */ - public function testGetAllCustomerUnansweredQuestionsShouldNotContainFirst() + public function testGetAllCustomerUnansweredQuestionsShouldNotContainFirst(): void { $unWantedQuestion = Question::all()[0]; @@ -242,11 +242,11 @@ class CrmClientQuestionTest extends CrmClientTester } /** - * test allWithCustomerAnswers + * Test all with customer answers. * * @return void */ - public function testGetAllQuestionsWithCustomerAnswersShouldHaveAnswers() + public function testGetAllQuestionsWithCustomerAnswersShouldHaveAnswers(): void { $api = new CrmApiV4(); $customer = $api->getCustomerOrNew(static::$info->hashcode); diff --git a/tests/Client/CrmClientSingleOptinTest.php b/tests/Client/CrmClientSingleOptinTest.php index 27085e6..1368aa2 100644 --- a/tests/Client/CrmClientSingleOptinTest.php +++ b/tests/Client/CrmClientSingleOptinTest.php @@ -15,12 +15,12 @@ class CrmClientSingleOptinTest extends CrmClientTester private $email = 'singleoptin@hotmail.fr'; /** - * Create and remove single optin test + * Create and remove single optin test. * Calling multiple times single optin true should not fail. * * @return void */ - public function testCreateAndRemoveSingleOptin() + public function testCreateAndRemoveSingleOptin(): void { // Set single optin and check. $this->assertTrue(SingleOptin::setStatus($this->email, true)); @@ -63,13 +63,12 @@ class CrmClientSingleOptinTest extends CrmClientTester } /** - * Remove single optin with hashcode test - * + * Remove single optin with hashcode test. * Calling multiple times single optin true should not fail. * * @return void */ - public function testRemoveSingleOptinWithHashcode() + public function testRemoveSingleOptinWithHashcode(): void { // Set single optin and check. $this->assertTrue(SingleOptin::setStatus($this->email, true)); diff --git a/tests/Client/CrmClientStatsTest.php b/tests/Client/CrmClientStatsTest.php index 39e16e6..5b8b649 100644 --- a/tests/Client/CrmClientStatsTest.php +++ b/tests/Client/CrmClientStatsTest.php @@ -12,11 +12,11 @@ use LDC\LDCCRM\Models\Stats; class CrmClientStatsTest extends CrmClientTester { /** - * Get stats by brand + * Get stats by brand. * * @return void */ - public function testStatsByBrand() + public function testStatsByBrand(): void { $start = Carbon::now()->subMonths(3); $end = Carbon::now(); @@ -49,7 +49,7 @@ class CrmClientStatsTest extends CrmClientTester * @return void * @throws \LDC\LDCCRM\Exceptions\ApiErrorException Because end date is before start date. */ - public function testStatsByBrandShouldFailIfStartDateIsAfterEndDate() + public function testStatsByBrandShouldFailIfStartDateIsAfterEndDate(): void { $this->expectException(ApiErrorException::class); $start = Carbon::now(); @@ -72,7 +72,7 @@ class CrmClientStatsTest extends CrmClientTester * @return void * @throws \LDC\LDCCRM\Exceptions\ApiErrorException Because interval is bigger thatn 3 months. */ - public function testStatsByBrandShouldFailIfIntervalIsMoreThanThreeMonths() + public function testStatsByBrandShouldFailIfIntervalIsMoreThanThreeMonths(): void { $this->expectException(ApiErrorException::class); $start = Carbon::now()->subMonths(3)->subDay(); @@ -94,7 +94,7 @@ class CrmClientStatsTest extends CrmClientTester * * @return void */ - public function testStatsByQuestion() + public function testStatsByQuestion(): void { /** @var \App\Models\Question $question */ $question = Question::where('brand_id', self::$brand->id)->first(); @@ -128,7 +128,7 @@ class CrmClientStatsTest extends CrmClientTester * * @return void */ - public function testStatsByQuestionShouldFailIfQuestionDoesNotBelongsToBrand() + public function testStatsByQuestionShouldFailIfQuestionDoesNotBelongsToBrand(): void { $this->expectException(ApiErrorException::class); /** @var \App\Models\Question $question */ @@ -150,7 +150,7 @@ class CrmClientStatsTest extends CrmClientTester * * @return void */ - public function testStatsByQuestionShouldFailIfStartDateIsAfterEndDate() + public function testStatsByQuestionShouldFailIfStartDateIsAfterEndDate(): void { $this->expectException(ApiErrorException::class); /** @var \App\Models\Question $question */ @@ -172,7 +172,7 @@ class CrmClientStatsTest extends CrmClientTester * * @return void */ - public function testStatsByQuestionShouldFailIfIntervalIsMoreThanThreeMonths() + public function testStatsByQuestionShouldFailIfIntervalIsMoreThanThreeMonths(): void { $this->expectException(ApiErrorException::class); /** @var \App\Models\Question $question */ diff --git a/tests/Client/CrmClientTester.php b/tests/Client/CrmClientTester.php index ec329a7..fe32496 100644 --- a/tests/Client/CrmClientTester.php +++ b/tests/Client/CrmClientTester.php @@ -53,7 +53,7 @@ abstract class CrmClientTester extends BaseTestCase } /** - * Get customer + * Get customer. * * @param boolean $status * @return array @@ -78,7 +78,7 @@ abstract class CrmClientTester extends BaseTestCase } /** - * Parse routes.json and return routes list + * Parse routes.json and return routes list. * * @return array */ diff --git a/tests/Client/HelperTest.php b/tests/Client/HelperTest.php index c07bc07..70f585d 100644 --- a/tests/Client/HelperTest.php +++ b/tests/Client/HelperTest.php @@ -13,44 +13,44 @@ class HelperTest extends TestCase use CreatesApplication; /** - * Helper::getRoute test + * Helper::getRoute test. * * @return void */ - public function testGetRoute() + public function testGetRoute(): void { $request = $this->makeRequest('apiV4.ping'); $this->assertInstanceOf(\Illuminate\Routing\Route::class, Helper::getRoute($request)); } /** - * Helper::getRoutePrefix test + * Helper::getRoutePrefix test. * * @return void */ - public function testGetRoutePrefix() + public function testGetRoutePrefix(): void { $request = $this->makeRequest('apiV4.ping'); $this->assertEquals($request->route()->getPrefix(), Helper::getRoutePrefix($request)); } /** - * Helper::getRouteName test + * Helper::getRouteName test. * * @return void */ - public function testGetRouteName() + public function testGetRouteName(): void { $request = $this->makeRequest('apiV4.ping'); $this->assertEquals($request->route()->getName(), Helper::getRouteName($request)); } /** - * Helper::isRequestForApiV4 test + * Helper::isRequestForApiV4 test. * * @return void */ - public function testIsRequestForApiV4() + public function testIsRequestForApiV4(): void { $request = $this->makeRequest('apiV4.ping'); $this->assertTrue(Helper::isRequestForApiV4($request)); @@ -62,7 +62,7 @@ class HelperTest extends TestCase * @param string $nameOrAction * @return \Illuminate\Http\Request */ - private function makeRequest(string $nameOrAction): Request + private function makeRequest(string $nameOrAction): \Illuminate\Http\Request { $route = Route::getRoutes()->getByName($nameOrAction) ?? Route::getRoutes()->getByAction($nameOrAction); $request = new Request([], [], [], [], [], ['REQUEST_URI' => $route->uri()]); diff --git a/tests/Client/UtilsTest.php b/tests/Client/UtilsTest.php index 1b3f52d..3a0a2fe 100644 --- a/tests/Client/UtilsTest.php +++ b/tests/Client/UtilsTest.php @@ -9,11 +9,11 @@ use Tests\TestCase; class UtilsTest extends TestCase { /** - * Test Utils validator + * Test utils validator. * * @return void */ - public function testUtilsValidator() + public function testUtilsValidator(): void { $this->expectNotToPerformAssertions(); Utils::makeValidator([ @@ -36,7 +36,7 @@ class UtilsTest extends TestCase 'bool' => true ], ['bool' => 'bool'])(); Utils::makeValidator([ - 'uuid' => (string)Str::uuid() + 'uuid' => (string) Str::uuid() ], ['uuid' => 'uuid|string'])(); Utils::makeValidator([ 'date' => date('Y-m-d') diff --git a/tests/StressTest/RunMultipleRequestsTest.php b/tests/StressTest/RunMultipleRequestsTest.php index b72077c..ff2bab6 100644 --- a/tests/StressTest/RunMultipleRequestsTest.php +++ b/tests/StressTest/RunMultipleRequestsTest.php @@ -57,7 +57,7 @@ class RunMultipleRequestsTest extends TestCase public function testSpamSingleOptin(): void { for ($i = 35; $i >= 0; $i--) { - $this->assertTrue(SingleOptin::setStatus('singleoptinteststress@gmail.com', (bool)rand(0, 1))); + $this->assertTrue(SingleOptin::setStatus('singleoptinteststress@gmail.com', (bool) rand(0, 1))); } }