diff --git a/Backend/.php-cs-fixer.cache b/Backend/.php-cs-fixer.cache deleted file mode 100644 index fec2eeb..0000000 --- a/Backend/.php-cs-fixer.cache +++ /dev/null @@ -1 +0,0 @@ -{"php":"8.2.12","version":"3.64.0:v3.64.0#58dd9c931c785a79739310aef5178928305ffa67","indent":" ","lineEnding":"\n","rules":{"no_whitespace_before_comma_in_array":true,"array_indentation":true,"trim_array_spaces":true,"whitespace_after_comma_in_array":true,"array_syntax":{"syntax":"short"},"php_unit_method_casing":true,"function_to_constant":true,"explicit_indirect_variable":true,"single_class_element_per_statement":{"elements":["const","property"]},"new_with_parentheses":true,"class_definition":{"single_line":true},"standardize_increment":true,"self_accessor":true,"magic_constant_casing":true,"no_useless_else":true,"ordered_class_elements":{"order":["use_trait","case","constant_public","constant_protected","constant_private","property_public","property_protected","property_private","construct","destruct","magic","phpunit","property_public_static","method_public_static","method_public","property_protected_static","method_protected_static","method_protected","property_private_static","method_private_static","method_private"]},"no_trailing_whitespace_in_comment":true,"phpdoc_trim_consecutive_blank_line_separation":true,"phpdoc_trim":true,"no_empty_phpdoc":true,"phpdoc_no_empty_return":true,"phpdoc_indent":true,"phpdoc_types":true,"phpdoc_return_self_reference":true,"phpdoc_var_without_name":true,"no_superfluous_phpdoc_tags":{"remove_inheritdoc":true,"allow_mixed":true},"php_unit_test_annotation":true,"php_unit_set_up_tear_down_visibility":true,"blank_line_after_opening_tag":true,"method_chaining_indentation":true,"concat_space":{"spacing":"one"},"binary_operator_spaces":{"operators":{"=>":"single_space","=":"single_space","&":"no_space"}},"single_trait_insert_per_statement":true,"no_blank_lines_after_class_opening":true,"no_singleline_whitespace_before_semicolons":true,"phpdoc_single_line_var_spacing":true,"no_leading_namespace_whitespace":true,"no_spaces_around_offset":true,"no_whitespace_in_blank_line":true,"return_type_declaration":true,"space_after_semicolon":true,"ternary_operator_spaces":true,"method_argument_space":true,"strict_comparison":true,"is_null":true,"strict_param":true,"no_unused_imports":true,"no_empty_statement":true,"no_unneeded_control_parentheses":true,"no_unneeded_braces":true,"declare_strict_types":true,"cast_spaces":{"space":"none"},"Blumilk\/double_quote":true,"void_return":true,"use_arrow_functions":true,"fully_qualified_strict_types":{"import_symbols":true},"ordered_imports":{"sort_algorithm":"alpha","imports_order":["class","function","const"]},"phpdoc_line_span":{"const":"single","property":"single"},"general_phpdoc_annotation_remove":{"annotations":["package","author"]},"no_extra_blank_lines":{"tokens":["attribute","break","case","continue","curly_brace_block","default","extra","parenthesis_brace_block","return","square_brace_block","switch","throw","use"]},"trailing_comma_in_multiline":{"elements":["arrays","parameters","arguments","match"]},"nullable_type_declaration_for_default_null_value":true,"PhpCsFixerCustomFixers\/constructor_empty_braces":true,"PhpCsFixerCustomFixers\/multiline_promoted_properties":true,"PhpCsFixerCustomFixers\/no_useless_comment":true,"PhpCsFixerCustomFixers\/phpdoc_array_style":true,"PhpCsFixerCustomFixers\/promoted_constructor_property":true,"PhpCsFixerCustomFixers\/single_space_after_statement":true,"PhpCsFixerCustomFixers\/single_space_before_statement":true,"PhpCsFixerCustomFixers\/stringable_interface":true,"visibility_required":true,"no_leading_import_slash":true,"lowercase_cast":true,"lowercase_static_reference":true,"compact_nullable_type_declaration":true,"declare_equal_normalize":true,"short_scalar_cast":true,"clean_namespace":true,"unary_operator_spaces":true,"class_attributes_separation":{"elements":{"property":"none","const":"none","method":"one","trait_import":"none","case":"none"}},"PhpCsFixerCustomFixers\/no_useless_parenthesis":true,"single_blank_line_at_eof":true,"Blumilk\/no_laravel_migrations_generated_comments":true,"PhpCsFixerCustomFixers\/commented_out_function":{"functions":["print_r","var_dump","var_export","dd"]},"PhpCsFixerCustomFixers\/no_commented_out_code":true,"PhpCsFixerCustomFixers\/no_php_storm_generated_comment":true,"PhpCsFixerCustomFixers\/phpdoc_no_incorrect_var_annotation":true,"PhpCsFixerCustomFixers\/phpdoc_no_superfluous_param":true,"yoda_style":{"equal":false,"identical":false,"less_and_greater":false},"object_operator_without_whitespace":true,"function_declaration":{"closure_function_spacing":"none","closure_fn_spacing":"none"},"single_line_after_imports":true,"single_line_comment_spacing":true,"blank_line_after_namespace":true,"simple_to_complex_string_variable":true,"no_empty_comment":true,"no_trailing_comma_in_singleline":true,"magic_method_casing":true,"native_function_casing":true,"lambda_not_used_import":true,"no_homoglyph_names":true,"assign_null_coalescing_to_coalesce_equal":true,"no_useless_nullsafe_operator":true,"no_useless_return":true,"simplified_null_return":true,"multiline_whitespace_before_semicolons":true,"line_ending":true,"statement_indentation":true,"blank_line_between_import_groups":true,"blank_line_before_statement":{"statements":["break","continue","declare","return","throw","try","if","do","for","foreach","while"]},"no_multiple_statements_per_line":true,"blank_lines_before_namespace":true,"psr_autoloading":true,"type_declaration_spaces":true,"control_structure_braces":true,"control_structure_continuation_position":true,"braces_position":{"anonymous_functions_opening_brace":"same_line"},"lowercase_keywords":true,"no_multiline_whitespace_around_double_arrow":true,"Blumilk\/compact_empty_array":true,"Blumilk\/class_keyword_fixer":true,"Blumilk\/named_arguments":true,"no_blank_lines_after_phpdoc":true,"constant_case":true,"php_unit_attributes":true,"spaces_inside_parentheses":true},"hashes":{"storage\\framework\\views\\9bf0bf855bc13e16750e2a5e36744ca4.php":"e5844427b776eb699d5ec89f44d3e2ce","database\\migrations\\2024_10_16_105416_create_kebabs_table.php":"1e355493c4cc9272fb4c67c2e6ba96c4","database\\migrations\\2024_10_16_110140_create_suggestions_table.php":"dcd28a096eb6ad324c7a7d79673a4e3f","database\\seeders\\DatabaseSeeder.php":"b82d88332bc59876a3e674a5fc2a8d8b","public\\index.php":"dd9420d1946e6f5ac53594066ed21bcd","resources\\views\\mail\\contactUsMail.blade.php":"2e5a0f145b80848cb5b1c643b0b6e2f2","resources\\views\\welcome.blade.php":"7c20c7ebc3218c403dea71117f69dfed","routes\\api.php":"91da4672c7a81bfecd52f75776c26414","routes\\channels.php":"69224ae3142ba715c9a88ab51ebb0f2a","routes\\console.php":"e8ec20fcf9db2c8ed133bd71f541959b","routes\\web.php":"622624c7aa262186fec4dfff56aa46ed","tests\\CreatesApplication.php":"547b076015f8c5a1bb558b7b1d3d8548","tests\\Feature\\ExampleTest.php":"cbc86ef604b670eff5077c52ba43cff3","tests\\TestCase.php":"b9ad5821823c481100f73431178caa71","tests\\Unit\\ExampleTest.php":"1892966e6e20f3cd936dcfa4ed7275eb","codestyle.php":"78106c01bb6c67815aad1f58ec44cd0d","config\\app.php":"9fc6583a7668465151943600476ea442","config\\auth.php":"a488b0d57431b546548feb34edccd48e","config\\broadcasting.php":"c72d877f6c2bc0726fb9a1e717fd62c8","config\\cache.php":"ef8901d79de3b0790253c5a96d0e4ca6","config\\cors.php":"584b47b3b8a04d20e28ec711f88871b0","app\\Http\\Middleware\\TrimStrings.php":"6fc714347e06b50092ab8ed32dde44a3","app\\Http\\Middleware\\TrustHosts.php":"296d5025e64924ad380db403db212e03","app\\Http\\Middleware\\TrustProxies.php":"6ef300cb0fa4760b0b78eeed4b562487","app\\Http\\Middleware\\ValidateSignature.php":"a3b8b6a39e865b98596215de1d2b1b49","app\\Http\\Middleware\\VerifyCsrfToken.php":"ec90d977fba72bf47b36209750f6c309","app\\Http\\Requests\\LoginRequest.php":"2e4b5eb1f7e96522fc6606563bc153c9","app\\Http\\Requests\\SignupRequest.php":"64d40c6fb14d7f0f4416f4fc65077af2","app\\Http\\Requests\\UserRequest.php":"9924fb264e27913626e84ac5caab2c2f","app\\Models\\User.php":"804b578c498bc1a16659ba94c7e4ae4b","app\\Providers\\AppServiceProvider.php":"1ec4db88d3552a5250b23a5730a20185","app\\Console\\Kernel.php":"f7036533db76cf5f2180e942e3a51ebb","app\\Exceptions\\Handler.php":"51a92074c25f79602e1d88bab27cc6f5","app\\Http\\Controllers\\AuthController.php":"da2847a9a182eaec1d125b2d91bc0d42","app\\Http\\Controllers\\Controller.php":"3cd28b4b4ae4d9fa3300376350c2751c","app\\Http\\Controllers\\UserController.php":"a435c4286a2532f277def2023df7c315","app\\Http\\Kernel.php":"dd78ef286f08e779169ef79df8cbd150","app\\Http\\Middleware\\Authenticate.php":"c5c9966ed056b0c30c346e4e1ed6de52","app\\Http\\Middleware\\EncryptCookies.php":"fba0599e278cebd030c54270cf855686","app\\Http\\Middleware\\PreventRequestsDuringMaintenance.php":"bc36f9173ef40b9ed9e334466863d3cd","app\\Http\\Middleware\\RedirectIfAuthenticated.php":"bbf6fd4f1eee7db7212ccf467071910c","config\\database.php":"40d5122ad3be69b8da2be286baeb8a52","config\\filesystems.php":"0832e73395b006321f46a83ccedb3ccc","config\\hashing.php":"d00fd9ca9075c4ea6f6ad22ce52b3270","config\\logging.php":"555f0f96051df392fdf8eb228343fed7","config\\mail.php":"9eaf706909d67b21ba11906c18188479","config\\queue.php":"3602debf67f71c07e7448b9411146a5f","config\\sanctum.php":"a7d069d5340bf31bb697bff3fc71a969","config\\services.php":"58f64381ee639c666aa976be791e36e7","config\\session.php":"3e81cc78f6b54d08b7ffcaf100e6ce57","config\\view.php":"b06ef698da6be2f1214571bb4c4a311e","app\\Providers\\AuthServiceProvider.php":"9235162bfd5da878db7470e4c479451d","app\\Providers\\BroadcastServiceProvider.php":"06e096a7dbb308964951af17f6ea190c","app\\Providers\\EventServiceProvider.php":"b46c5ca9cef8dd7cb86250582c4dd6e0","app\\Providers\\RouteServiceProvider.php":"b178ac899e4b1c45d5672f07762590b8","bootstrap\\app.php":"5e869cd81ba78c305abc18d334c0cba2","bootstrap\\cache\\packages.php":"4729b9b7c89ffdcef02efc391e29d3e9","bootstrap\\cache\\services.php":"a7ef73ba590bbdc8deb767a8f3d6aab3","database\\factories\\UserFactory.php":"529ff335b3146262e3d23374ed56a8bd","database\\migrations\\0001_01_01_000000_create_users_table.php":"e6563bc95e78a8c535ce12e4442eaaf8","database\\migrations\\2019_12_14_000001_create_personal_access_tokens_table.php":"56cb4a268545b0e74d68c8aced1f58e3","storage\\framework\\views\\967092ef3e1507558668863e9463f057.php":"71d1d2804f69c88121eb63e827f0de83","storage\\framework\\views\\f4aff3de51c6874079719f39e969bfb7.php":"2673d1d0efb6de66fc933b875221563e","app\\Models\\Kebab.php":"fcdf01f9d18b9a53ee7c6be0d604c799","app\\Http\\Controllers\\KebabController.php":"5071168a7fd3eeaf2c1d90c4fcc627c3","app\\Http\\Middleware\\CheckAdmin.php":"bfbf273b33fdacb20f8577ad9748a8fc","app\\Http\\Requests\\ChangeEmailRequest.php":"70916b29c6e0aadd102159dc4cad920d","app\\Http\\Requests\\ChangeNameRequest.php":"5cb6eef366a99592a09d7b3ee1f98517","app\\Http\\Requests\\ChangePasswordRequest.php":"65da5c250cf407ebdead62c0a202d4e1","app\\Http\\Requests\\FavoriteKebabRequest.php":"5ce9e715b9cc3209e32cf9cd88b993d6","app\\Http\\Requests\\KebabRequests\\KebabRequest.php":"a2f7670c140e6b02e608b748e0a44cb1","app\\Http\\Controllers\\SuggestionsController.php":"443647e36b95f95002de7e0ca9e2e20d","app\\Models\\Suggestions.php":"dc615d61c486362961ac6b5759735a7c","app\\Http\\Requests\\UserRequests\\UserRequest.php":"e93fdf35b2e521d2b02a23664ded82e3","app\\Http\\Requests\\SuggestionRequest.php":"28832169adb92ccb25e8c62e090f04e5","app\\Http\\Requests\\UserRequests\\ChangeEmailRequest.php":"96acb58486b9bfc2d5d0e871f97d7e07","app\\Http\\Requests\\UserRequests\\ChangeNameRequest.php":"3de895405d2aba7f262fcf39fe48c16b","app\\Http\\Requests\\UserRequests\\ChangePasswordRequest.php":"55f7d4be9b989cf3781dc91a3c0c1dff","app\\Http\\Requests\\UserRequests\\FavoriteKebabRequest.php":"c9c04478f6be56243a4db1ea2a0e4fc4","tests\\Feature\\AuthControllerTest.php":"60def14d559fbc5969ca0dd43bba1020","app\\Http\\Controllers\\GoogleScraperController.php":"de8ae9535538ef7664559b2e3cebb12d","app\\Services\\GoogleScraper.php":"f6e5adad52184bce6d8f064868b4f3be","config\\l5-swagger.php":"933a221eeb784e9243d4c94531a8d40a","app\\Http\\Requests\\UserRequests\\ChangeUserRoleRequest.php":"0ec918f5e4c570ba8fd9db66d1de610a","resources\\views\\vendor\\l5-swagger\\index.blade.php":"5c07239178c67784c1ce65d0261c3cfb","storage\\framework\\views\\3f4a2a5117a095683b4bd4f4817cdd7e.php":"b0d3aaf049ae81da1627ad4a870c9408","app\\Http\\Requests\\KebabRequests\\KebabIsChainstoreRequest.php":"65ebf250f36e3a274d22c16b4dd791b4","app\\Http\\Requests\\KebabRequests\\KebabIsCraftedRequest.php":"381b102d9c9580c2d513531a7467dd3b","app\\Http\\Requests\\KebabRequests\\KebabIsPremisesRequest.php":"f8767ea5fa7565e29386cfa3cb324b56","app\\Http\\Requests\\KebabRequests\\KebabMeatRequest.php":"b9c006d775847fae4d10429f47342a93","app\\Http\\Requests\\KebabRequests\\KebabNameRequest.php":"0da0b3a32ef0c82df40f2e8f6c1c0fee","app\\Http\\Requests\\KebabRequests\\KebabOpeningHourRequest.php":"ab573d1cdc8dc61a5a35c3b4ff0c9012","app\\Http\\Requests\\KebabRequests\\KebabOpeningYearRequest.php":"bb638d93a94e75490ebfabf248cb69b9","app\\Http\\Requests\\KebabRequests\\KebabOrderingOptionRequest.php":"ed527e4eb517950688b22ad6303d9e8c","app\\Http\\Requests\\KebabRequests\\KebabPageRequest.php":"014b90a00819d4440cb3e749e28f2eb3","app\\Http\\Requests\\KebabRequests\\KebabRemoveOpeningHourRequest.php":"00b961233ee7a2d01eacbeeb1fd64aeb","storage\\framework\\views\\6c885b58304fbc4e2aec93b32e21e7d9.php":"b19e8caccdfc6bd8b1e7e830f5e1d73a","storage\\framework\\views\\7ad1c4a57fd20667e171684a776a6a4b.php":"821b94ab7733ebb96e50e1ad1433d626","storage\\framework\\views\\8db7a9c997446847b068860e72051f3f.php":"8edde35264218afe04804880f3021cb9","storage\\framework\\views\\92c61c37d62d309b2261696533623f0e.php":"feedb36e617bd932aee32f5245a5785d","storage\\framework\\views\\ab38df06e69f67dc01873ae179e9d8ac.php":"00b4d8ea20981e02df7d3a8b4ebc0069","storage\\framework\\views\\e5e9ac36fad87cbd2f3251ed9abe7296.php":"a1b239be85267d69c41a467c0f831f77","storage\\framework\\views\\06147b58b27e243b8a91117bcb2e7c76.php":"df03083fa4992a953a9adb33f86db636","storage\\framework\\views\\09d4d7244749dd8974944448cf2bf96f.php":"eb8405a6435c6d8e056d02342db1778f","storage\\framework\\views\\39b6db6ec59539b2c5045f87bed7448a.php":"1140a46aa1a4c1796bd0bf02b1131dbb","storage\\framework\\views\\533535455bececf37749798130da41bd.php":"74d47637030959bfde388944831898d9","storage\\framework\\views\\536ae9e7a221fbfbb57822904ba3aacd.php":"216b289ad08ab01d8a8753234c53796f","storage\\framework\\views\\5ed5e5b51be7b3cfa9851b0e60f8238d.php":"9993f6fb33357d32079c929de0a6c877","storage\\framework\\views\\643935d0d2475a73239c913510676f7a.php":"779fa58ac9e55d40597198c9a67c24fd","storage\\framework\\views\\6468ca2f48adc9c1058f7b5eba9629cd.php":"3cbe9f7c4e9bc14ec04ad4115e6dfcd8","config\\scribe.php":"b6c71b001f3da9b58b724528d6f00970","app\\Http\\Controllers\\KebabScraperController.php":"fa440530a00c1119560417d1e0d6fa00","app\\Http\\Requests\\KebabRequests\\KebabAddressRequest.php":"3fc80132ea0e01f7c599142a0713a32b","app\\Http\\Requests\\KebabRequests\\KebabClosingYearRequest.php":"a6c42ed5a33b0ca0149967228e4be2a9","app\\Http\\Requests\\KebabRequests\\KebabCommentRequest.php":"0315ce8a66bdb7e4d6923e5054f5ec7a","app\\Http\\Requests\\KebabRequests\\KebabCoordinatesRequest.php":"5f338ef5344cb8ed68e436f259db9eaa","app\\Http\\Requests\\KebabRequests\\KebabRemoveOrderingOptionRequest.php":"6be6e425d50113dbe68d31d43f3dceec","app\\Http\\Requests\\KebabRequests\\KebabStatusRequest.php":"6a95b56abfed7dcff01626258dff65e8","app\\Http\\Requests\\KebabRequests\\SauceKebabRequest.php":"a6db49ff8865a674e765f0375afdf96e","app\\Services\\PyszneScraper.php":"21286caf798b637455a2996ac278d24c","database\\seeders\\KebabSeeder.php":"165fb3475df8388da617cd92d5aa292d"}} \ No newline at end of file diff --git a/Backend/app/Http/Controllers/KebabController.php b/Backend/app/Http/Controllers/KebabController.php index b9099ee..414c74b 100644 --- a/Backend/app/Http/Controllers/KebabController.php +++ b/Backend/app/Http/Controllers/KebabController.php @@ -72,8 +72,6 @@ public function getAllKebabs() public function addKebab(KebabRequest $request) { - $data = $request->validated(); - try { $kebab = new Kebab($request->all()); diff --git a/Backend/app/Http/Requests/KebabRequests/KebabRequest.php b/Backend/app/Http/Requests/KebabRequests/KebabRequest.php index 542e307..dd41cef 100644 --- a/Backend/app/Http/Requests/KebabRequests/KebabRequest.php +++ b/Backend/app/Http/Requests/KebabRequests/KebabRequest.php @@ -24,7 +24,7 @@ public function authorize(): bool public function rules(): array { return [ - "logo" => "required", + "logo" => "required|file|image|mimes:jpeg,png,jpg,gif|max:10240", "name" => "required", "address" => "required|string|max:255", "coordinates" => "required|array", diff --git a/Backend/database/factories/KebabFactory.php b/Backend/database/factories/KebabFactory.php new file mode 100644 index 0000000..5be3402 --- /dev/null +++ b/Backend/database/factories/KebabFactory.php @@ -0,0 +1,42 @@ + $this->faker->imageUrl(), + "name" => $this->faker->company, + "address" => $this->faker->address, + "coordinates" => json_encode([ + ["lat" => $this->faker->latitude, "lng" => $this->faker->longitude], + ]), + "sauces" => json_encode([$this->faker->word, $this->faker->word]), + "meats" => json_encode([$this->faker->word, $this->faker->word]), + "status" => $this->faker->randomElement(["exists", "closed", "planned"]), + "opening_hours" => json_encode([ + ["day" => "monday", "hours" => "10:00-20:00"], + ["day" => "tuesday", "hours" => "10:00-20:00"], + ]), + "opening_year" => $this->faker->year(), + "closing_year" => $this->faker->optional()->year(), + "is_crafted" => $this->faker->boolean, + "is_premises" => $this->faker->boolean, + "is_chainstore" => $this->faker->boolean, + "ordering_options" => $this->faker->randomElement(["delivery", "pickup"]), + "pages" => json_encode([ + "pyszne.pl" => $this->faker->url, + "ubereats" => $this->faker->url, + ]), + ]; + } +} diff --git a/Backend/routes/api.php b/Backend/routes/api.php index c3f7806..a6e327d 100644 --- a/Backend/routes/api.php +++ b/Backend/routes/api.php @@ -40,8 +40,6 @@ Route::delete("/kebabs/{kebabId}/comments", [KebabController::class, "removeComment"]); }); -Route::get("/documentation", fn() => view("vendor.scribe.index")); - Route::middleware(["auth:sanctum", "admin"])->group(function (): void { Route::put("/changeUserRole/{id}", [UserController::class, "changeUserRole"]); Route::delete("/deleteUser/{id}", [UserController::class, "deleteUser"]); diff --git a/Backend/tests/Arch/ModelArchTest.php b/Backend/tests/Arch/ModelArchTest.php index 3607b5f..216f921 100644 --- a/Backend/tests/Arch/ModelArchTest.php +++ b/Backend/tests/Arch/ModelArchTest.php @@ -1,11 +1,16 @@ expect('App\Models') ->toBeClasses() - ->toHaveSuffix('') - ->toExtend(\Illuminate\Database\Eloquent\Model::class); + ->toHaveSuffix("") + ->toExtend(Model::class); -arch('Kebab model should follow conventions') - ->expect('App\Models\Kebab') +arch("Kebab model should follow conventions") + ->expect(Kebab::class) ->toBeClasses(); diff --git a/Backend/tests/Arch/RequestsArchTest.php b/Backend/tests/Arch/RequestsArchTest.php index cd30911..3f3111f 100644 --- a/Backend/tests/Arch/RequestsArchTest.php +++ b/Backend/tests/Arch/RequestsArchTest.php @@ -1,17 +1,21 @@ expect('App\Http\Requests') ->toBeClasses() - ->toHaveSuffix('Request'); + ->toHaveSuffix("Request"); -arch('Kebab requests should be in thier folder') +arch("Kebab requests should be in thier folder") ->expect('App\Http\Requests\KebabRequests') ->toBeClasses() - ->toHaveSuffix('Request'); + ->toHaveSuffix("Request"); -arch('UserRequests should have proper architecture') +arch("UserRequests should have proper architecture") ->expect('App\Http\Requests\UserRequests') ->toBeClasses() - ->toHaveSuffix('Request') - ->toExtend(\Illuminate\Foundation\Http\FormRequest::class); \ No newline at end of file + ->toHaveSuffix("Request") + ->toExtend(FormRequest::class); diff --git a/Backend/tests/Feature/KebabControllerTest.php b/Backend/tests/Feature/KebabControllerTest.php new file mode 100644 index 0000000..8aadb9f --- /dev/null +++ b/Backend/tests/Feature/KebabControllerTest.php @@ -0,0 +1,147 @@ +admin = User::factory()->create([ + "email" => "admin@admin.pl", + "password" => Hash::make("admin"), + "isAdmin" => 1, + ]); + } + + public function testAdminCanUpdateKebabAddress(): void + { + $kebab = Kebab::factory()->create(); + $payload = ["address" => "New Address"]; + + $response = $this->actingAs($this->admin)->putJson("/api/kebabs/{$kebab->id}/address", $payload); + + $response->assertStatus(200); + $this->assertDatabaseHas("kebabs", ["id" => $kebab->id, "address" => "New Address"]); + } + + public function testAdminCanDeleteAKebab(): void + { + $kebab = Kebab::factory()->create(); + + $response = $this->actingAs($this->admin)->deleteJson("/api/kebabs/{$kebab->id}"); + + $response->assertStatus(200); + $this->assertDatabaseMissing("kebabs", ["id" => $kebab->id]); + } + + public function testAdminCanUpdateKebabCoordinates(): void + { + $kebab = Kebab::factory()->create(); + $payload = ["coordinates" => [["lat" => 51.0, "lng" => 21.0]]]; + + $response = $this->actingAs($this->admin)->putJson("/api/kebabs/{$kebab->id}/coordinates", $payload); + + $response->assertStatus(200); + $this->assertDatabaseHas("kebabs", ["id" => $kebab->id, "coordinates" => json_encode($payload["coordinates"])]); + } + + public function testAdminCanUpdateKebabStatus(): void + { + $kebab = Kebab::factory()->create(); + $payload = ["status" => "closed"]; + + $response = $this->actingAs($this->admin)->putJson("/api/kebabs/{$kebab->id}/status", $payload); + + $response->assertStatus(200); + $this->assertDatabaseHas("kebabs", ["id" => $kebab->id, "status" => "closed"]); + } + + public function testAdminCanUpdateKebabOpeningYear(): void + { + $kebab = Kebab::factory()->create(); + + $response = $this->actingAs($this->admin)->putJson("/api/kebabs/{$kebab->id}/opening-year", [ + "opening_year" => 2000, + ]); + + $response->assertStatus(200); + $this->assertDatabaseHas("kebabs", [ + "id" => $kebab->id, + "opening_year" => 2000, + ]); + } + + public function testAdminCanUpdateKebabClosingYear(): void + { + $kebab = Kebab::factory()->create(); + + $response = $this->actingAs($this->admin)->putJson("/api/kebabs/{$kebab->id}/closing-year", [ + "closing_year" => 2023, + ]); + + $response->assertStatus(200); + $this->assertDatabaseHas("kebabs", [ + "id" => $kebab->id, + "closing_year" => 2023, + ]); + } + + public function testAdminCanUpdateKebabIsCrafted(): void + { + $kebab = Kebab::factory()->create(); + + $response = $this->actingAs($this->admin)->putJson("/api/kebabs/{$kebab->id}/is-crafted", [ + "is_crafted" => true, + ]); + + $response->assertStatus(200); + $this->assertDatabaseHas("kebabs", [ + "id" => $kebab->id, + "is_crafted" => true, + ]); + } + + public function testAdminCanUpdateKebabIsPremises(): void + { + $kebab = Kebab::factory()->create(); + + $response = $this->actingAs($this->admin)->putJson("/api/kebabs/{$kebab->id}/is-premises", [ + "is_premises" => true, + ]); + + $response->assertStatus(200); + $this->assertDatabaseHas("kebabs", [ + "id" => $kebab->id, + "is_premises" => true, + ]); + } + + public function testAdminCanUpdateKebabIsChainstore(): void + { + $kebab = Kebab::factory()->create(); + + $response = $this->actingAs($this->admin)->putJson("/api/kebabs/{$kebab->id}/is-chainstore", [ + "is_chainstore" => true, + ]); + + $response->assertStatus(200); + $this->assertDatabaseHas("kebabs", [ + "id" => $kebab->id, + "is_chainstore" => true, + ]); + } +} diff --git a/Backend/tests/Feature/StresTest.php b/Backend/tests/Feature/StresTest.php index d79a110..e74f8a2 100644 --- a/Backend/tests/Feature/StresTest.php +++ b/Backend/tests/Feature/StresTest.php @@ -1,27 +1,28 @@ getJson('/api/kebabs'); + $response = $this->getJson("/api/kebabs"); - expect(in_array($response->status(), [200, 429])) + expect(in_array($response->status(), [200, 429], true)) ->toBeTrue("Unexpected status: {$response->status()}"); } }); - test('API rate limits requests correctly', function () { +test("API rate limits requests correctly", function (): void { $iterations = 100; $successfulResponses = 0; $rateLimitResponses = 0; for ($i = 0; $i < $iterations; $i++) { - $response = $this->getJson('/api/kebabs'); + $response = $this->getJson("/api/kebabs"); if ($response->status() === 200) { $successfulResponses++; diff --git a/Backend/tests/Pest.php b/Backend/tests/Pest.php index 50ab1e4..442ab49 100644 --- a/Backend/tests/Pest.php +++ b/Backend/tests/Pest.php @@ -1,5 +1,9 @@ in('Feature'); +)->in("Feature"); /* |-------------------------------------------------------------------------- @@ -27,9 +31,7 @@ | */ -expect()->extend('toBeOne', function () { - return $this->toBe(1); -}); +expect()->extend("toBeOne", fn() => $this->toBe(1)); /* |-------------------------------------------------------------------------- @@ -42,7 +44,7 @@ | */ -function something() +function something(): void { // .. }