From 85bbe4f47bb468d534a0f0a900ca73e48ec83edb Mon Sep 17 00:00:00 2001 From: Alexis Gousseau Date: Mon, 21 Oct 2024 12:01:23 +0200 Subject: [PATCH 1/8] feat: :white_check_mark: add uwil laravel unit tests --- .gitignore | 2 + README.md | 54 ++ app/Enums/Breeders/GeoType.php | 6 +- .../{EleveurOcbStatus.php => OCBStatus.php} | 10 +- app/Enums/Breeders/OCBType.php | 6 +- app/Enums/Breeders/PresentationType.php | 4 +- app/Enums/HistoricalMilestonePosition.php | 23 - .../HistoricalMilestonePosition.php | 23 + .../Controllers/Bo/DiscountController.php | 11 + .../StoreDemarcheSlideRequest.php | 8 +- .../StoreHistoricalMilestoneRequest.php | 45 +- .../Bo/MainSlides/StoreMainSlideRequest.php | 12 +- app/Jobs/DemarcheSlidesStatusUpdate.php | 16 +- app/Jobs/MainSlidesStatusUpdate.php | 24 +- app/Models/Breeder.php | 4 +- app/Models/DemarcheSlide.php | 38 +- app/Models/HistoricalMilestone.php | 35 +- app/Models/MainSlide.php | 32 +- app/Models/User.php | 53 +- app/Policies/DiscountPolicy.php | 11 + composer.json | 1 + composer.lock | 51 ++ config/mail.php | 6 +- config/unit-tests.php | 64 +++ database/factories/ActivityLogFactory.php | 32 ++ database/factories/ApproachFactory.php | 1 + database/factories/BrandAdvantageFactory.php | 2 + database/factories/BreederFactory.php | 40 +- database/factories/ClaimFactory.php | 2 +- .../factories/ConsumptionMomentFactory.php | 4 +- database/factories/DemarcheSlideFactory.php | 8 +- .../DepartaimantsCollectionFactory.php | 2 +- database/factories/DiscountFactory.php | 13 +- .../factories/HistoricalMilestoneFactory.php | 11 +- .../factories/IncoNutritionalValueFactory.php | 2 +- database/factories/KeyNumberFactory.php | 6 +- database/factories/MainSlideFactory.php | 11 +- database/factories/MeatFactory.php | 5 +- database/factories/MenuNodeDataFactory.php | 6 +- database/factories/NewsBreedingFactory.php | 2 + database/factories/NewsCategoryFactory.php | 2 + database/factories/NewsClubFactory.php | 2 + database/factories/NewsCorporateFactory.php | 1 + database/factories/NewsFactory.php | 2 + database/factories/OfferFactory.php | 4 +- database/factories/ProductFactory.php | 13 +- database/factories/ProductTypeFactory.php | 3 +- database/factories/ProfessionFactory.php | 5 +- database/factories/RangeFactory.php | 6 +- database/factories/RecipeFactory.php | 8 +- database/factories/SellItemFactory.php | 32 ++ database/factories/StaticPageFactory.php | 36 ++ database/factories/SubmeatFactory.php | 6 +- database/factories/SubrangeFactory.php | 6 +- database/factories/SurveysAnswerFactory.php | 3 +- database/factories/TestimonialFactory.php | 6 +- database/factories/UserFactory.php | 7 +- database/factories/VideoFactory.php | 3 +- ..._27_123912_alter_tables_for_unit_tests.php | 54 ++ phpunit.xml | 59 +-- resources/lang/en/validation.php | 1 + resources/lang/fr/validation.php | 1 + resources/sass/bo/pages/.gitkeep | 0 resources/sass/bo/partials/.gitkeep | 0 resources/views/bo/layouts/header.blade.php | 4 +- resources/views/bo/layouts/sidemenu.blade.php | 470 +++++++++--------- .../bo/pages/demarche_slides/form.blade.php | 16 +- .../bo/pages/discounts/index-list.blade.php | 8 +- .../views/bo/pages/discounts/show.blade.php | 82 +++ .../historical_milestones/form.blade.php | 40 +- .../views/bo/pages/main_slides/form.blade.php | 16 +- .../views/bo/pages/main_slides/show.blade.php | 18 +- resources/views/fo/pages/story.blade.php | 4 +- routes/breadcrumbs-bo.php | 5 + routes/web-bo.php | 2 +- tests/Back/ActivityLogTest.php | 76 +++ tests/Back/ApproachDemarcheTest.php | 227 +++++++++ tests/Back/ApproachLabelTest.php | 227 +++++++++ tests/Back/BrandAdvantageTest.php | 218 ++++++++ tests/Back/ClaimTest.php | 218 ++++++++ tests/Back/ConsumptionMomentTest.php | 218 ++++++++ tests/Back/DemarcheSlideTest.php | 218 ++++++++ tests/Back/DiscountTest.php | 76 +++ tests/Back/HistoricalMilestoneTest.php | 218 ++++++++ tests/Back/KeyNumberTest.php | 218 ++++++++ tests/Back/MainSlideTest.php | 218 ++++++++ tests/Back/MeatTest.php | 218 ++++++++ tests/Back/MenuNodeDataTest.php | 35 ++ tests/Back/NewsBreedingTest.php | 218 ++++++++ tests/Back/NewsCategoryTest.php | 218 ++++++++ tests/Back/NewsClubNewsTest.php | 227 +++++++++ tests/Back/NewsClubSurveyTest.php | 227 +++++++++ tests/Back/NewsCorporateTest.php | 218 ++++++++ tests/Back/NewsTest.php | 218 ++++++++ tests/Back/OfferTest.php | 218 ++++++++ tests/Back/ProductTest.php | 218 ++++++++ tests/Back/ProductTypeTest.php | 218 ++++++++ tests/Back/ProfessionTest.php | 218 ++++++++ tests/Back/RangeTest.php | 218 ++++++++ tests/Back/RecipeTest.php | 218 ++++++++ tests/Back/SellItemTest.php | 218 ++++++++ tests/Back/StaticPageTest.php | 91 ++++ tests/Back/SubmeatTest.php | 218 ++++++++ tests/Back/SubrangeTest.php | 218 ++++++++ tests/Back/SurveysAnswerTest.php | 218 ++++++++ tests/Back/TestimonialTest.php | 218 ++++++++ tests/Back/VideoTest.php | 218 ++++++++ tests/CreatesApplication.php | 9 +- tests/Feature/ExampleTest.php | 19 - tests/TestCase.php | 2 + tests/Unit/ExampleTest.php | 16 - 111 files changed, 7508 insertions(+), 567 deletions(-) rename app/Enums/Breeders/{EleveurOcbStatus.php => OCBStatus.php} (58%) delete mode 100644 app/Enums/HistoricalMilestonePosition.php create mode 100644 app/Enums/HistoricalMilestones/HistoricalMilestonePosition.php create mode 100644 config/unit-tests.php create mode 100644 database/factories/ActivityLogFactory.php create mode 100644 database/factories/SellItemFactory.php create mode 100644 database/factories/StaticPageFactory.php create mode 100644 database/migrations/2024_21_27_123912_alter_tables_for_unit_tests.php delete mode 100644 resources/sass/bo/pages/.gitkeep delete mode 100644 resources/sass/bo/partials/.gitkeep create mode 100644 resources/views/bo/pages/discounts/show.blade.php create mode 100644 tests/Back/ActivityLogTest.php create mode 100644 tests/Back/ApproachDemarcheTest.php create mode 100644 tests/Back/ApproachLabelTest.php create mode 100644 tests/Back/BrandAdvantageTest.php create mode 100644 tests/Back/ClaimTest.php create mode 100644 tests/Back/ConsumptionMomentTest.php create mode 100644 tests/Back/DemarcheSlideTest.php create mode 100644 tests/Back/DiscountTest.php create mode 100644 tests/Back/HistoricalMilestoneTest.php create mode 100644 tests/Back/KeyNumberTest.php create mode 100644 tests/Back/MainSlideTest.php create mode 100644 tests/Back/MeatTest.php create mode 100644 tests/Back/MenuNodeDataTest.php create mode 100644 tests/Back/NewsBreedingTest.php create mode 100644 tests/Back/NewsCategoryTest.php create mode 100644 tests/Back/NewsClubNewsTest.php create mode 100644 tests/Back/NewsClubSurveyTest.php create mode 100644 tests/Back/NewsCorporateTest.php create mode 100644 tests/Back/NewsTest.php create mode 100644 tests/Back/OfferTest.php create mode 100644 tests/Back/ProductTest.php create mode 100644 tests/Back/ProductTypeTest.php create mode 100644 tests/Back/ProfessionTest.php create mode 100644 tests/Back/RangeTest.php create mode 100644 tests/Back/RecipeTest.php create mode 100644 tests/Back/SellItemTest.php create mode 100644 tests/Back/StaticPageTest.php create mode 100644 tests/Back/SubmeatTest.php create mode 100644 tests/Back/SubrangeTest.php create mode 100644 tests/Back/SurveysAnswerTest.php create mode 100644 tests/Back/TestimonialTest.php create mode 100644 tests/Back/VideoTest.php delete mode 100644 tests/Feature/ExampleTest.php delete mode 100644 tests/Unit/ExampleTest.php diff --git a/.gitignore b/.gitignore index c98f26cd..aa929f20 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,6 @@ .env .env.backup +.env.testing .env.production .phpunit.result.cache .stylelintcache @@ -23,6 +24,7 @@ Homestead.yaml npm-debug.log yarn-error.log .npmrc +/tests/coverage # Ignore public favicon /public/android-chrome-192x192.png diff --git a/README.md b/README.md index f0a46835..9bc9f3b3 100644 --- a/README.md +++ b/README.md @@ -14,6 +14,60 @@ apt install trimage # Copy paste from the admin secure readme.md Put every min in PROD : +```php php artisan schedule:run +``` +# Unit tests +Create new `.env.testing` with a new empty database `le-gaulois-testing` and just run this command : +```php +php artisan test +``` +To see more details, please read the documentation of [uwil/unit-tests-laravel](https://lab.s-web.fr/ldc-web/projets/unit-tests-laravel/-/blob/main/README.md?ref_type=heads#documentation) +Legend : ✅ test added & operational, ⚠️ test added & operational but modified, ❌ no test (because no CRUD or specific model) + +Models list : + + ✅ ActivityLog + ⚠️ Approach (label/demarche) + ❌ BlockList + ✅ BrandAdvantage + ❌ Breeder + ✅ Claim + ✅ ConsumptionMoment + ❌ Customer + ❌ DeliveryAddress + ✅ DemarcheSlide + ❌ DepartaimantsCollection + ✅ Discount + ❌ GeneralSetting + ✅ HistoricalMilestone + ❌ IncoNutritionalValue + ✅ KeyNumber + ✅ MainSlide + ✅ Meat + ⚠️ MenuNodeData + ❌ Message + ⚠️ News + ✅ NewsBreeding + ✅ NewsCategory + ⚠️ NewsClub (News/Survey) + ✅ NewsCorporate + ❌ Notification + ✅ Offer + ❌ Order + ❌ OrderSellItem + ✅ Product + ✅ ProductType + ✅ Profession + ✅ Range + ✅ Recipe + ✅ SellItem + ✅ StaticPage + ✅ Submeat + ✅ Subrange + ✅ SurveysAnswer + ✅ Testimonial + ❌ User + ✅ Video diff --git a/app/Enums/Breeders/GeoType.php b/app/Enums/Breeders/GeoType.php index 7ee56e29..684f3d9b 100644 --- a/app/Enums/Breeders/GeoType.php +++ b/app/Enums/Breeders/GeoType.php @@ -16,8 +16,8 @@ enum GeoType: int * * @phpstan-ignore-next-line */ - private const ROUTENAMES = [ - self::exact->name => trans('Exacte'), - self::commune->name => trans('Code commune'), + private const LABELS = [ + self::exact->name => 'Exacte', + self::commune->name => 'Code commune', ]; } diff --git a/app/Enums/Breeders/EleveurOcbStatus.php b/app/Enums/Breeders/OCBStatus.php similarity index 58% rename from app/Enums/Breeders/EleveurOcbStatus.php rename to app/Enums/Breeders/OCBStatus.php index 0e9bdcc9..63f68307 100644 --- a/app/Enums/Breeders/EleveurOcbStatus.php +++ b/app/Enums/Breeders/OCBStatus.php @@ -4,7 +4,7 @@ namespace App\Enums\Breeders; use App\Traits\Enums\BaseEnum; -enum EleveurOcbStatus: int +enum OCBStatus: int { use BaseEnum; @@ -19,9 +19,9 @@ enum EleveurOcbStatus: int * @phpstan-ignore-next-line */ private const LABELS = [ - self::none->name => trans('Non'), - self::pending->name => trans('En attente'), - self::no->name => trans('Réfusé'), - self::yes->name => trans('Valide'), + self::none->name => 'Non', + self::pending->name => 'En attente', + self::no->name => 'Réfusé', + self::yes->name => 'Valide', ]; } diff --git a/app/Enums/Breeders/OCBType.php b/app/Enums/Breeders/OCBType.php index 14ecea4b..10c09fd6 100644 --- a/app/Enums/Breeders/OCBType.php +++ b/app/Enums/Breeders/OCBType.php @@ -18,8 +18,8 @@ enum OCBType: int * @phpstan-ignore-next-line */ private const LABELS = [ - self::rabbit->name => trans('Lapin'), - self::chicken->name => trans('Poulet'), - self::turkey->name => trans('Dinde'), + self::rabbit->name => 'Lapin', + self::chicken->name => 'Poulet', + self::turkey->name => 'Dinde', ]; } diff --git a/app/Enums/Breeders/PresentationType.php b/app/Enums/Breeders/PresentationType.php index 297f2c2e..e688825e 100644 --- a/app/Enums/Breeders/PresentationType.php +++ b/app/Enums/Breeders/PresentationType.php @@ -17,7 +17,7 @@ enum PresentationType: int * @phpstan-ignore-next-line */ private const LABELS = [ - self::picture->name => trans('Photo'), - self::video->name => trans('Video'), + self::picture->name => 'Photo', + self::video->name => 'Video', ]; } diff --git a/app/Enums/HistoricalMilestonePosition.php b/app/Enums/HistoricalMilestonePosition.php deleted file mode 100644 index 5dd5bb8f..00000000 --- a/app/Enums/HistoricalMilestonePosition.php +++ /dev/null @@ -1,23 +0,0 @@ -name => 'Haut gauche', - self::hd->name => "Haut droit", - ]; -} diff --git a/app/Enums/HistoricalMilestones/HistoricalMilestonePosition.php b/app/Enums/HistoricalMilestones/HistoricalMilestonePosition.php new file mode 100644 index 00000000..858be68f --- /dev/null +++ b/app/Enums/HistoricalMilestones/HistoricalMilestonePosition.php @@ -0,0 +1,23 @@ +name => 'Haut gauche', + self::topRight->name => "Haut droit", + ]; +} diff --git a/app/Http/Controllers/Bo/DiscountController.php b/app/Http/Controllers/Bo/DiscountController.php index 563856af..4140c1dd 100644 --- a/app/Http/Controllers/Bo/DiscountController.php +++ b/app/Http/Controllers/Bo/DiscountController.php @@ -57,6 +57,17 @@ class DiscountController extends Controller return view('bo.pages.discounts.index', compact('discountModels', 'search', 'searchFields')); } + /** + * Show the specified resource. + * + * @param \App\Models\Discount $discount + * @return \Illuminate\Contracts\View\View + */ + public function show(Discount $discount): \Illuminate\Contracts\View\View + { + return view('bo.pages.discounts.show', ['discountModel' => $discount]); + } + /** * Show the specified resource. * diff --git a/app/Http/Requests/Bo/DemarcheSlides/StoreDemarcheSlideRequest.php b/app/Http/Requests/Bo/DemarcheSlides/StoreDemarcheSlideRequest.php index e03c308e..da3f2338 100644 --- a/app/Http/Requests/Bo/DemarcheSlides/StoreDemarcheSlideRequest.php +++ b/app/Http/Requests/Bo/DemarcheSlides/StoreDemarcheSlideRequest.php @@ -60,8 +60,8 @@ class StoreDemarcheSlideRequest extends FormRequest 'button_2_url' => 'required_if_accepted:button_2_status|string|nullable|url:http,https', 'button_2_target' => 'required_if_accepted:button_2_status|boolean', 'published' => 'required|boolean', - 'publish_at' => 'nullable|date', - 'unpublish_at' => 'nullable|date|after:publish_at', + 'published_at' => 'nullable|date', + 'unpublished_at' => 'nullable|date|after:publish_at', ]; return \array_merge( $rules, @@ -91,8 +91,8 @@ class StoreDemarcheSlideRequest extends FormRequest 'button_2_status' => trans('validation.custom.button_status') . ' n°2', 'button_2_target' => trans('validation.custom.button_target') . ' n°2', 'published' => trans('validation.attributes.published'), - 'publish_at' => trans('validation.custom.publish_at'), - 'unpublish_at' => trans('validation.custom.unpublish_at'), + 'published_at' => trans('validation.custom.publish_at'), + 'unpublished_at' => trans('validation.custom.unpublish_at'), ]; } } diff --git a/app/Http/Requests/Bo/HistoricalMilestones/StoreHistoricalMilestoneRequest.php b/app/Http/Requests/Bo/HistoricalMilestones/StoreHistoricalMilestoneRequest.php index 481ccc8f..54a3423b 100644 --- a/app/Http/Requests/Bo/HistoricalMilestones/StoreHistoricalMilestoneRequest.php +++ b/app/Http/Requests/Bo/HistoricalMilestones/StoreHistoricalMilestoneRequest.php @@ -2,7 +2,7 @@ namespace App\Http\Requests\Bo\HistoricalMilestones; -use App\Enums\HistoricalMilestonePosition; +use App\Enums\HistoricalMilestones\HistoricalMilestonePosition; use App\Models\HistoricalMilestone; use App\Rules\WysiwygLength; use App\Traits\Requests\HasPicture; @@ -48,12 +48,12 @@ class StoreHistoricalMilestoneRequest extends FormRequest public function rules(): array { $rules = [ - 'year' => 'required|integer|min:1901|max:2155', - 'title' => 'required|string|between:3,255', - 'description' => ['required', 'string', new WysiwygLength()], - 'picture_alt' => 'required_with:picture|nullable|between:3,255', - 'picture_title' => 'required_with:picture|nullable|between:3,255', - 'video_id' => [ + 'year' => 'required|integer|min:1901|max:2155', + 'title' => 'required|string|between:3,255', + 'description' => ['required', 'string', new WysiwygLength()], + 'picture_alt' => 'required_with:picture|nullable|between:3,255', + 'picture_title' => 'required_with:picture|nullable|between:3,255', + 'video_id' => [ 'sometimes', 'nullable', 'string', @@ -67,10 +67,10 @@ class StoreHistoricalMilestoneRequest extends FormRequest } } ], - 'picto_alt' => 'required_with:picto|nullable|between:3,255', - 'picto_title' => 'required_with:picto|nullable|between:3,255', - 'published' => 'required|boolean', - 'picto_placement' => ['required_with:picto', 'nullable', Rule::enum(HistoricalMilestonePosition::class)] + 'picto_alt' => 'required_with:picto|nullable|between:3,255', + 'picto_title' => 'required_with:picto|nullable|between:3,255', + 'picto_position' => ['required_with:picto', 'nullable', Rule::enum(HistoricalMilestonePosition::class)], + 'published' => 'required|boolean', ]; return \array_merge( $rules, @@ -87,17 +87,18 @@ class StoreHistoricalMilestoneRequest extends FormRequest public function attributes(): array { return [ - 'year' => trans('validation.attributes.year'), - 'title' => trans('validation.attributes.title'), - 'description' => trans('validation.attributes.description'), - 'picture' => trans('validation.attributes.image'), - 'picture_alt' => trans('validation.custom.attribute_alt'), - 'picture_title' => trans('validation.custom.attribute_title'), - 'video_id' => trans('validation.custom.video_id'), - 'picto' => trans('validation.custom.picto'), - 'picto_alt' => trans('validation.custom.attribute_alt'), - 'picto_title' => trans('validation.custom.attribute_title'), - 'published' => trans('validation.attributes.published') + 'year' => trans('validation.attributes.year'), + 'title' => trans('validation.attributes.title'), + 'description' => trans('validation.attributes.description'), + 'picture' => trans('validation.attributes.image'), + 'picture_alt' => trans('validation.custom.attribute_alt'), + 'picture_title' => trans('validation.custom.attribute_title'), + 'video_id' => trans('validation.custom.video_id'), + 'picto' => trans('validation.custom.picto'), + 'picto_alt' => trans('validation.custom.attribute_alt'), + 'picto_title' => trans('validation.custom.attribute_title'), + 'picto_position' => trans('validation.custom.picto_position'), + 'published' => trans('validation.attributes.published') ]; } } diff --git a/app/Http/Requests/Bo/MainSlides/StoreMainSlideRequest.php b/app/Http/Requests/Bo/MainSlides/StoreMainSlideRequest.php index f726939b..23431450 100644 --- a/app/Http/Requests/Bo/MainSlides/StoreMainSlideRequest.php +++ b/app/Http/Requests/Bo/MainSlides/StoreMainSlideRequest.php @@ -34,8 +34,8 @@ class StoreMainSlideRequest extends FormRequest 'button_1_target' => $this->boolean('button_1_target'), 'button_2_status' => $this->boolean('button_2_status'), 'button_2_target' => $this->boolean('button_2_target'), - 'published' => $this->boolean('published'), 'new' => $this->boolean('new'), + 'published' => $this->boolean('published'), ]); $this->mergePicture('picture'); $this->mergePicture('background'); @@ -69,10 +69,10 @@ class StoreMainSlideRequest extends FormRequest 'button_1_color_background' => ['required_if_accepted:button_1_status', new Hex()], 'button_2_color_text' => ['required_if_accepted:button_2_status', new Hex()], 'button_2_color_background' => ['required_if_accepted:button_2_status', new Hex()], - 'published' => 'required|boolean', 'new' => 'required|boolean', - 'publish_at' => 'nullable|date', - 'unpublish_at' => 'nullable|date|after:publish_at', + 'published' => 'required|boolean', + 'published_at' => 'nullable|date', + 'unpublished_at' => 'nullable|date|after:published_at', ]; return \array_merge( $rules, @@ -112,8 +112,8 @@ class StoreMainSlideRequest extends FormRequest 'button_2_color_background' => trans('validation.custom.button_color_background') . ' n°2', 'new' => trans('validation.custom.new'), 'published' => trans('validation.custom.published'), - 'publish_at' => trans('validation.custom.publish_at'), - 'unpublish_at' => trans('validation.custom.unpublish_at'), + 'published_at' => trans('validation.custom.published_at'), + 'unpublished_at' => trans('validation.custom.unpublished_at'), ]; } } diff --git a/app/Jobs/DemarcheSlidesStatusUpdate.php b/app/Jobs/DemarcheSlidesStatusUpdate.php index 4a6254a4..63623f55 100644 --- a/app/Jobs/DemarcheSlidesStatusUpdate.php +++ b/app/Jobs/DemarcheSlidesStatusUpdate.php @@ -8,7 +8,7 @@ use Illuminate\Support\Facades\Log; /** * Update published attribute reading its - * publish_at and unpublish_at attributes. + * published_at and unpublished_at attributes. */ class DemarcheSlidesStatusUpdate { @@ -21,20 +21,20 @@ class DemarcheSlidesStatusUpdate { /** @var \Illuminate\Database\Eloquent\Collection */ $demarcheSlidesListToUnPublish = DemarcheSlide::query() - ->where('unpublish_at', '<=', Carbon::now()) - ->whereNotNull('unpublish_at') + ->where('unpublished_at', '<=', Carbon::now()) + ->whereNotNull('unpublished_at') ->where('published', true)->get(); Log::debug(__CLASS__ . " demarcheSlides to unpublish " . $demarcheSlidesListToUnPublish->count()); foreach ($demarcheSlidesListToUnPublish as $demarcheSlide) { - $demarcheSlide->publish_at = null; - $demarcheSlide->unpublish_at = null; + $demarcheSlide->published_at = null; + $demarcheSlide->unpublished_at = null; $demarcheSlide->published = false; $demarcheSlide->saveOrFail(); } /** @var \Illuminate\Database\Eloquent\Collection */ $demarcheSlidesListToPublish = DemarcheSlide::query() - ->where('publish_at', '<=', Carbon::now()) - ->whereNotNull('publish_at') + ->where('published_at', '<=', Carbon::now()) + ->whereNotNull('published_at') ->where('published', false)->get(); Log::debug(__CLASS__ . " demarcheSlides to publish " . $demarcheSlidesListToPublish->count()); // Unpublish all demarcheSlide with no date because only 1 demarcheSlide can be published. @@ -46,7 +46,7 @@ class DemarcheSlidesStatusUpdate }); } foreach ($demarcheSlidesListToPublish as $demarcheSlide) { - $demarcheSlide->publish_at = null; + $demarcheSlide->published_at = null; $demarcheSlide->published = true; $demarcheSlide->saveOrFail(); } diff --git a/app/Jobs/MainSlidesStatusUpdate.php b/app/Jobs/MainSlidesStatusUpdate.php index 43c4f066..b3bae811 100644 --- a/app/Jobs/MainSlidesStatusUpdate.php +++ b/app/Jobs/MainSlidesStatusUpdate.php @@ -8,7 +8,7 @@ use Illuminate\Support\Facades\Log; /** * Update published attribute reading its - * publish_at and unpublish_at attributes. + * published_at and unpublished_at attributes. */ class MainSlidesStatusUpdate { @@ -20,33 +20,33 @@ class MainSlidesStatusUpdate public function handle(): void { /** @var \Illuminate\Database\Eloquent\Collection */ - $mainSlidesListToUnPublish = MainSlide::query() - ->where('unpublish_at', '<=', Carbon::now()) + $mainSlidesListToUnPublished = MainSlide::query() + ->where('unpublished_at', '<=', Carbon::now()) ->whereNotNull('unpublish_at') ->where('published', true)->get(); - Log::debug(__CLASS__ . " mainSlides to unpublish " . $mainSlidesListToUnPublish->count()); - foreach ($mainSlidesListToUnPublish as $mainSlide) { - $mainSlide->publish_at = null; - $mainSlide->unpublish_at = null; + Log::debug(__CLASS__ . " mainSlides to unpublished " . $mainSlidesListToUnPublished->count()); + foreach ($mainSlidesListToUnPublished as $mainSlide) { + $mainSlide->published_at = null; + $mainSlide->unpublished_at = null; $mainSlide->published = false; $mainSlide->saveOrFail(); } /** @var \Illuminate\Database\Eloquent\Collection */ - $mainSlidesListToPublish = MainSlide::query() + $mainSlidesListToPublished = MainSlide::query() ->where('publish_at', '<=', Carbon::now()) ->whereNotNull('publish_at') ->where('published', false)->get(); - Log::debug(__CLASS__ . " mainSlides to publish " . $mainSlidesListToPublish->count()); + Log::debug(__CLASS__ . " mainSlides to publish " . $mainSlidesListToPublished->count()); // Unpublish all mainSlide with no date because only 1 mainSlide can be published. - if ($mainSlidesListToPublish->count()) { + if ($mainSlidesListToPublished->count()) { MainSlide::query()->where('published', true) ->each(function (MainSlide $mainSlide) { $mainSlide->published = false; $mainSlide->saveOrFail(); }); } - foreach ($mainSlidesListToPublish as $mainSlide) { - $mainSlide->publish_at = null; + foreach ($mainSlidesListToPublished as $mainSlide) { + $mainSlide->published_at = null; $mainSlide->published = true; $mainSlide->saveOrFail(); } diff --git a/app/Models/Breeder.php b/app/Models/Breeder.php index 33a59a2d..e09ed18e 100644 --- a/app/Models/Breeder.php +++ b/app/Models/Breeder.php @@ -2,7 +2,7 @@ namespace App\Models; -use App\Enums\Breeders\EleveurOcbStatus; +use App\Enums\Breeders\OCBStatus; use App\Enums\Breeders\GeoType; use App\Enums\Breeders\OCBType; use App\Enums\Breeders\PresentationType; @@ -80,7 +80,7 @@ class Breeder extends Model 'published' => 'boolean', 'display_random' => 'boolean', 'presentation_type' => PresentationType::class, - 'ocbStatus' => EleveurOcbStatus::class, + 'ocbStatus' => OCBStatus::class, 'ocbType' => OCBType::class, 'geo_type' => GeoType::class ]; diff --git a/app/Models/DemarcheSlide.php b/app/Models/DemarcheSlide.php index c16e4d2b..e88ff68a 100644 --- a/app/Models/DemarcheSlide.php +++ b/app/Models/DemarcheSlide.php @@ -24,10 +24,10 @@ use Illuminate\Support\Facades\Cache; * @property boolean $button_2_status Slide button n°2 publish status. * @property boolean $button_2_target Slide button n°2 target. * @property boolean $published Slide publish status. - * @property-read \Illuminate\Support\Carbon $published_at Slide published_at. - * @property-read \Illuminate\Support\Carbon $unpublished_at Slide unpublished_at. - * @property-read \Illuminate\Support\Carbon $created_at Created date. - * @property-read \Illuminate\Support\Carbon $updated_at Updated date. + * @property-read \Illuminate\Support\Carbon $published_at Slide published at. + * @property-read \Illuminate\Support\Carbon $unpublished_at Slide unpublished at. + * @property-read \Carbon\Carbon $created_at Created date. + * @property-read \Carbon\Carbon $updated_at Updated date. */ class DemarcheSlide extends Model { @@ -55,8 +55,8 @@ class DemarcheSlide extends Model 'button_2_target', 'order', 'published', - 'publish_at', - 'unpublish_at', + 'published_at', + 'unpublished_at', ]; /** @@ -69,8 +69,8 @@ class DemarcheSlide extends Model 'button_1_target' => 'boolean', 'button_2_status' => 'boolean', 'button_2_target' => 'boolean', - 'publish_at' => 'datetime', - 'unpublish_at' => 'datetime', + 'published_at' => 'datetime', + 'unpublished_at' => 'datetime', ]; /** @@ -135,11 +135,11 @@ class DemarcheSlide extends Model private static function makeStatusSense(self $demarcheSlide): void { /** @var \Carbon\Carbon|null */ - $publish_at = $demarcheSlide->publish_at; + $published_at = $demarcheSlide->published_at; /** @var \Carbon\Carbon|null */ - $unpublish_at = $demarcheSlide->unpublish_at; + $unpublished_at = $demarcheSlide->unpublished_at; $wantedStatus = $demarcheSlide->published; - if ($publish_at or $unpublish_at) { + if ($published_at or $unpublished_at) { $demarcheSlide->published = $demarcheSlide->planificated_status; } if ($wantedStatus !== $demarcheSlide->published) { @@ -158,17 +158,17 @@ class DemarcheSlide extends Model public function getPlanificatedStatusAttribute(): bool { /** @var \Carbon\Carbon|null */ - $publish_at = $this->publish_at; + $published_at = $this->published_at; /** @var \Carbon\Carbon|null */ - $unpublish_at = $this->unpublish_at; - if ($publish_at and $unpublish_at) { - return $unpublish_at->greaterThanOrEqualTo(now()) and $publish_at->lessThan(now()); + $unpublished_at = $this->unpublished_at; + if ($published_at and $unpublished_at) { + return $unpublished_at->greaterThanOrEqualTo(now()) and $published_at->lessThan(now()); } - if ($publish_at) { - return $publish_at->lessThan(now()); + if ($published_at) { + return $published_at->lessThan(now()); } - if ($unpublish_at) { - return $unpublish_at->greaterThanOrEqualTo(now()); + if ($unpublished_at) { + return $unpublished_at->greaterThanOrEqualTo(now()); } return false; } diff --git a/app/Models/HistoricalMilestone.php b/app/Models/HistoricalMilestone.php index 3c0109c6..824c3ddf 100644 --- a/app/Models/HistoricalMilestone.php +++ b/app/Models/HistoricalMilestone.php @@ -2,6 +2,7 @@ namespace App\Models; +use App\Enums\HistoricalMilestones\HistoricalMilestonePosition; use App\Lib\Helpers\FileStorageHelper; use App\Traits\Models\ActivityLog; use Illuminate\Database\Eloquent\Factories\HasFactory; @@ -9,19 +10,20 @@ use Illuminate\Database\Eloquent\Model; use Illuminate\Support\Facades\Cache; /** - * @property \Carbon\Carbon $year Historical milestone year. - * @property string $title Historical milestone title. - * @property string $description Historical milestone description. - * @property string|null $picture Historical milestone picture. - * @property string|null $picture_alt Picture alt attribute. - * @property string|null $picture_title Picture title attribute. - * @property string|null $video_id Historical milestone video ID. - * @property string|null $picto Historical milestone picto. - * @property string|null $picto_alt picto alt attribute. - * @property string|null $picto_title picto title attribute. - * @property boolean $published Historical milestone publish status. - * @property-read \Illuminate\Support\Carbon $created_at Created date. - * @property-read \Illuminate\Support\Carbon $updated_at Updated date. + * @property \Carbon\Carbon $year Historical milestone year. + * @property string $title Historical milestone title. + * @property string $description Historical milestone description. + * @property string|null $picture Historical milestone picture. + * @property string|null $picture_alt Picture alt attribute. + * @property string|null $picture_title Picture title attribute. + * @property string|null $video_id Historical milestone video ID. + * @property string|null $picto Historical milestone picto. + * @property string|null $picto_alt Picto alt attribute. + * @property string|null $picto_title Picto title attribute. + * @property \App\Enums\HistoricalMilestones\HistoricalMilestonePosition $picto_position Historical milestone picto position. + * @property boolean $published Historical milestone publish status. + * @property-read \Illuminate\Support\Carbon $created_at Created date. + * @property-read \Illuminate\Support\Carbon $updated_at Updated date. */ class HistoricalMilestone extends Model { @@ -44,7 +46,7 @@ class HistoricalMilestone extends Model 'picto', 'picto_alt', 'picto_title', - 'picto_placement', + 'picto_position', 'order', 'published', ]; @@ -55,8 +57,9 @@ class HistoricalMilestone extends Model * @var array */ protected $casts = [ - 'year' => 'integer', - 'published' => 'boolean', + 'year' => 'integer', + 'picto_position' => HistoricalMilestonePosition::class, + 'published' => 'boolean', ]; /** diff --git a/app/Models/MainSlide.php b/app/Models/MainSlide.php index 0c5e440f..2c2a22c6 100644 --- a/app/Models/MainSlide.php +++ b/app/Models/MainSlide.php @@ -76,8 +76,8 @@ class MainSlide extends Model 'order', 'new', 'published', - 'publish_at', - 'unpublish_at', + 'published_at', + 'unpublished_at', ]; /** @@ -95,8 +95,8 @@ class MainSlide extends Model 'button_1_color_background' => HtmlColor::class, 'button_2_color_text' => HtmlColor::class, 'button_2_color_background' => HtmlColor::class, - 'publish_at' => 'datetime', - 'unpublish_at' => 'datetime', + 'published_at' => 'datetime', + 'unpublished_at' => 'datetime', ]; /** @@ -177,7 +177,7 @@ class MainSlide extends Model } /** - * Adjusts mainSlide status using current status and publish dates. + * Adjusts mainSlide status using current status and published dates. * * @param self $mainSlide * @return void @@ -185,11 +185,11 @@ class MainSlide extends Model private static function makeStatusSense(self $mainSlide): void { /** @var \Carbon\Carbon|null */ - $publish_at = $mainSlide->publish_at; + $published_at = $mainSlide->published_at; /** @var \Carbon\Carbon|null */ - $unpublish_at = $mainSlide->unpublish_at; + $unpublished_at = $mainSlide->unpublished_at; $wantedStatus = $mainSlide->published; - if ($publish_at or $unpublish_at) { + if ($published_at or $unpublished_at) { $mainSlide->published = $mainSlide->planificated_status; } if ($wantedStatus !== $mainSlide->published) { @@ -208,17 +208,17 @@ class MainSlide extends Model public function getPlanificatedStatusAttribute(): bool { /** @var \Carbon\Carbon|null */ - $publish_at = $this->publish_at; + $published_at = $this->published_at; /** @var \Carbon\Carbon|null */ - $unpublish_at = $this->unpublish_at; - if ($publish_at and $unpublish_at) { - return $unpublish_at->greaterThanOrEqualTo(now()) and $publish_at->lessThan(now()); + $unpublished_at = $this->unpublished_at; + if ($published_at and $unpublished_at) { + return $unpublished_at->greaterThanOrEqualTo(now()) and $published_at->lessThan(now()); } - if ($publish_at) { - return $publish_at->lessThan(now()); + if ($published_at) { + return $published_at->lessThan(now()); } - if ($unpublish_at) { - return $unpublish_at->greaterThanOrEqualTo(now()); + if ($unpublished_at) { + return $unpublished_at->greaterThanOrEqualTo(now()); } return false; } diff --git a/app/Models/User.php b/app/Models/User.php index 437b113a..e73a9ba5 100644 --- a/app/Models/User.php +++ b/app/Models/User.php @@ -72,25 +72,44 @@ class User extends Authenticatable protected static function booted(): void { static::creating(function (self $model) { - // * Prevent user elevation privileges - throw_if( - auth('backend')->user() and auth('backend')->user()->role->value() > $model->role->value(), - AuthorizationException::class - ); + self::checkElevationPrivileges($model); }); static::updating(function (self $model) { - if (optional(auth('backend')->user())->getKey() === $model->getKey()) { - \validator( - ['published' => $model->published], - ['published' => 'required|boolean|accepted'], - ['published.accepted' => trans('crud.messages.user_unpublished')], - )->validate(); - } - // * Prevent user elevation privileges - throw_if( - auth('backend')->user() and auth('backend')->user()->role->value() > $model->role->value(), - AuthorizationException::class - ); + self::updatePublishedStatus($model); + self::checkElevationPrivileges($model); }); } + + // * METHODS + + /** + * Check if the authenticable user can update the published status. + * + * @param self $user + * @return void + */ + private static function updatePublishedStatus(self $user): void + { + if (optional(auth('backend')->user())->getKey() === $user->getKey()) { + \validator( + ['published' => $user->published], + ['published' => 'required|boolean|accepted'], + ['published.accepted' => trans('Vous ne pouvez pas désactiver votre propre compte')], + )->validate(); + } + } + + /** + * Prevent user elevation privileges. + * + * @param self $user + * @return void + */ + private static function checkElevationPrivileges(self $user): void + { + throw_if( + auth('backend')->user() and auth('backend')->user()->role->value() > $user->role->value(), + AuthorizationException::class + ); + } } diff --git a/app/Policies/DiscountPolicy.php b/app/Policies/DiscountPolicy.php index df3f6964..0c6d0509 100644 --- a/app/Policies/DiscountPolicy.php +++ b/app/Policies/DiscountPolicy.php @@ -18,6 +18,17 @@ class DiscountPolicy return UserStaticRules::everyOne(); } + /** + * Determine whether the user can view the model. + * + * @param \App\Models\User $authUser + * @return boolean + */ + public function view(User $authUser): bool + { + return UserStaticRules::atLeastRole($authUser, RoleEnum::admin); + } + /** * Determine whether the user can update the model. * diff --git a/composer.json b/composer.json index 9ffe7440..8ca30ad9 100644 --- a/composer.json +++ b/composer.json @@ -35,6 +35,7 @@ "uwil/k8s-laravel": "^1.4", "uwil/laravel-common": "^2.1", "uwil/seo-laravel": "^3.0", + "uwil/unit-tests-laravel": "^1.0", "verschuur/laravel-robotstxt": "^5.1" }, "require-dev": { diff --git a/composer.lock b/composer.lock index eda42993..27edb303 100644 --- a/composer.lock +++ b/composer.lock @@ -8300,6 +8300,57 @@ "issues": "https://lab.s-web.fr/ldc-web/projets/seo-laravel/-/issues" } }, + { + "name": "uwil/unit-tests-laravel", + "version": "1.0.0", + "source": { + "type": "git", + "url": "git@lab.s-web.fr:ldc-web/projets/unit-tests-laravel.git", + "reference": "0e80fcdadc858f7238b6863ffa85bf47191e3172" + }, + "dist": { + "type": "zip", + "url": "https://lab.s-web.fr/api/v4/projects/173/packages/composer/archives/uwil/unit-tests-laravel.zip?sha=0e80fcdadc858f7238b6863ffa85bf47191e3172", + "reference": "0e80fcdadc858f7238b6863ffa85bf47191e3172", + "shasum": "" + }, + "require": { + "illuminate/support": "^8.0|^9.0|^10.0|^11.0", + "laravel/framework": "^8.0|^9.0|^10.0|^11.0", + "php": "^7.3|^8.0" + }, + "require-dev": { + "phpstan/phpstan": "^1.11", + "slevomat/coding-standard": "^8.3", + "squizlabs/php_codesniffer": "^3.7" + }, + "type": "library", + "extra": { + "laravel": { + "providers": [ + "Uwil\\UnitTestsLaravel\\UnitTestsServiceProvider" + ] + } + }, + "autoload": { + "psr-4": { + "Uwil\\UnitTestsLaravel\\": "src/" + } + }, + "license": [ + "MIT" + ], + "description": "Test CRUDs assertions in Laravel project.", + "keywords": [ + "laravel", + "tests", + "uwil" + ], + "support": { + "email": "equipe.web@ldc.fr", + "issues": "https://lab.s-web.fr/ldc-web/projets/unit-tests-laravel/-/issues" + } + }, { "name": "verschuur/laravel-robotstxt", "version": "5.1.0", diff --git a/config/mail.php b/config/mail.php index b40a08e3..cd22b559 100644 --- a/config/mail.php +++ b/config/mail.php @@ -98,9 +98,9 @@ return [ // Contacts List. 'contactsList' => [ - 'contact' => explode(',', env('MAIL_LIST_CONTACT')), - 'passerelle' => explode(',', env('MAIL_LIST_PASSERELLE')), - 'contactNL' => explode(',', env('MAIL_LIST_NL')), + 'contact' => explode(',', env('MAIL_LIST_CONTACT', 'contact@legaulois.fr')), + 'passerelle' => explode(',', env('MAIL_LIST_PASSERELLE', '')), + 'contactNL' => explode(',', env('MAIL_LIST_NL', '')), ], /* diff --git a/config/unit-tests.php b/config/unit-tests.php new file mode 100644 index 00000000..261ea71a --- /dev/null +++ b/config/unit-tests.php @@ -0,0 +1,64 @@ + [ + 'prefix' => 'bo.', + + 'name-homepage' => 'dashboard', + + 'resources-index' => 'index', + 'resources-create' => 'create', + 'resources-update' => 'edit', + 'resources-read' => 'show', + ], + + /* + |-------------------------------------------------------------------------- + | Route options + |-------------------------------------------------------------------------- + | + | Here you can configure the optional prefix of existing routes and all + | their action names. + | + */ + + 'route' => [ + 'prefix' => 'bo.', + + 'action-create' => 'store', + 'action-update' => 'update', + 'action-delete' => 'destroy', + ], + + /* + |-------------------------------------------------------------------------- + | Model field used for an update + |-------------------------------------------------------------------------- + | + | Here you can configure the list of possible text fields existing in a model, + | (the first one to exist will be updated, must be a text field). + | ex: ['name', 'label', 'title', 'first_name']. + | + */ + + 'list-fields' => [ + 'name', + 'label', + 'title', + 'first_name', + 'catchline', + 'text', + 'answer', + ] +]; diff --git a/database/factories/ActivityLogFactory.php b/database/factories/ActivityLogFactory.php new file mode 100644 index 00000000..b0f34aad --- /dev/null +++ b/database/factories/ActivityLogFactory.php @@ -0,0 +1,32 @@ + + */ +final class ActivityLogFactory extends Factory +{ + /** + * Define the model's default state. + * + * @return array + */ + public function definition(): array + { + $boolean = fake()->boolean(50); + return [ + 'user_id' => null, + 'is_anonymous' => $boolean, + 'is_console' => !$boolean, + 'model_class' => "\App\Models\User", + 'model_id' => 1, + 'event' => \collect(ActivityLogsEventEnum::toArray())->random()->value, + 'data' => [], + 'created_at' => now(), + ]; + } +} diff --git a/database/factories/ApproachFactory.php b/database/factories/ApproachFactory.php index 37883927..06f9c8c2 100644 --- a/database/factories/ApproachFactory.php +++ b/database/factories/ApproachFactory.php @@ -17,6 +17,7 @@ class ApproachFactory extends Factory return [ 'type' => fake()->boolean(50) ? ApproachTypeEnum::label : ApproachTypeEnum::demarche, 'name' => fake()->words(3, true), + 'picture' => '', 'picture_title' => fake()->words(5, true), 'picture_alt' => fake()->words(8, true), 'published' => fake()->boolean(75), diff --git a/database/factories/BrandAdvantageFactory.php b/database/factories/BrandAdvantageFactory.php index 390b4cc6..1c217806 100644 --- a/database/factories/BrandAdvantageFactory.php +++ b/database/factories/BrandAdvantageFactory.php @@ -16,10 +16,12 @@ class BrandAdvantageFactory extends Factory return [ 'title' => fake()->text(10), 'sustitle' => fake()->text(10), + 'picto' => '', 'picto_alt' => fake()->text(255), 'picto_title' => fake()->text(255), 'text' => fake()->text(165), 'is_large' => fake()->boolean(25), + 'order' => 1, 'published' => fake()->boolean(75), ]; } diff --git a/database/factories/BreederFactory.php b/database/factories/BreederFactory.php index e6f900d8..184b70a8 100644 --- a/database/factories/BreederFactory.php +++ b/database/factories/BreederFactory.php @@ -2,6 +2,11 @@ namespace Database\Factories; +use App\Enums\Breeders\GeoType; +use App\Enums\Breeders\OCBStatus; +use App\Enums\Breeders\OCBType; +use App\Enums\Department; +use Carbon\Carbon; use Illuminate\Database\Eloquent\Factories\Factory; class BreederFactory extends Factory @@ -13,19 +18,36 @@ class BreederFactory extends Factory */ public function definition(): array { + $code = strval(fake()->numberBetween(1, 1000)); + $lastname = fake()->lastname(); + $firstname = fake()->firstName(); return [ - 'inuav_codes' => [ + 'breeder_code' => $code, + 'inuav_codes' => [ fake()->text(10), fake()->text(10), ], - 'first_name' => fake()->firstName(), - 'last_name' => fake()->lastName(), - 'picture_title' => fake()->words(5, true), - 'picture_alt' => fake()->words(8, true), - 'postal_code' => fake()->postcode(), - 'testimony' => fake()->text(), - 'is_highlighted' => fake()->boolean(75), - 'published' => fake()->boolean(75), + 'slug' => sprintf("%s-%s-%s", $code, $lastname, $firstname), + 'first_name' => $firstname, + 'last_name' => fake()->lastName(), + 'picture' => '', + 'picture_title' => fake()->words(5, true), + 'picture_alt' => fake()->words(8, true), + 'postal_code' => fake()->postcode(), + 'department' => \collect(Department::toArray())->random()->value, + 'place' => fake()->word(), + 'testimony' => fake()->text(), + 'latitude' => fake()->randomFloat(2), + 'longitude' => fake()->randomFloat(2), + 'geo_type' => \collect(GeoType::toArray())->random()->value, + 'ocbStatus' => \collect(OCBStatus::toArray())->random()->value, + 'ocbType' => \collect(OCBType::toArray())->random()->value, + 'audit' => 1, // FIXME: utilité de ce champs, aucune indication + 'valid_marketing_date' => Carbon::now(), + 'approaches' => [], + 'is_highlighted' => fake()->boolean(75), + 'order' => 1, + 'published' => fake()->boolean(75), ]; } } diff --git a/database/factories/ClaimFactory.php b/database/factories/ClaimFactory.php index 14058850..af102b7a 100644 --- a/database/factories/ClaimFactory.php +++ b/database/factories/ClaimFactory.php @@ -11,7 +11,7 @@ class ClaimFactory extends Factory * * @return array */ - public function definition() + public function definition(): array { return [ 'label' => fake()->words(rand(1, 2), true), diff --git a/database/factories/ConsumptionMomentFactory.php b/database/factories/ConsumptionMomentFactory.php index 0ca09ed8..63c71098 100644 --- a/database/factories/ConsumptionMomentFactory.php +++ b/database/factories/ConsumptionMomentFactory.php @@ -12,13 +12,15 @@ class ConsumptionMomentFactory extends Factory * * @return array */ - public function definition() + public function definition(): array { $title = fake()->words(rand(1, 2), true); return [ 'title' => $title, 'subtitle' => fake()->text(10), 'slug' => Str::of($title)->slug(), + 'description' => fake()->text(), + 'picture' => '', 'picture_alt' => fake()->sentence(), 'picture_title' => fake()->sentence(), ]; diff --git a/database/factories/DemarcheSlideFactory.php b/database/factories/DemarcheSlideFactory.php index 2c65f4ba..e03f9cf1 100644 --- a/database/factories/DemarcheSlideFactory.php +++ b/database/factories/DemarcheSlideFactory.php @@ -17,9 +17,10 @@ class DemarcheSlideFactory extends Factory $button1status = fake()->boolean(75); $button2status = fake()->boolean(75); $publishedStatus = fake()->boolean(75); - $publish_at = Carbon::now()->addMonth(); + $publishedAt = Carbon::now()->addMonth(); return [ 'title' => fake()->words(rand(1, 2), true), + 'picture' => '', 'picture_alt' => fake()->sentence(), 'picture_title' => fake()->sentence(), 'button_1_text' => $button1status ? fake()->sentence(3) : null, @@ -27,13 +28,14 @@ class DemarcheSlideFactory extends Factory 'button_2_text' => $button2status ? fake()->sentence(3) : null, 'button_2_url' => $button2status ? fake()->url() : null, 'text' => \clean(\fake()->randomHtml(1, 1)), + 'order' => 1, 'button_1_status' => $button1status, 'button_1_target' => $button1status ? fake()->boolean(75) : false, 'button_2_status' => $button2status, 'button_2_target' => $button2status ? fake()->boolean(75) : false, 'published' => $publishedStatus, - 'publish_at' => !$publishedStatus ? $publish_at : null, - 'unpublish_at' => !$publishedStatus ? $publish_at->copy()->addDays(rand(10, 20)) : null, + 'published_at' => $publishedStatus ? $publishedAt : null, + 'unpublished_at' => !$publishedStatus ? $publishedAt->copy()->addDays(rand(10, 20)) : null, ]; } } diff --git a/database/factories/DepartaimantsCollectionFactory.php b/database/factories/DepartaimantsCollectionFactory.php index 7e57166d..ec2181ef 100644 --- a/database/factories/DepartaimantsCollectionFactory.php +++ b/database/factories/DepartaimantsCollectionFactory.php @@ -19,7 +19,7 @@ class DepartaimantsCollectionFactory extends Factory * * @return array */ - public function definition() + public function definition(): array { $bigNumber = function () { // * prevent the first number from being 0 diff --git a/database/factories/DiscountFactory.php b/database/factories/DiscountFactory.php index 71b760a1..5b37b591 100644 --- a/database/factories/DiscountFactory.php +++ b/database/factories/DiscountFactory.php @@ -11,13 +11,16 @@ class DiscountFactory extends Factory * * @return array */ - public function definition() + public function definition(): array { return [ - 'picture_alt' => fake()->sentence(), - 'picture_title' => fake()->sentence(), - 'amount' => fake()->randomNumber(), - 'validity' => fake()->sentence(), + 'name' => fake()->word(), + 'desktop_image_available' => '', + 'desktop_image_unavailable' => '', + 'mobile_image_available' => '', + 'mobile_image_unavailable' => '', + 'code' => fake()->numberBetween(1, 10000), + 'value' => fake()->randomFloat(1, 1, 100), ]; } } diff --git a/database/factories/HistoricalMilestoneFactory.php b/database/factories/HistoricalMilestoneFactory.php index 63dae7b9..01a5178b 100644 --- a/database/factories/HistoricalMilestoneFactory.php +++ b/database/factories/HistoricalMilestoneFactory.php @@ -11,17 +11,20 @@ class HistoricalMilestoneFactory extends Factory * * @return array */ - public function definition() + public function definition(): array { return [ - 'year' => fake()->randomFloat(1, 1900, 2100), + 'year' => fake()->randomFloat(1, 1901, 2100), 'title' => fake()->words(rand(1, 2), true), 'description' => fake()->sentence(), + 'picture' => '', 'picture_alt' => fake()->sentence(), 'picture_title' => fake()->sentence(), 'video_id' => null, - 'picture_alt' => null, - 'picture_title' => null, + 'picto' => null, + 'picto_alt' => null, + 'picto_title' => null, + 'order' => 1, 'published' => fake()->boolean(75), ]; } diff --git a/database/factories/IncoNutritionalValueFactory.php b/database/factories/IncoNutritionalValueFactory.php index c9ab3e6f..0e4dd091 100644 --- a/database/factories/IncoNutritionalValueFactory.php +++ b/database/factories/IncoNutritionalValueFactory.php @@ -11,7 +11,7 @@ class IncoNutritionalValueFactory extends Factory * * @return array */ - public function definition() + public function definition(): array { return [ 'energy' => fake()->randomFloat(1, 0, 100), diff --git a/database/factories/KeyNumberFactory.php b/database/factories/KeyNumberFactory.php index 7edd1063..28b857d8 100644 --- a/database/factories/KeyNumberFactory.php +++ b/database/factories/KeyNumberFactory.php @@ -11,13 +11,15 @@ class KeyNumberFactory extends Factory * * @return array */ - public function definition() + public function definition(): array { return [ - 'text' => fake()->sentence(), + 'picto' => '', 'picto_alt' => fake()->sentence(), 'picto_title' => fake()->sentence(), + 'text' => fake()->sentence(), 'source' => fake()->sentence(), + 'order' => 1, 'published' => fake()->boolean(75), ]; } diff --git a/database/factories/MainSlideFactory.php b/database/factories/MainSlideFactory.php index 3b9d0cd1..94416082 100644 --- a/database/factories/MainSlideFactory.php +++ b/database/factories/MainSlideFactory.php @@ -15,27 +15,30 @@ class MainSlideFactory extends Factory * @return array * @phpcs:disable Generic.Metrics.CyclomaticComplexity.TooHigh */ - public function definition() + public function definition(): array { // @phpcs:enable $button1status = fake()->boolean(75); $button2status = fake()->boolean(75); $publishedStatus = fake()->boolean(75); - $publish_at = Carbon::now()->addMonth(); + $published_at = Carbon::now()->addMonth(); return [ 'title' => fake()->words(rand(1, 2), true), 'subtitle' => fake()->words(rand(1, 2), true), 'approach_id' => (fake()->boolean(50)) ? collect( Approach::query()->where('published', true)->where('type', ApproachTypeEnum::demarche)->get()->random(1) )->first()->getKey() : null, + 'background' => '', 'background_alt' => fake()->sentence(), 'background_title' => fake()->sentence(), + 'picture' => '', 'picture_alt' => fake()->sentence(), 'picture_title' => fake()->sentence(), 'button_1_text' => $button1status ? fake()->sentence(3) : null, 'button_1_url' => $button1status ? fake()->url() : null, 'button_2_text' => $button2status ? fake()->sentence(3) : null, 'button_2_url' => $button2status ? fake()->url() : null, + 'order' => 1, 'color_block' => fake()->unique()->safeHexColor(), 'button_1_color_text' => '#FFFFFF', 'button_1_color_background' => '#4E3238', @@ -47,8 +50,8 @@ class MainSlideFactory extends Factory 'button_2_target' => $button2status ? fake()->boolean(75) : false, 'new' => fake()->boolean(75), 'published' => fake()->boolean(75), - 'publish_at' => !$publishedStatus ? $publish_at : null, - 'unpublish_at' => !$publishedStatus ? $publish_at->copy()->addDays(rand(10, 20)) : null, + 'published_at' => $publishedStatus ? $published_at : null, + 'unpublished_at' => !$publishedStatus ? $published_at->copy()->addDays(rand(10, 20)) : null, ]; } } diff --git a/database/factories/MeatFactory.php b/database/factories/MeatFactory.php index 3c2cd8f0..6aca754b 100644 --- a/database/factories/MeatFactory.php +++ b/database/factories/MeatFactory.php @@ -12,7 +12,7 @@ class MeatFactory extends Factory * * @return array */ - public function definition() + public function definition(): array { $label = fake()->unique()->words(rand(1, 2), true); return [ @@ -20,11 +20,14 @@ class MeatFactory extends Factory 'subtitle' => fake()->text(10), 'slug' => Str::slug($label), 'description' => fake()->sentence(), + 'banner' => '', 'banner_alt' => fake()->sentence(), 'banner_title' => fake()->sentence(), + 'picture' => '', 'picture_alt' => fake()->sentence(), 'picture_title' => fake()->sentence(), 'color' => fake()->unique()->safeHexColor(), + 'order' => 1, 'published' => fake()->boolean(75), ]; } diff --git a/database/factories/MenuNodeDataFactory.php b/database/factories/MenuNodeDataFactory.php index 7be9b8f4..4bcfcb5a 100644 --- a/database/factories/MenuNodeDataFactory.php +++ b/database/factories/MenuNodeDataFactory.php @@ -2,6 +2,7 @@ namespace Database\Factories; +use App\Enums\Settings\MenuNodeType; use Illuminate\Database\Eloquent\Factories\Factory; class MenuNodeDataFactory extends Factory @@ -11,9 +12,10 @@ class MenuNodeDataFactory extends Factory * * @return array */ - public function definition() + public function definition(): array { return [ + 'type' => \collect(MenuNodeType::toArray())->random()->value, 'sub_label' => fake()->sentence(), 'title' => fake()->sentence(), 'text' => fake()->sentence(), @@ -22,9 +24,11 @@ class MenuNodeDataFactory extends Factory 'link_title' => fake()->sentence(), 'link_target' => fake()->boolean(), 'link_status' => fake()->boolean(), + 'picture' => '', 'picture_alt' => fake()->sentence(), 'picture_title' => fake()->sentence(), 'picture_status' => fake()->boolean(), + 'background_picture' => '', 'background_picture_alt' => fake()->sentence(), 'background_picture_title' => fake()->sentence(), ]; diff --git a/database/factories/NewsBreedingFactory.php b/database/factories/NewsBreedingFactory.php index 4127435c..8883f482 100644 --- a/database/factories/NewsBreedingFactory.php +++ b/database/factories/NewsBreedingFactory.php @@ -29,9 +29,11 @@ class NewsBreedingFactory extends Factory 'subtitle' => fake()->sentence(), 'content' => fake()->text(), 'slug' => Str::slug($title), + 'picture' => '', 'picture_alt' => fake()->sentence(), 'picture_title' => fake()->sentence(), 'associated_page' => collect(StaticPageType::getBreedingPages())->random(), + 'order' => 1, 'published' => $publishedStatus, 'publish_at' => !$publishedStatus ? $publish_at : null, 'unpublish_at' => !$publishedStatus ? $publish_at->copy()->addDays(rand(10, 20)) : null, diff --git a/database/factories/NewsCategoryFactory.php b/database/factories/NewsCategoryFactory.php index 25e42141..5ee06b3f 100644 --- a/database/factories/NewsCategoryFactory.php +++ b/database/factories/NewsCategoryFactory.php @@ -23,6 +23,8 @@ class NewsCategoryFactory extends Factory 'seo_description' => fake()->sentence(), 'title' => $title, 'slug' => Str::slug($title), + 'color' => fake()->numberBetween(), + 'order' => 1, 'published' => fake()->boolean(75), ]; } diff --git a/database/factories/NewsClubFactory.php b/database/factories/NewsClubFactory.php index c8964cc7..eab21819 100644 --- a/database/factories/NewsClubFactory.php +++ b/database/factories/NewsClubFactory.php @@ -22,11 +22,13 @@ class NewsClubFactory extends Factory return [ 'title' => $title, 'slug' => Str::slug($title), + 'picture' => '', 'picture_alt' => fake()->sentence(), 'picture_title' => fake()->sentence(), 'content' => fake()->text(), 'type' => \collect(NewsClubTypeEnum::toArray())->random()->value, 'multiple_answers' => fake()->boolean(50), + 'published' => fake()->boolean(75), ]; } } diff --git a/database/factories/NewsCorporateFactory.php b/database/factories/NewsCorporateFactory.php index 557b6585..581f0d52 100644 --- a/database/factories/NewsCorporateFactory.php +++ b/database/factories/NewsCorporateFactory.php @@ -23,6 +23,7 @@ class NewsCorporateFactory extends Factory 'title' => fake()->sentence(), 'content' => fake()->text(), 'url' => fake()->url(), + 'picture' => '', 'picture_alt' => fake()->sentence(), 'picture_title' => fake()->sentence(), 'published' => $publishedStatus, diff --git a/database/factories/NewsFactory.php b/database/factories/NewsFactory.php index d0e70329..8b9c9494 100644 --- a/database/factories/NewsFactory.php +++ b/database/factories/NewsFactory.php @@ -28,8 +28,10 @@ class NewsFactory extends Factory 'subtitle' => fake()->sentence(), 'content' => fake()->text(), 'slug' => Str::slug($title), + 'picture' => '', 'picture_alt' => fake()->sentence(), 'picture_title' => fake()->sentence(), + 'thumbnail' => '', 'thumbnail_alt' => fake()->sentence(), 'thumbnail_title' => fake()->sentence(), 'highlight' => false, diff --git a/database/factories/OfferFactory.php b/database/factories/OfferFactory.php index 7912eeaa..4ff37b9c 100644 --- a/database/factories/OfferFactory.php +++ b/database/factories/OfferFactory.php @@ -11,15 +11,17 @@ class OfferFactory extends Factory * * @return array */ - public function definition() + public function definition(): array { return [ 'title' => fake()->words(3, true), 'location' => fake()->words(5, true), 'contract' => fake()->words(5, true), 'function' => fake()->words(5, true), + 'picture' => '', 'picture_alt' => fake()->words(5, true), 'picture_title' => fake()->words(5, true), + 'link' => fake()->url(), 'description' => fake()->sentence(), 'published' => fake()->boolean(75), ]; diff --git a/database/factories/ProductFactory.php b/database/factories/ProductFactory.php index d0d0cb29..a897b1f3 100644 --- a/database/factories/ProductFactory.php +++ b/database/factories/ProductFactory.php @@ -9,6 +9,7 @@ use App\Models\Range; use App\Models\Submeat; use App\Models\Subrange; use Illuminate\Database\Eloquent\Factories\Factory; +use Illuminate\Support\Str; class ProductFactory extends Factory { @@ -17,16 +18,24 @@ class ProductFactory extends Factory * * @return array */ - public function definition() + public function definition(): array { + $label = fake()->words(3, true); $meatBoolean = fake()->boolean(50); $rangeBoolean = fake()->boolean(50); return [ - 'label' => fake()->words(3, true), + 'seo_title' => fake()->sentence(), + 'seo_description' => fake()->sentence(), + 'label' => $label, + 'claim_title' => fake()->words(3, true), + 'slug' => Str::slug($label), + 'picture' => '', 'picture_alt' => fake()->words(5, true), 'picture_title' => fake()->words(5, true), + 'banner' => '', 'banner_alt' => fake()->words(5, true), 'banner_title' => fake()->words(5, true), + 'packaging' => '', 'packaging_alt' => fake()->words(5, true), 'packaging_title' => fake()->words(5, true), 'description' => fake()->sentence(), diff --git a/database/factories/ProductTypeFactory.php b/database/factories/ProductTypeFactory.php index 16f13132..98873b45 100644 --- a/database/factories/ProductTypeFactory.php +++ b/database/factories/ProductTypeFactory.php @@ -11,11 +11,12 @@ class ProductTypeFactory extends Factory * * @return array */ - public function definition() + public function definition(): array { return [ 'label' => fake()->words(rand(1, 2), true), 'description' => fake()->sentence(), + 'picture' => '', 'picture_alt' => fake()->sentence(), 'picture_title' => fake()->sentence(), 'button_status' => fake()->boolean(75), diff --git a/database/factories/ProfessionFactory.php b/database/factories/ProfessionFactory.php index 2d6cc568..89a00f1c 100644 --- a/database/factories/ProfessionFactory.php +++ b/database/factories/ProfessionFactory.php @@ -23,10 +23,11 @@ class ProfessionFactory extends Factory return [ 'title' => fake()->firstName, - 'picture_title' => fake()->words(5, true), + 'picture' => '', 'picture_alt' => fake()->words(8, true), - 'job_url' => fake()->url(), + 'picture_title' => fake()->words(5, true), 'jobs_list' => $jobsList, + 'job_url' => fake()->url(), 'published' => fake()->boolean(75), ]; } diff --git a/database/factories/RangeFactory.php b/database/factories/RangeFactory.php index 5221048b..ed69c626 100644 --- a/database/factories/RangeFactory.php +++ b/database/factories/RangeFactory.php @@ -12,7 +12,7 @@ class RangeFactory extends Factory * * @return array */ - public function definition() + public function definition(): array { $label = fake()->unique()->words(rand(1, 2), true); return [ @@ -20,13 +20,17 @@ class RangeFactory extends Factory 'subtitle' => fake()->text(10), 'slug' => Str::slug($label), 'description' => fake()->sentence(), + 'banner' => '', 'banner_alt' => fake()->sentence(), 'banner_title' => fake()->sentence(), + 'banner_ambiance' => '', 'banner_ambiance_alt' => fake()->sentence(), 'banner_ambiance_title' => fake()->sentence(), + 'picture' => '', 'picture_alt' => fake()->sentence(), 'picture_title' => fake()->sentence(), 'color' => fake()->unique()->safeHexColor(), + 'order' => 1, 'published' => fake()->boolean(75), ]; } diff --git a/database/factories/RecipeFactory.php b/database/factories/RecipeFactory.php index d073fe3d..a1f2ed8b 100644 --- a/database/factories/RecipeFactory.php +++ b/database/factories/RecipeFactory.php @@ -30,20 +30,24 @@ class RecipeFactory extends Factory } return [ + 'seo_title' => fake()->sentence(), + 'seo_description' => fake()->sentence(), 'slug' => Str::slug($title), 'title' => $title, 'tips' => fake()->sentence(), + 'picture' => '', 'picture_alt' => fake()->words(8, true), 'picture_title' => fake()->words(5, true), - 'advice' => fake()->sentence(), - 'preparation' => fake()->sentence(), 'ingredients_list' => $ingredientsList, + 'preparation' => fake()->sentence(), + 'advice' => fake()->sentence(), 'video_id' => fake()->boolean(50) ? \collect(Video::all())->random() : null, 'consumption_moment_id' => \collect(ConsumptionMoment::all())->random(), 'preparation_time' => fake()->numberBetween(1, 100), 'cooking_time' => fake()->numberBetween(1, 100), 'nb_guests' => fake()->numberBetween(1, 10), 'difficulty' => \collect(DifficultyEnum::toArray())->random()->value, + 'highlight' => fake()->boolean(75), 'published' => fake()->boolean(75), ]; } diff --git a/database/factories/SellItemFactory.php b/database/factories/SellItemFactory.php new file mode 100644 index 00000000..4159b784 --- /dev/null +++ b/database/factories/SellItemFactory.php @@ -0,0 +1,32 @@ + + */ +class SellItemFactory extends Factory +{ + /** + * Define the model's default state. + * + * @return array + */ + public function definition(): array + { + return [ + 'name' => fake()->words(rand(1, 2), true), + 'picture' => '', + 'picture_alt' => fake()->sentence(), + 'picture_title' => fake()->sentence(), + 'price' => fake()->numberBetween(1, 100), + 'arcadia_weight' => fake()->numberBetween(1, 100), + 'arcadia_id' => fake()->unique()->numberBetween(100, 500), + 'order' => 1, + 'type' => \collect(SellItemsType::toArray())->random()->value, + ]; + } +} diff --git a/database/factories/StaticPageFactory.php b/database/factories/StaticPageFactory.php new file mode 100644 index 00000000..24f5fa33 --- /dev/null +++ b/database/factories/StaticPageFactory.php @@ -0,0 +1,36 @@ + + */ +class StaticPageFactory extends Factory +{ + /** + * Define the model's default state. + * + * @return array + */ + public function definition(): array + { + $title = fake()->unique()->words(rand(1, 2), true); + return [ + 'type' => \collect(StaticPageType::toArray())->random()->value, + 'seo_title' => fake()->sentence(), + 'seo_description' => fake()->sentence(), + 'title' => $title, + 'slug' => Str::slug($title), + 'subtitle' => fake()->words(rand(1, 2), true), + 'picture' => '', + 'picture_alt' => fake()->sentence(), + 'picture_title' => fake()->sentence(), + 'content' => fake()->sentence(), + 'data' => [], + ]; + } +} diff --git a/database/factories/SubmeatFactory.php b/database/factories/SubmeatFactory.php index 94101f1e..b6bbd70e 100644 --- a/database/factories/SubmeatFactory.php +++ b/database/factories/SubmeatFactory.php @@ -2,6 +2,7 @@ namespace Database\Factories; +use App\Models\Meat; use Illuminate\Database\Eloquent\Factories\Factory; use Illuminate\Support\Str; @@ -12,7 +13,7 @@ class SubmeatFactory extends Factory * * @return array */ - public function definition() + public function definition(): array { $label = fake()->unique()->words(rand(1, 2), true); return [ @@ -20,8 +21,11 @@ class SubmeatFactory extends Factory 'subtitle' => fake()->text(10), 'slug' => Str::slug($label), 'description' => fake()->sentence(), + 'picture' => '', 'picture_alt' => fake()->sentence(), 'picture_title' => fake()->sentence(), + 'meat_id' => Meat::query()->where('published', true)->inRandomOrder()->value('id'), + 'order' => 1, 'published' => fake()->boolean(75), ]; } diff --git a/database/factories/SubrangeFactory.php b/database/factories/SubrangeFactory.php index 2994d8f4..f3f1cec1 100644 --- a/database/factories/SubrangeFactory.php +++ b/database/factories/SubrangeFactory.php @@ -2,6 +2,7 @@ namespace Database\Factories; +use App\Models\Range; use Illuminate\Database\Eloquent\Factories\Factory; use Illuminate\Support\Str; @@ -12,7 +13,7 @@ class SubrangeFactory extends Factory * * @return array */ - public function definition() + public function definition(): array { $label = fake()->unique()->words(rand(1, 2), true); return [ @@ -20,8 +21,11 @@ class SubrangeFactory extends Factory 'subtitle' => fake()->text(10), 'slug' => Str::slug($label), 'description' => fake()->sentence(), + 'picture' => '', 'picture_alt' => fake()->sentence(), 'picture_title' => fake()->sentence(), + 'range_id' => Range::query()->where('published', true)->inRandomOrder()->value('id'), + 'order' => 1, 'published' => fake()->boolean(75), ]; } diff --git a/database/factories/SurveysAnswerFactory.php b/database/factories/SurveysAnswerFactory.php index fd7b524f..a0b94c7a 100644 --- a/database/factories/SurveysAnswerFactory.php +++ b/database/factories/SurveysAnswerFactory.php @@ -20,8 +20,9 @@ class SurveysAnswerFactory extends Factory { return [ 'news_club_id' => NewsClub::query()->where('type', NewsClubTypeEnum::survey)->inRandomOrder()->value('id'), - 'answer' => fake()->unique()->words(rand(1, 2), true), + 'order' => 1, 'published' => fake()->boolean(75), + 'answer' => fake()->unique()->words(rand(1, 2), true), ]; } } diff --git a/database/factories/TestimonialFactory.php b/database/factories/TestimonialFactory.php index da5a9bd2..506fcca4 100644 --- a/database/factories/TestimonialFactory.php +++ b/database/factories/TestimonialFactory.php @@ -11,17 +11,19 @@ class TestimonialFactory extends Factory * * @return array */ - public function definition() + public function definition(): array { return [ 'catchline' => fake()->text(25), 'content' => fake()->text(150), 'identity' => fake()->name(), 'job' => fake()->jobTitle(), + 'picture' => '', 'picture_alt' => fake()->sentence(), 'picture_title' => fake()->sentence(), 'video_id' => fake()->boolean(25) ? '6B4O-_1CQoI' : '', - 'published' => false, + 'order' => 1, + 'published' => fake()->boolean(75), ]; } } diff --git a/database/factories/UserFactory.php b/database/factories/UserFactory.php index 121dc9bb..e5d66115 100644 --- a/database/factories/UserFactory.php +++ b/database/factories/UserFactory.php @@ -21,12 +21,11 @@ class UserFactory extends Factory 'first_name' => fake()->firstName, 'last_name' => fake()->lastName, 'email' => fake()->unique()->safeEmail(), - 'email_verified_at' => now(), - 'password' => '$2y$10$92IXUNpkjO0rOQ5byMi.Ye4oKoEa3Ro9llC/.og/at2.uheWG/igi', 'remember_token' => Str::random(10), 'role' => $randEnum->value, - 'published' => $published, - 'published_at' => ($published) ? now() : null, + 'last_connection' => ($published) ? now() : null, + 'published' => true, + 'published_at' => now(), ]; } diff --git a/database/factories/VideoFactory.php b/database/factories/VideoFactory.php index 03abccdf..c185c6a5 100644 --- a/database/factories/VideoFactory.php +++ b/database/factories/VideoFactory.php @@ -11,11 +11,12 @@ class VideoFactory extends Factory * * @return array */ - public function definition() + public function definition(): array { return [ 'title' => fake()->unique()->words(rand(1, 2), true), 'video_id' => '7rpgfetac0U', + 'order' => 1, 'is_on_homepage' => fake()->boolean(25), 'published' => fake()->boolean(75), ]; diff --git a/database/migrations/2024_21_27_123912_alter_tables_for_unit_tests.php b/database/migrations/2024_21_27_123912_alter_tables_for_unit_tests.php new file mode 100644 index 00000000..9594e7d4 --- /dev/null +++ b/database/migrations/2024_21_27_123912_alter_tables_for_unit_tests.php @@ -0,0 +1,54 @@ +renameColumn('publish_at', 'published_at'); + $table->renameColumn('unpublish_at', 'unpublished_at'); + }); + + Schema::table('historical_milestones', function (Blueprint $table) { + $table->tinyInteger('picto_position')->nullable()->comment('Historical milestone picto position.')->after('picto_title'); + $table->integer('order')->comment('Historical milestone order.')->after('published')->change(); + }); + HistoricalMilestone::query()->where('picto_placement', 'hg')->get()->map(function (HistoricalMilestone $historicalMilestoneModel) { + $historicalMilestoneModel->picto_position = HistoricalMilestonePosition::topLeft; + $historicalMilestoneModel->saveQuietly(); + }); + HistoricalMilestone::query()->where('picto_placement', 'hd')->get()->map(function (HistoricalMilestone $historicalMilestoneModel) { + $historicalMilestoneModel->picto_position = HistoricalMilestonePosition::topRight; + $historicalMilestoneModel->saveQuietly(); + }); + Schema::table('historical_milestones', function (Blueprint $table) { + $table->dropColumn('picto_placement'); + }); + + Schema::table('main_slides', function (Blueprint $table) { + $table->renameColumn('publish_at', 'published_at'); + $table->renameColumn('unpublish_at', 'unpublished_at'); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down(): void + { + // + } +}; diff --git a/phpunit.xml b/phpunit.xml index eb13aff1..0a95d087 100644 --- a/phpunit.xml +++ b/phpunit.xml @@ -1,31 +1,32 @@ - - - - ./tests/Unit - - - ./tests/Feature - - - - - ./app - - - - - - - - - - - - - + + + + + + + + + + ./tests/Back + + + + + + + + + + + + + + + + + ./app + + + diff --git a/resources/lang/en/validation.php b/resources/lang/en/validation.php index 68d81e50..8c280482 100644 --- a/resources/lang/en/validation.php +++ b/resources/lang/en/validation.php @@ -282,6 +282,7 @@ return [ 'order' => 'order', 'packaging' => 'packaging', 'picto' => 'pictogram', + 'picto_position' => 'pictogram position', 'preparation_time' => 'preparation time (in minutes)', 'preparation' => 'preparation', 'price' => 'price', diff --git a/resources/lang/fr/validation.php b/resources/lang/fr/validation.php index d78bfd7f..c2d53d08 100644 --- a/resources/lang/fr/validation.php +++ b/resources/lang/fr/validation.php @@ -288,6 +288,7 @@ return [ 'order' => 'ordre', 'packaging' => 'emballage', 'picto' => 'pictogramme', + 'picto_position' => 'position du pictogramme', 'preparation_time' => 'temps de préparation (en minutes)', 'preparation' => 'préparation', 'price' => 'prix', diff --git a/resources/sass/bo/pages/.gitkeep b/resources/sass/bo/pages/.gitkeep deleted file mode 100644 index e69de29b..00000000 diff --git a/resources/sass/bo/partials/.gitkeep b/resources/sass/bo/partials/.gitkeep deleted file mode 100644 index e69de29b..00000000 diff --git a/resources/views/bo/layouts/header.blade.php b/resources/views/bo/layouts/header.blade.php index 45f5f549..6258c0ef 100644 --- a/resources/views/bo/layouts/header.blade.php +++ b/resources/views/bo/layouts/header.blade.php @@ -98,8 +98,8 @@ value="{{ $bootstrapTheme->value }}"> @endforeach diff --git a/resources/views/bo/layouts/sidemenu.blade.php b/resources/views/bo/layouts/sidemenu.blade.php index 3ba523d2..b71d213b 100644 --- a/resources/views/bo/layouts/sidemenu.blade.php +++ b/resources/views/bo/layouts/sidemenu.blade.php @@ -821,33 +821,11 @@ {{-- BREEDING --}} - + {{-- BREEDER MAP --}} + {{-- FIXME: uncomment when breeder map feature is ready --}} + {{--
  • + url()->current() === route('bo.general_settings.edit', \App\Enums\Settings\SettingsType::breederMap->value()), + ])> + url()->current() === route('bo.general_settings.edit', \App\Enums\Settings\SettingsType::breederMap->value()), + ])> + {{ $breederMapSettingModel->type->label() }} + +
  • --}} + + + @endif {{-- ACTUALITES --}} - + ])> + + url()->current() === + route('bo.static_pages.edit', $newsStaticPageModel->type->value()), + ])> + {{ str(__('Page Actualités'))->ucFirst() }} + + + {{-- ACTUS LE GAULOIS --}} +
  • + request()->routeIs('bo.news.*'), + ])> + request()->routeIs('bo.news.*'), + ])> + {{ str(__('Actus le Gaulois'))->ucFirst() }} + +
  • + {{-- ACTUS CATEGORY --}} +
  • + request()->routeIs('bo.news_categories.*'), + ])> + request()->routeIs('bo.news_categories.*'), + ])> + {{ str(__('Catégories des actualités'))->ucFirst() }} + +
  • + + + @endif {{-- CLUB --}} @endauth diff --git a/resources/views/bo/pages/demarche_slides/form.blade.php b/resources/views/bo/pages/demarche_slides/form.blade.php index c0824dbe..18ccc39d 100644 --- a/resources/views/bo/pages/demarche_slides/form.blade.php +++ b/resources/views/bo/pages/demarche_slides/form.blade.php @@ -325,29 +325,29 @@ {{-- PUBLICATION DATES --}}
    - {{-- PUBLISH_AT --}} + {{-- PUBLISHED_AT --}}
    @include('bo.partials.inputs.timestamp-datetime', [ - 'label' => str(__('validation.custom.publish_at'))->ucFirst() . __(' (Europe/Paris)'), + 'label' => str(__('validation.custom.published_at'))->ucFirst() . __(' (Europe/Paris)'), 'id' => 'demarcheSlidePublishedAt', - 'name' => 'publish_at', + 'name' => 'published_at', 'model' => $demarcheSlideModel ?? null, - 'helper' => __('crud.helpers.publish_at', [ + 'helper' => __('crud.helpers.published_at', [ 'model' => str(__('models.classes.demarche_slide'))->ucFirst(), ]), ])
    - {{-- UNPUBLISH_AT --}} + {{-- UNPUBLISHED_AT --}}
    @include('bo.partials.inputs.timestamp-datetime', [ - 'label' => str(__('validation.custom.unpublish_at'))->ucfirst() . __(' (Europe/Paris)'), + 'label' => str(__('validation.custom.unpublished_at'))->ucfirst() . __(' (Europe/Paris)'), 'id' => 'demarcheSlideUnPublishedAt', - 'name' => 'unpublish_at', + 'name' => 'unpublished_at', 'model' => $demarcheSlideModel ?? null, - 'helper' => __('crud.helpers.unpublish_at', [ + 'helper' => __('crud.helpers.unpublished_at', [ 'model' => str(__('models.classes.demarche_slide'))->ucFirst(), ]), ]) diff --git a/resources/views/bo/pages/discounts/index-list.blade.php b/resources/views/bo/pages/discounts/index-list.blade.php index 59dc5fa2..ba1e7373 100644 --- a/resources/views/bo/pages/discounts/index-list.blade.php +++ b/resources/views/bo/pages/discounts/index-list.blade.php @@ -26,7 +26,13 @@ {{ $discountModel->updated_at->isoFormat('LLLL') }} {{-- Keep empty for actions collumn --}} - + + + + + @endforeach diff --git a/resources/views/bo/pages/discounts/show.blade.php b/resources/views/bo/pages/discounts/show.blade.php new file mode 100644 index 00000000..d7b88785 --- /dev/null +++ b/resources/views/bo/pages/discounts/show.blade.php @@ -0,0 +1,82 @@ +@extends('bo.layout', ['brParam' => $discountModel]) + +@section('title', __('Aperçu d\'une :model', ['model' => __('models.classes.claim')])) +@section('description', __('Aperçu d\'une :model déjà existante', ['model' => __('models.classes.claim')])) +@section('breadcrumb', request()->route()->getName()) + +@section('content') +
    +
    + + + + @include('modules.breadcrumbs.breadcrumb-body', ['brParam' => $discountModel]) +
    +
    +
    +
    +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    {{ str(__('validation.attributes.name'))->ucFirst() }} + {{ $discountModel->name }} +
    {{ str(__('validation.custom.code'))->ucFirst() }} + {{ $discountModel->code }} +
    {{ str(__('validation.custom.value'))->ucFirst() }} + @money($discountModel->value) +
    {{ str(__('validation.attributes.created_at'))->ucFirst() }} + {{ str($discountModel->created_at->isoFormat('LLLL'))->ucFirst() }} +
    {{ str(__('validation.attributes.image'))->ucFirst() }} + {{ __('Image disponible pour ordinateur') }} +
    {{ str(__('validation.attributes.image'))->ucFirst() }} + {{ __('Image indisponible pour ordinateur') }} +
    {{ str(__('validation.attributes.image'))->ucFirst() }} + {{ __('Image disponible pour mobile') }} +
    {{ str(__('validation.attributes.image'))->ucFirst() }} + {{ __('Image indisponible pour mobile') }} +
    {{ str(__('validation.attributes.updated_at'))->ucFirst() }} + {{ str($discountModel->updated_at->isoFormat('LLLL'))->ucFirst() }} +
    +
    +
    +
    +@endsection diff --git a/resources/views/bo/pages/historical_milestones/form.blade.php b/resources/views/bo/pages/historical_milestones/form.blade.php index ee92ec90..7e25b65e 100644 --- a/resources/views/bo/pages/historical_milestones/form.blade.php +++ b/resources/views/bo/pages/historical_milestones/form.blade.php @@ -258,32 +258,24 @@ 'preview' => true, ])
    - {{-- EMPLACEMENT --}}
    -
    - {{ str(__('validation.custom.emplacement'))->ucfirst() }} -
    -
    - @include('bo.partials.inputs.tinyint-enum', [ - 'id' => 'pictoPlacement', - 'label' => sprintf( - '%s %s %s', - str(__('validation.custom.emplacement'))->ucfirst(), - __('validation.custom.of_the.male'), - __('validation.custom.picto')), - 'name' => 'picto_placement', - 'model' => $historicalMilestoneModel ?? null, - 'required' => false, - 'value' => $historicalMilestoneModel->picto_placement, - 'associatedModels' => \App\Enums\HistoricalMilestonePosition::toArray(), - 'helper' => __('crud.minicrud.select_entity', [ - 'entity' => sprintf('un seul et unique %s', __('validation.custom.emplacement')), - ]), - ]) -
    -
    -
    + @include('bo.partials.inputs.tinyint-enum', [ + 'id' => 'pictoPlacement', + 'label' => sprintf( + '%s %s %s', + str(__('validation.custom.emplacement'))->ucfirst(), + __('validation.custom.of_the.male'), + __('validation.custom.picto')), + 'name' => 'picto_position', + 'model' => $historicalMilestoneModel ?? null, + 'required' => false, + 'value' => $historicalMilestoneModel->picto_position, + 'associatedModels' => \App\Enums\HistoricalMilestones\HistoricalMilestonePosition::toArray(), + 'helper' => __('crud.minicrud.select_entity', [ + 'entity' => sprintf('un seul et unique %s', __('validation.custom.emplacement')), + ]), + ])
    diff --git a/resources/views/bo/pages/main_slides/form.blade.php b/resources/views/bo/pages/main_slides/form.blade.php index 265cee62..7b02aa19 100644 --- a/resources/views/bo/pages/main_slides/form.blade.php +++ b/resources/views/bo/pages/main_slides/form.blade.php @@ -555,33 +555,33 @@ {{-- PUBLICATION DATES --}}
    - {{-- PUBLISH_AT --}} + {{-- PUBLISHED_AT --}}
    @include('bo.partials.inputs.timestamp-datetime', [ 'label' => - str(__('validation.custom.publish_at'))->ucFirst() . + str(__('validation.custom.published_at'))->ucFirst() . __(' (Europe/Paris)'), 'id' => 'mainSlidePublishedAt', - 'name' => 'publish_at', + 'name' => 'published_at', 'model' => $mainSlideModel ?? null, - 'helper' => __('crud.helpers.publish_at', [ + 'helper' => __('crud.helpers.published_at', [ 'model' => str(__('models.classes.main_slide'))->ucFirst(), ]), ])
    - {{-- UNPUBLISH_AT --}} + {{-- UNPUBLISHED_AT --}}
    @include('bo.partials.inputs.timestamp-datetime', [ 'label' => - str(__('validation.custom.unpublish_at'))->ucfirst() . + str(__('validation.custom.unpublished_at'))->ucfirst() . __(' (Europe/Paris)'), 'id' => 'mainSlideUnPublishedAt', - 'name' => 'unpublish_at', + 'name' => 'unpublished_at', 'model' => $mainSlideModel ?? null, - 'helper' => __('crud.helpers.unpublish_at', [ + 'helper' => __('crud.helpers.unpublished_at', [ 'model' => str(__('models.classes.main_slide'))->ucFirst(), ]), ]) diff --git a/resources/views/bo/pages/main_slides/show.blade.php b/resources/views/bo/pages/main_slides/show.blade.php index 35f81be6..39243160 100644 --- a/resources/views/bo/pages/main_slides/show.blade.php +++ b/resources/views/bo/pages/main_slides/show.blade.php @@ -53,19 +53,15 @@ {{ $mainSlideModel->title }} - - {{ str(__('validation.attributes.text'))->ucFirst() }} - -
    - {!! clean($mainSlideModel->text) !!} -
    - - {{ str(__('validation.attributes.image'))->ucFirst() }} - {{ $mainSlideModel->picture_alt }} + @if($mainSlideModel->picture) + {{ $mainSlideModel->picture_alt }} + @else + {{ __('Aucune image enregistrée') }} + @endif @@ -73,7 +69,7 @@ {{ str(__('validation.custom.publication'))->ucFirst() }} - {{ $mainSlideModel->published + {{ $mainSlideModel->published_at ? str($mainSlideModel->published_at->isoFormat('LLLL'))->ucFirst() : ($mainSlideModel->unpublished_at ?: __('crud.other.model_not_published')) }} diff --git a/resources/views/fo/pages/story.blade.php b/resources/views/fo/pages/story.blade.php index 1e1a8eb8..c00d91e5 100644 --- a/resources/views/fo/pages/story.blade.php +++ b/resources/views/fo/pages/story.blade.php @@ -196,7 +196,7 @@
    iteration % 2 ? 'rotate-right' : 'rotate-left', ])> @if (isset($historicalMilestoneModel->picto) && $historicalMilestoneModel->picto !== null) @@ -204,7 +204,7 @@ title="{{ $historicalMilestoneModel->picto_title }}" alt="{{ $historicalMilestoneModel->picto_alt }}" @class([ 'slider-picto position-absolute img-fluid z-1', - $historicalMilestoneModel->picto_placement === 'hg' + $historicalMilestoneModel->picto_position->equals(\App\Enums\HistoricalMilestones\HistoricalMilestonePosition::topLeft) ? 'slider-picto' : 'slider-picto-reversed', ])> diff --git a/routes/breadcrumbs-bo.php b/routes/breadcrumbs-bo.php index 6229c2f6..b94f6dc6 100644 --- a/routes/breadcrumbs-bo.php +++ b/routes/breadcrumbs-bo.php @@ -10,6 +10,7 @@ use App\Models\Profession; use App\Models\BrandAdvantage; use App\Models\Claim; use App\Models\ConsumptionMoment; +use App\Models\Discount; use App\Models\MainSlide; use App\Models\GeneralSetting; use App\Models\HistoricalMilestone; @@ -748,6 +749,10 @@ Breadcrumbs::for('bo.discounts.index', function (Generator $trail) { route('bo.discounts.index') ); }); +Breadcrumbs::for('bo.discounts.show', function (Generator $trail, Discount $discount) { + $trail->parent('bo.discounts.index'); + $trail->push(Str::ucfirst(trans('crud.actions.view')), route('bo.discounts.show', $discount)); +}); // * SELL ITEMS Breadcrumbs::for('bo.sell_items.index', function (Generator $trail) { diff --git a/routes/web-bo.php b/routes/web-bo.php index f3714b8d..3320ba65 100644 --- a/routes/web-bo.php +++ b/routes/web-bo.php @@ -546,7 +546,7 @@ Route::middleware(['throttle:web', 'admin-secure'])->prefix('bo')->name('bo.')-> ])->name('surveys_answers.duplicate'); // * DISCOUNTS. - Route::get('/discounts', [DiscountController::class, 'index'])->name('discounts.index'); + Route::resource('discounts', DiscountController::class); Route::get('/discounts/update', [DiscountController::class, 'updateList'])->name('discounts.update'); // * SELL ITEMS. diff --git a/tests/Back/ActivityLogTest.php b/tests/Back/ActivityLogTest.php new file mode 100644 index 00000000..dc24f07a --- /dev/null +++ b/tests/Back/ActivityLogTest.php @@ -0,0 +1,76 @@ +get(route( + config('unit-tests.route.prefix') . + 'activity_logs.' . + config('unit-tests.view.resources-index') + )); + $response->assertRedirect(route(config('unit-tests.route.prefix') . 'login')); + } + + /** @return void */ + public function testGuestCannotAccessActivityLogsReadView(): void + { + $model = ActivityLog::factory()->createOneQuietly(); + $response = $this->get(route( + config('unit-tests.route.prefix') . + 'activity_logs.' . + config('unit-tests.view.resources-read'), + $model->getKey() + )); + $response->assertRedirect(route(config('unit-tests.route.prefix') . 'login')); + } + + /** + * TESTS USER CONCEPTOR ACCESS VIEWS. + */ + + /** @return void */ + public function testUserConceptorCanAccessActivityLogsIndexView(): void + { + $authModel = AuthModel::factory()->createOneQuietly(); + $authModel->update(['role' => RoleEnum::conceptor]); + $response = $this->actingAs($authModel, 'backend')->get( + route(config('unit-tests.route.prefix') . 'activity_logs.' . config('unit-tests.view.resources-index')) + ); + $response->assertSuccessful(); + $response->assertViewIs( + config('unit-tests.view.prefix') . + 'pages.activity_logs.' . + config('unit-tests.view.resources-index') + ); + } + + /** @return void */ + public function testUserConceptorCanAccessActivityLogsReadView(): void + { + $authModel = AuthModel::factory()->createOneQuietly(); + $authModel->update(['role' => RoleEnum::conceptor]); + $model = ActivityLog::factory()->createOneQuietly(); + $response = $this->actingAs($authModel, 'backend')->get( + route(config('unit-tests.route.prefix') . 'activity_logs.' . config('unit-tests.view.resources-read'), $model) + ); + $response->assertSuccessful(); + $response->assertViewIs( + config('unit-tests.view.prefix') . + 'pages.activity_logs.' . + config('unit-tests.view.resources-read') + ); + } +} diff --git a/tests/Back/ApproachDemarcheTest.php b/tests/Back/ApproachDemarcheTest.php new file mode 100644 index 00000000..63e118c1 --- /dev/null +++ b/tests/Back/ApproachDemarcheTest.php @@ -0,0 +1,227 @@ +get(route( + config('unit-tests.route.prefix') . + 'approaches.' . + config('unit-tests.view.resources-index'), + ['approach_type' => ApproachTypeEnum::demarche->value()] + )); + $response->assertRedirect(route(config('unit-tests.route.prefix') . 'login')); + } + + /** @return void */ + public function testGuestCannotAccessApproachsReadView(): void + { + $model = Approach::factory()->createOneQuietly(); + $response = $this->get(route( + config('unit-tests.route.prefix') . + 'approaches.' . + config('unit-tests.view.resources-read'), + $model->getKey() + )); + $response->assertRedirect(route(config('unit-tests.route.prefix') . 'login')); + } + + /** @return void */ + public function testGuestCannotAccessApproachsCreateView(): void + { + $response = $this->get(route( + config('unit-tests.route.prefix') . + 'approaches.' . + config('unit-tests.view.resources-create'), + ['approach_type' => ApproachTypeEnum::demarche->value()] + )); + $response->assertRedirect(route(config('unit-tests.route.prefix') . 'login')); + } + + /** @return void */ + public function testGuestCannotAccessApproachsUpdateView(): void + { + $model = Approach::factory()->createOneQuietly(); + $response = $this->get(route( + config('unit-tests.route.prefix') . + 'approaches.' . + config('unit-tests.view.resources-update'), + $model->getKey() + )); + $response->assertRedirect(route(config('unit-tests.route.prefix') . 'login')); + } + + /** + * TESTS GUEST CANNOT POST MODEL. + */ + + /** @return void */ + public function testGuestCannotCreateApproach(): void + { + $model = Approach::factory()->createOneQuietly(); + $response = $this->post( + route( + config('unit-tests.route.prefix') . 'approaches.' . config('unit-tests.route.action-create'), + $model->getKey() + ), + $model->toArray() + ); + $response->assertRedirect(route(config('unit-tests.route.prefix') . 'login')); + } + + /** @return void */ + public function testGuestCannotUpdateApproach(): void + { + $model = Approach::factory()->createOneQuietly(); + $response = $this->patch( + route( + config('unit-tests.route.prefix') . 'approaches.' . config('unit-tests.route.action-update'), + $model->getKey() + ), + $model->toArray() + ); + $response->assertRedirect(route(config('unit-tests.route.prefix') . 'login')); + } + + /** @return void */ + public function testGuestCannotDeleteApproach(): void + { + $model = Approach::factory()->createOneQuietly(); + $response = $this->delete( + route( + config('unit-tests.route.prefix') . 'approaches.' . config('unit-tests.route.action-delete'), + $model->getKey() + ), + $model->toArray() + ); + $response->assertRedirect(route(config('unit-tests.route.prefix') . 'login')); + } + + /** + * TESTS USER CONCEPTOR ACCESS VIEWS. + */ + + /** @return void */ + public function testUserConceptorCanAccessApproachsIndexView(): void + { + $authModel = AuthModel::factory()->createOneQuietly(); + $authModel->update(['role' => RoleEnum::conceptor]); + $response = $this->actingAs($authModel, 'backend')->get( + route( + config('unit-tests.route.prefix') . 'approaches.' . config('unit-tests.view.resources-index'), + ['approach_type' => ApproachTypeEnum::demarche->value()] + ) + ); + $response->assertSuccessful(); + $response->assertViewIs( + config('unit-tests.view.prefix') . + 'pages.approaches.' . + config('unit-tests.view.resources-index') + ); + } + + /** @return void */ + public function testUserConceptorCanAccessApproachsReadView(): void + { + $authModel = AuthModel::factory()->createOneQuietly(); + $authModel->update(['role' => RoleEnum::conceptor]); + $model = Approach::factory()->createOneQuietly(); + $response = $this->actingAs($authModel, 'backend')->get( + route(config('unit-tests.route.prefix') . 'approaches.' . config('unit-tests.view.resources-read'), $model) + ); + $response->assertSuccessful(); + $response->assertViewIs( + config('unit-tests.view.prefix') . + 'pages.approaches.' . + config('unit-tests.view.resources-read') + ); + } + + /** @return void */ + public function testUserConceptorCanAccessApproachsCreateView(): void + { + $authModel = AuthModel::factory()->createOneQuietly(); + $authModel->update(['role' => RoleEnum::conceptor]); + $response = $this->actingAs($authModel, 'backend')->get( + route( + config('unit-tests.route.prefix') . 'approaches.' . config('unit-tests.view.resources-create'), + ['approach_type' => ApproachTypeEnum::demarche->value()] + ) + ); + $response->assertSuccessful(); + $response->assertViewIs( + config('unit-tests.view.prefix') . + 'pages.approaches.' . + config('unit-tests.view.resources-create') + ); + } + + /** @return void */ + public function testUserConceptorCanAccessApproachsUpdateView(): void + { + $authModel = AuthModel::factory()->createOneQuietly(); + $authModel->update(['role' => RoleEnum::conceptor]); + $model = Approach::factory()->createOneQuietly(); + $response = $this->actingAs($authModel, 'backend')->get( + route(config('unit-tests.route.prefix') . 'approaches.' . config('unit-tests.view.resources-update'), $model) + ); + $response->assertSuccessful(); + $response->assertViewIs( + config('unit-tests.view.prefix') . + 'pages.approaches.' . + config('unit-tests.view.resources-update') + ); + } + + /** + * TESTS CAN ACTIONS ON MODEL. + */ + + /** @return void */ + public function testCanCreateApproach(): void + { + $model = Approach::factory()->createOneQuietly(); + $this->assertModelExists($model); + } + + /** @return void */ + public function testCanUpdateApproach(): void + { + $model = Approach::factory()->createOneQuietly(); + + $fieldTest = ""; + foreach (config('unit-tests.list-fields') as $field) { + if (Schema::hasColumn($model->getTable(), $field)) { + $model->update([$field => "test"]); + $fieldTest = $field; + break; + } + } + + $this->assertTrue($model->wasChanged()); + $this->assertTrue(array_key_exists($fieldTest, $model->getChanges())); + $this->assertModelExists($model); + } + + /** @return void */ + public function testCanDeleteApproach(): void + { + $model = Approach::factory()->createOneQuietly(); + $model->delete(); + $this->assertModelMissing($model); + } +} diff --git a/tests/Back/ApproachLabelTest.php b/tests/Back/ApproachLabelTest.php new file mode 100644 index 00000000..62594a9c --- /dev/null +++ b/tests/Back/ApproachLabelTest.php @@ -0,0 +1,227 @@ +get(route( + config('unit-tests.route.prefix') . + 'approaches.' . + config('unit-tests.view.resources-index'), + ['approach_type' => ApproachTypeEnum::label->value()] + )); + $response->assertRedirect(route(config('unit-tests.route.prefix') . 'login')); + } + + /** @return void */ + public function testGuestCannotAccessApproachsReadView(): void + { + $model = Approach::factory()->createOneQuietly(); + $response = $this->get(route( + config('unit-tests.route.prefix') . + 'approaches.' . + config('unit-tests.view.resources-read'), + $model->getKey() + )); + $response->assertRedirect(route(config('unit-tests.route.prefix') . 'login')); + } + + /** @return void */ + public function testGuestCannotAccessApproachsCreateView(): void + { + $response = $this->get(route( + config('unit-tests.route.prefix') . + 'approaches.' . + config('unit-tests.view.resources-create'), + ['approach_type' => ApproachTypeEnum::label->value()] + )); + $response->assertRedirect(route(config('unit-tests.route.prefix') . 'login')); + } + + /** @return void */ + public function testGuestCannotAccessApproachsUpdateView(): void + { + $model = Approach::factory()->createOneQuietly(); + $response = $this->get(route( + config('unit-tests.route.prefix') . + 'approaches.' . + config('unit-tests.view.resources-update'), + $model->getKey() + )); + $response->assertRedirect(route(config('unit-tests.route.prefix') . 'login')); + } + + /** + * TESTS GUEST CANNOT POST MODEL. + */ + + /** @return void */ + public function testGuestCannotCreateApproach(): void + { + $model = Approach::factory()->createOneQuietly(); + $response = $this->post( + route( + config('unit-tests.route.prefix') . 'approaches.' . config('unit-tests.route.action-create'), + $model->getKey() + ), + $model->toArray() + ); + $response->assertRedirect(route(config('unit-tests.route.prefix') . 'login')); + } + + /** @return void */ + public function testGuestCannotUpdateApproach(): void + { + $model = Approach::factory()->createOneQuietly(); + $response = $this->patch( + route( + config('unit-tests.route.prefix') . 'approaches.' . config('unit-tests.route.action-update'), + $model->getKey() + ), + $model->toArray() + ); + $response->assertRedirect(route(config('unit-tests.route.prefix') . 'login')); + } + + /** @return void */ + public function testGuestCannotDeleteApproach(): void + { + $model = Approach::factory()->createOneQuietly(); + $response = $this->delete( + route( + config('unit-tests.route.prefix') . 'approaches.' . config('unit-tests.route.action-delete'), + $model->getKey() + ), + $model->toArray() + ); + $response->assertRedirect(route(config('unit-tests.route.prefix') . 'login')); + } + + /** + * TESTS USER CONCEPTOR ACCESS VIEWS. + */ + + /** @return void */ + public function testUserConceptorCanAccessApproachsIndexView(): void + { + $authModel = AuthModel::factory()->createOneQuietly(); + $authModel->update(['role' => RoleEnum::conceptor]); + $response = $this->actingAs($authModel, 'backend')->get( + route( + config('unit-tests.route.prefix') . 'approaches.' . config('unit-tests.view.resources-index'), + ['approach_type' => ApproachTypeEnum::label->value()] + ) + ); + $response->assertSuccessful(); + $response->assertViewIs( + config('unit-tests.view.prefix') . + 'pages.approaches.' . + config('unit-tests.view.resources-index') + ); + } + + /** @return void */ + public function testUserConceptorCanAccessApproachsReadView(): void + { + $authModel = AuthModel::factory()->createOneQuietly(); + $authModel->update(['role' => RoleEnum::conceptor]); + $model = Approach::factory()->createOneQuietly(); + $response = $this->actingAs($authModel, 'backend')->get( + route(config('unit-tests.route.prefix') . 'approaches.' . config('unit-tests.view.resources-read'), $model) + ); + $response->assertSuccessful(); + $response->assertViewIs( + config('unit-tests.view.prefix') . + 'pages.approaches.' . + config('unit-tests.view.resources-read') + ); + } + + /** @return void */ + public function testUserConceptorCanAccessApproachsCreateView(): void + { + $authModel = AuthModel::factory()->createOneQuietly(); + $authModel->update(['role' => RoleEnum::conceptor]); + $response = $this->actingAs($authModel, 'backend')->get( + route( + config('unit-tests.route.prefix') . 'approaches.' . config('unit-tests.view.resources-create'), + ['approach_type' => ApproachTypeEnum::label->value()] + ) + ); + $response->assertSuccessful(); + $response->assertViewIs( + config('unit-tests.view.prefix') . + 'pages.approaches.' . + config('unit-tests.view.resources-create') + ); + } + + /** @return void */ + public function testUserConceptorCanAccessApproachsUpdateView(): void + { + $authModel = AuthModel::factory()->createOneQuietly(); + $authModel->update(['role' => RoleEnum::conceptor]); + $model = Approach::factory()->createOneQuietly(); + $response = $this->actingAs($authModel, 'backend')->get( + route(config('unit-tests.route.prefix') . 'approaches.' . config('unit-tests.view.resources-update'), $model) + ); + $response->assertSuccessful(); + $response->assertViewIs( + config('unit-tests.view.prefix') . + 'pages.approaches.' . + config('unit-tests.view.resources-update') + ); + } + + /** + * TESTS CAN ACTIONS ON MODEL. + */ + + /** @return void */ + public function testCanCreateApproach(): void + { + $model = Approach::factory()->createOneQuietly(); + $this->assertModelExists($model); + } + + /** @return void */ + public function testCanUpdateApproach(): void + { + $model = Approach::factory()->createOneQuietly(); + + $fieldTest = ""; + foreach (config('unit-tests.list-fields') as $field) { + if (Schema::hasColumn($model->getTable(), $field)) { + $model->update([$field => "test"]); + $fieldTest = $field; + break; + } + } + + $this->assertTrue($model->wasChanged()); + $this->assertTrue(array_key_exists($fieldTest, $model->getChanges())); + $this->assertModelExists($model); + } + + /** @return void */ + public function testCanDeleteApproach(): void + { + $model = Approach::factory()->createOneQuietly(); + $model->delete(); + $this->assertModelMissing($model); + } +} diff --git a/tests/Back/BrandAdvantageTest.php b/tests/Back/BrandAdvantageTest.php new file mode 100644 index 00000000..caf7e90f --- /dev/null +++ b/tests/Back/BrandAdvantageTest.php @@ -0,0 +1,218 @@ +get(route( + config('unit-tests.route.prefix') . + 'brand_advantages.' . + config('unit-tests.view.resources-index') + )); + $response->assertRedirect(route(config('unit-tests.route.prefix') . 'login')); + } + + /** @return void */ + public function testGuestCannotAccessBrandAdvantagesReadView(): void + { + $model = BrandAdvantage::factory()->createOneQuietly(); + $response = $this->get(route( + config('unit-tests.route.prefix') . + 'brand_advantages.' . + config('unit-tests.view.resources-read'), + $model->getKey() + )); + $response->assertRedirect(route(config('unit-tests.route.prefix') . 'login')); + } + + /** @return void */ + public function testGuestCannotAccessBrandAdvantagesCreateView(): void + { + $response = $this->get(route( + config('unit-tests.route.prefix') . + 'brand_advantages.' . + config('unit-tests.view.resources-create') + )); + $response->assertRedirect(route(config('unit-tests.route.prefix') . 'login')); + } + + /** @return void */ + public function testGuestCannotAccessBrandAdvantagesUpdateView(): void + { + $model = BrandAdvantage::factory()->createOneQuietly(); + $response = $this->get(route( + config('unit-tests.route.prefix') . + 'brand_advantages.' . + config('unit-tests.view.resources-update'), + $model->getKey() + )); + $response->assertRedirect(route(config('unit-tests.route.prefix') . 'login')); + } + + /** + * TESTS GUEST CANNOT POST MODEL. + */ + + /** @return void */ + public function testGuestCannotCreateBrandAdvantage(): void + { + $model = BrandAdvantage::factory()->createOneQuietly(); + $response = $this->post( + route( + config('unit-tests.route.prefix') . 'brand_advantages.' . config('unit-tests.route.action-create'), + $model->getKey() + ), + $model->toArray() + ); + $response->assertRedirect(route(config('unit-tests.route.prefix') . 'login')); + } + + /** @return void */ + public function testGuestCannotUpdateBrandAdvantage(): void + { + $model = BrandAdvantage::factory()->createOneQuietly(); + $response = $this->patch( + route( + config('unit-tests.route.prefix') . 'brand_advantages.' . config('unit-tests.route.action-update'), + $model->getKey() + ), + $model->toArray() + ); + $response->assertRedirect(route(config('unit-tests.route.prefix') . 'login')); + } + + /** @return void */ + public function testGuestCannotDeleteBrandAdvantage(): void + { + $model = BrandAdvantage::factory()->createOneQuietly(); + $response = $this->delete( + route( + config('unit-tests.route.prefix') . 'brand_advantages.' . config('unit-tests.route.action-delete'), + $model->getKey() + ), + $model->toArray() + ); + $response->assertRedirect(route(config('unit-tests.route.prefix') . 'login')); + } + + /** + * TESTS USER CONCEPTOR ACCESS VIEWS. + */ + + /** @return void */ + public function testUserConceptorCanAccessBrandAdvantagesIndexView(): void + { + $authModel = AuthModel::factory()->createOneQuietly(); + $authModel->update(['role' => RoleEnum::conceptor]); + $response = $this->actingAs($authModel, 'backend')->get( + route(config('unit-tests.route.prefix') . 'brand_advantages.' . config('unit-tests.view.resources-index')) + ); + $response->assertSuccessful(); + $response->assertViewIs( + config('unit-tests.view.prefix') . + 'pages.brand_advantages.' . + config('unit-tests.view.resources-index') + ); + } + + /** @return void */ + public function testUserConceptorCanAccessBrandAdvantagesReadView(): void + { + $authModel = AuthModel::factory()->createOneQuietly(); + $authModel->update(['role' => RoleEnum::conceptor]); + $model = BrandAdvantage::factory()->createOneQuietly(); + $response = $this->actingAs($authModel, 'backend')->get( + route(config('unit-tests.route.prefix') . 'brand_advantages.' . config('unit-tests.view.resources-read'), $model) + ); + $response->assertSuccessful(); + $response->assertViewIs( + config('unit-tests.view.prefix') . + 'pages.brand_advantages.' . + config('unit-tests.view.resources-read') + ); + } + + /** @return void */ + public function testUserConceptorCanAccessBrandAdvantagesCreateView(): void + { + $authModel = AuthModel::factory()->createOneQuietly(); + $authModel->update(['role' => RoleEnum::conceptor]); + $response = $this->actingAs($authModel, 'backend')->get( + route(config('unit-tests.route.prefix') . 'brand_advantages.' . config('unit-tests.view.resources-create')) + ); + $response->assertSuccessful(); + $response->assertViewIs( + config('unit-tests.view.prefix') . + 'pages.brand_advantages.' . + config('unit-tests.view.resources-create') + ); + } + + /** @return void */ + public function testUserConceptorCanAccessBrandAdvantagesUpdateView(): void + { + $authModel = AuthModel::factory()->createOneQuietly(); + $authModel->update(['role' => RoleEnum::conceptor]); + $model = BrandAdvantage::factory()->createOneQuietly(); + $response = $this->actingAs($authModel, 'backend')->get( + route(config('unit-tests.route.prefix') . 'brand_advantages.' . config('unit-tests.view.resources-update'), $model) + ); + $response->assertSuccessful(); + $response->assertViewIs( + config('unit-tests.view.prefix') . + 'pages.brand_advantages.' . + config('unit-tests.view.resources-update') + ); + } + + /** + * TESTS CAN ACTIONS ON MODEL. + */ + + /** @return void */ + public function testCanCreateBrandAdvantage(): void + { + $model = BrandAdvantage::factory()->createOneQuietly(); + $this->assertModelExists($model); + } + + /** @return void */ + public function testCanUpdateBrandAdvantage(): void + { + $model = BrandAdvantage::factory()->createOneQuietly(); + + $fieldTest = ""; + foreach (config('unit-tests.list-fields') as $field) { + if (Schema::hasColumn($model->getTable(), $field)) { + $model->update([$field => "test"]); + $fieldTest = $field; + break; + } + } + + $this->assertTrue($model->wasChanged()); + $this->assertTrue(array_key_exists($fieldTest, $model->getChanges())); + $this->assertModelExists($model); + } + + /** @return void */ + public function testCanDeleteBrandAdvantage(): void + { + $model = BrandAdvantage::factory()->createOneQuietly(); + $model->delete(); + $this->assertModelMissing($model); + } +} diff --git a/tests/Back/ClaimTest.php b/tests/Back/ClaimTest.php new file mode 100644 index 00000000..0a0c112b --- /dev/null +++ b/tests/Back/ClaimTest.php @@ -0,0 +1,218 @@ +get(route( + config('unit-tests.route.prefix') . + 'claims.' . + config('unit-tests.view.resources-index') + )); + $response->assertRedirect(route(config('unit-tests.route.prefix') . 'login')); + } + + /** @return void */ + public function testGuestCannotAccessClaimsReadView(): void + { + $model = Claim::factory()->createOneQuietly(); + $response = $this->get(route( + config('unit-tests.route.prefix') . + 'claims.' . + config('unit-tests.view.resources-read'), + $model->getKey() + )); + $response->assertRedirect(route(config('unit-tests.route.prefix') . 'login')); + } + + /** @return void */ + public function testGuestCannotAccessClaimsCreateView(): void + { + $response = $this->get(route( + config('unit-tests.route.prefix') . + 'claims.' . + config('unit-tests.view.resources-create') + )); + $response->assertRedirect(route(config('unit-tests.route.prefix') . 'login')); + } + + /** @return void */ + public function testGuestCannotAccessClaimsUpdateView(): void + { + $model = Claim::factory()->createOneQuietly(); + $response = $this->get(route( + config('unit-tests.route.prefix') . + 'claims.' . + config('unit-tests.view.resources-update'), + $model->getKey() + )); + $response->assertRedirect(route(config('unit-tests.route.prefix') . 'login')); + } + + /** + * TESTS GUEST CANNOT POST MODEL. + */ + + /** @return void */ + public function testGuestCannotCreateClaim(): void + { + $model = Claim::factory()->createOneQuietly(); + $response = $this->post( + route( + config('unit-tests.route.prefix') . 'claims.' . config('unit-tests.route.action-create'), + $model->getKey() + ), + $model->toArray() + ); + $response->assertRedirect(route(config('unit-tests.route.prefix') . 'login')); + } + + /** @return void */ + public function testGuestCannotUpdateClaim(): void + { + $model = Claim::factory()->createOneQuietly(); + $response = $this->patch( + route( + config('unit-tests.route.prefix') . 'claims.' . config('unit-tests.route.action-update'), + $model->getKey() + ), + $model->toArray() + ); + $response->assertRedirect(route(config('unit-tests.route.prefix') . 'login')); + } + + /** @return void */ + public function testGuestCannotDeleteClaim(): void + { + $model = Claim::factory()->createOneQuietly(); + $response = $this->delete( + route( + config('unit-tests.route.prefix') . 'claims.' . config('unit-tests.route.action-delete'), + $model->getKey() + ), + $model->toArray() + ); + $response->assertRedirect(route(config('unit-tests.route.prefix') . 'login')); + } + + /** + * TESTS USER CONCEPTOR ACCESS VIEWS. + */ + + /** @return void */ + public function testUserConceptorCanAccessClaimsIndexView(): void + { + $authModel = AuthModel::factory()->createOneQuietly(); + $authModel->update(['role' => RoleEnum::conceptor]); + $response = $this->actingAs($authModel, 'backend')->get( + route(config('unit-tests.route.prefix') . 'claims.' . config('unit-tests.view.resources-index')) + ); + $response->assertSuccessful(); + $response->assertViewIs( + config('unit-tests.view.prefix') . + 'pages.claims.' . + config('unit-tests.view.resources-index') + ); + } + + /** @return void */ + public function testUserConceptorCanAccessClaimsReadView(): void + { + $authModel = AuthModel::factory()->createOneQuietly(); + $authModel->update(['role' => RoleEnum::conceptor]); + $model = Claim::factory()->createOneQuietly(); + $response = $this->actingAs($authModel, 'backend')->get( + route(config('unit-tests.route.prefix') . 'claims.' . config('unit-tests.view.resources-read'), $model) + ); + $response->assertSuccessful(); + $response->assertViewIs( + config('unit-tests.view.prefix') . + 'pages.claims.' . + config('unit-tests.view.resources-read') + ); + } + + /** @return void */ + public function testUserConceptorCanAccessClaimsCreateView(): void + { + $authModel = AuthModel::factory()->createOneQuietly(); + $authModel->update(['role' => RoleEnum::conceptor]); + $response = $this->actingAs($authModel, 'backend')->get( + route(config('unit-tests.route.prefix') . 'claims.' . config('unit-tests.view.resources-create')) + ); + $response->assertSuccessful(); + $response->assertViewIs( + config('unit-tests.view.prefix') . + 'pages.claims.' . + config('unit-tests.view.resources-create') + ); + } + + /** @return void */ + public function testUserConceptorCanAccessClaimsUpdateView(): void + { + $authModel = AuthModel::factory()->createOneQuietly(); + $authModel->update(['role' => RoleEnum::conceptor]); + $model = Claim::factory()->createOneQuietly(); + $response = $this->actingAs($authModel, 'backend')->get( + route(config('unit-tests.route.prefix') . 'claims.' . config('unit-tests.view.resources-update'), $model) + ); + $response->assertSuccessful(); + $response->assertViewIs( + config('unit-tests.view.prefix') . + 'pages.claims.' . + config('unit-tests.view.resources-update') + ); + } + + /** + * TESTS CAN ACTIONS ON MODEL. + */ + + /** @return void */ + public function testCanCreateClaim(): void + { + $model = Claim::factory()->createOneQuietly(); + $this->assertModelExists($model); + } + + /** @return void */ + public function testCanUpdateClaim(): void + { + $model = Claim::factory()->createOneQuietly(); + + $fieldTest = ""; + foreach (config('unit-tests.list-fields') as $field) { + if (Schema::hasColumn($model->getTable(), $field)) { + $model->update([$field => "test"]); + $fieldTest = $field; + break; + } + } + + $this->assertTrue($model->wasChanged()); + $this->assertTrue(array_key_exists($fieldTest, $model->getChanges())); + $this->assertModelExists($model); + } + + /** @return void */ + public function testCanDeleteClaim(): void + { + $model = Claim::factory()->createOneQuietly(); + $model->delete(); + $this->assertModelMissing($model); + } +} diff --git a/tests/Back/ConsumptionMomentTest.php b/tests/Back/ConsumptionMomentTest.php new file mode 100644 index 00000000..6619cbcb --- /dev/null +++ b/tests/Back/ConsumptionMomentTest.php @@ -0,0 +1,218 @@ +get(route( + config('unit-tests.route.prefix') . + 'consumption_moments.' . + config('unit-tests.view.resources-index') + )); + $response->assertRedirect(route(config('unit-tests.route.prefix') . 'login')); + } + + /** @return void */ + public function testGuestCannotAccessConsumptionMomentsReadView(): void + { + $model = ConsumptionMoment::factory()->createOneQuietly(); + $response = $this->get(route( + config('unit-tests.route.prefix') . + 'consumption_moments.' . + config('unit-tests.view.resources-read'), + $model->getKey() + )); + $response->assertRedirect(route(config('unit-tests.route.prefix') . 'login')); + } + + /** @return void */ + public function testGuestCannotAccessConsumptionMomentsCreateView(): void + { + $response = $this->get(route( + config('unit-tests.route.prefix') . + 'consumption_moments.' . + config('unit-tests.view.resources-create') + )); + $response->assertRedirect(route(config('unit-tests.route.prefix') . 'login')); + } + + /** @return void */ + public function testGuestCannotAccessConsumptionMomentsUpdateView(): void + { + $model = ConsumptionMoment::factory()->createOneQuietly(); + $response = $this->get(route( + config('unit-tests.route.prefix') . + 'consumption_moments.' . + config('unit-tests.view.resources-update'), + $model->getKey() + )); + $response->assertRedirect(route(config('unit-tests.route.prefix') . 'login')); + } + + /** + * TESTS GUEST CANNOT POST MODEL. + */ + + /** @return void */ + public function testGuestCannotCreateConsumptionMoment(): void + { + $model = ConsumptionMoment::factory()->createOneQuietly(); + $response = $this->post( + route( + config('unit-tests.route.prefix') . 'consumption_moments.' . config('unit-tests.route.action-create'), + $model->getKey() + ), + $model->toArray() + ); + $response->assertRedirect(route(config('unit-tests.route.prefix') . 'login')); + } + + /** @return void */ + public function testGuestCannotUpdateConsumptionMoment(): void + { + $model = ConsumptionMoment::factory()->createOneQuietly(); + $response = $this->patch( + route( + config('unit-tests.route.prefix') . 'consumption_moments.' . config('unit-tests.route.action-update'), + $model->getKey() + ), + $model->toArray() + ); + $response->assertRedirect(route(config('unit-tests.route.prefix') . 'login')); + } + + /** @return void */ + public function testGuestCannotDeleteConsumptionMoment(): void + { + $model = ConsumptionMoment::factory()->createOneQuietly(); + $response = $this->delete( + route( + config('unit-tests.route.prefix') . 'consumption_moments.' . config('unit-tests.route.action-delete'), + $model->getKey() + ), + $model->toArray() + ); + $response->assertRedirect(route(config('unit-tests.route.prefix') . 'login')); + } + + /** + * TESTS USER CONCEPTOR ACCESS VIEWS. + */ + + /** @return void */ + public function testUserConceptorCanAccessConsumptionMomentsIndexView(): void + { + $authModel = AuthModel::factory()->createOneQuietly(); + $authModel->update(['role' => RoleEnum::conceptor]); + $response = $this->actingAs($authModel, 'backend')->get( + route(config('unit-tests.route.prefix') . 'consumption_moments.' . config('unit-tests.view.resources-index')) + ); + $response->assertSuccessful(); + $response->assertViewIs( + config('unit-tests.view.prefix') . + 'pages.consumption_moments.' . + config('unit-tests.view.resources-index') + ); + } + + /** @return void */ + public function testUserConceptorCanAccessConsumptionMomentsReadView(): void + { + $authModel = AuthModel::factory()->createOneQuietly(); + $authModel->update(['role' => RoleEnum::conceptor]); + $model = ConsumptionMoment::factory()->createOneQuietly(); + $response = $this->actingAs($authModel, 'backend')->get( + route(config('unit-tests.route.prefix') . 'consumption_moments.' . config('unit-tests.view.resources-read'), $model) + ); + $response->assertSuccessful(); + $response->assertViewIs( + config('unit-tests.view.prefix') . + 'pages.consumption_moments.' . + config('unit-tests.view.resources-read') + ); + } + + /** @return void */ + public function testUserConceptorCanAccessConsumptionMomentsCreateView(): void + { + $authModel = AuthModel::factory()->createOneQuietly(); + $authModel->update(['role' => RoleEnum::conceptor]); + $response = $this->actingAs($authModel, 'backend')->get( + route(config('unit-tests.route.prefix') . 'consumption_moments.' . config('unit-tests.view.resources-create')) + ); + $response->assertSuccessful(); + $response->assertViewIs( + config('unit-tests.view.prefix') . + 'pages.consumption_moments.' . + config('unit-tests.view.resources-create') + ); + } + + /** @return void */ + public function testUserConceptorCanAccessConsumptionMomentsUpdateView(): void + { + $authModel = AuthModel::factory()->createOneQuietly(); + $authModel->update(['role' => RoleEnum::conceptor]); + $model = ConsumptionMoment::factory()->createOneQuietly(); + $response = $this->actingAs($authModel, 'backend')->get( + route(config('unit-tests.route.prefix') . 'consumption_moments.' . config('unit-tests.view.resources-update'), $model) + ); + $response->assertSuccessful(); + $response->assertViewIs( + config('unit-tests.view.prefix') . + 'pages.consumption_moments.' . + config('unit-tests.view.resources-update') + ); + } + + /** + * TESTS CAN ACTIONS ON MODEL. + */ + + /** @return void */ + public function testCanCreateConsumptionMoment(): void + { + $model = ConsumptionMoment::factory()->createOneQuietly(); + $this->assertModelExists($model); + } + + /** @return void */ + public function testCanUpdateConsumptionMoment(): void + { + $model = ConsumptionMoment::factory()->createOneQuietly(); + + $fieldTest = ""; + foreach (config('unit-tests.list-fields') as $field) { + if (Schema::hasColumn($model->getTable(), $field)) { + $model->update([$field => "test"]); + $fieldTest = $field; + break; + } + } + + $this->assertTrue($model->wasChanged()); + $this->assertTrue(array_key_exists($fieldTest, $model->getChanges())); + $this->assertModelExists($model); + } + + /** @return void */ + public function testCanDeleteConsumptionMoment(): void + { + $model = ConsumptionMoment::factory()->createOneQuietly(); + $model->delete(); + $this->assertModelMissing($model); + } +} diff --git a/tests/Back/DemarcheSlideTest.php b/tests/Back/DemarcheSlideTest.php new file mode 100644 index 00000000..ef32c133 --- /dev/null +++ b/tests/Back/DemarcheSlideTest.php @@ -0,0 +1,218 @@ +get(route( + config('unit-tests.route.prefix') . + 'demarche_slides.' . + config('unit-tests.view.resources-index') + )); + $response->assertRedirect(route(config('unit-tests.route.prefix') . 'login')); + } + + /** @return void */ + public function testGuestCannotAccessDemarcheSlidesReadView(): void + { + $model = DemarcheSlide::factory()->createOneQuietly(); + $response = $this->get(route( + config('unit-tests.route.prefix') . + 'demarche_slides.' . + config('unit-tests.view.resources-read'), + $model->getKey() + )); + $response->assertRedirect(route(config('unit-tests.route.prefix') . 'login')); + } + + /** @return void */ + public function testGuestCannotAccessDemarcheSlidesCreateView(): void + { + $response = $this->get(route( + config('unit-tests.route.prefix') . + 'demarche_slides.' . + config('unit-tests.view.resources-create') + )); + $response->assertRedirect(route(config('unit-tests.route.prefix') . 'login')); + } + + /** @return void */ + public function testGuestCannotAccessDemarcheSlidesUpdateView(): void + { + $model = DemarcheSlide::factory()->createOneQuietly(); + $response = $this->get(route( + config('unit-tests.route.prefix') . + 'demarche_slides.' . + config('unit-tests.view.resources-update'), + $model->getKey() + )); + $response->assertRedirect(route(config('unit-tests.route.prefix') . 'login')); + } + + /** + * TESTS GUEST CANNOT POST MODEL. + */ + + /** @return void */ + public function testGuestCannotCreateDemarcheSlide(): void + { + $model = DemarcheSlide::factory()->createOneQuietly(); + $response = $this->post( + route( + config('unit-tests.route.prefix') . 'demarche_slides.' . config('unit-tests.route.action-create'), + $model->getKey() + ), + $model->toArray() + ); + $response->assertRedirect(route(config('unit-tests.route.prefix') . 'login')); + } + + /** @return void */ + public function testGuestCannotUpdateDemarcheSlide(): void + { + $model = DemarcheSlide::factory()->createOneQuietly(); + $response = $this->patch( + route( + config('unit-tests.route.prefix') . 'demarche_slides.' . config('unit-tests.route.action-update'), + $model->getKey() + ), + $model->toArray() + ); + $response->assertRedirect(route(config('unit-tests.route.prefix') . 'login')); + } + + /** @return void */ + public function testGuestCannotDeleteDemarcheSlide(): void + { + $model = DemarcheSlide::factory()->createOneQuietly(); + $response = $this->delete( + route( + config('unit-tests.route.prefix') . 'demarche_slides.' . config('unit-tests.route.action-delete'), + $model->getKey() + ), + $model->toArray() + ); + $response->assertRedirect(route(config('unit-tests.route.prefix') . 'login')); + } + + /** + * TESTS USER CONCEPTOR ACCESS VIEWS. + */ + + /** @return void */ + public function testUserConceptorCanAccessDemarcheSlidesIndexView(): void + { + $authModel = AuthModel::factory()->createOneQuietly(); + $authModel->update(['role' => RoleEnum::conceptor]); + $response = $this->actingAs($authModel, 'backend')->get( + route(config('unit-tests.route.prefix') . 'demarche_slides.' . config('unit-tests.view.resources-index')) + ); + $response->assertSuccessful(); + $response->assertViewIs( + config('unit-tests.view.prefix') . + 'pages.demarche_slides.' . + config('unit-tests.view.resources-index') + ); + } + + /** @return void */ + public function testUserConceptorCanAccessDemarcheSlidesReadView(): void + { + $authModel = AuthModel::factory()->createOneQuietly(); + $authModel->update(['role' => RoleEnum::conceptor]); + $model = DemarcheSlide::factory()->createOneQuietly(); + $response = $this->actingAs($authModel, 'backend')->get( + route(config('unit-tests.route.prefix') . 'demarche_slides.' . config('unit-tests.view.resources-read'), $model) + ); + $response->assertSuccessful(); + $response->assertViewIs( + config('unit-tests.view.prefix') . + 'pages.demarche_slides.' . + config('unit-tests.view.resources-read') + ); + } + + /** @return void */ + public function testUserConceptorCanAccessDemarcheSlidesCreateView(): void + { + $authModel = AuthModel::factory()->createOneQuietly(); + $authModel->update(['role' => RoleEnum::conceptor]); + $response = $this->actingAs($authModel, 'backend')->get( + route(config('unit-tests.route.prefix') . 'demarche_slides.' . config('unit-tests.view.resources-create')) + ); + $response->assertSuccessful(); + $response->assertViewIs( + config('unit-tests.view.prefix') . + 'pages.demarche_slides.' . + config('unit-tests.view.resources-create') + ); + } + + /** @return void */ + public function testUserConceptorCanAccessDemarcheSlidesUpdateView(): void + { + $authModel = AuthModel::factory()->createOneQuietly(); + $authModel->update(['role' => RoleEnum::conceptor]); + $model = DemarcheSlide::factory()->createOneQuietly(); + $response = $this->actingAs($authModel, 'backend')->get( + route(config('unit-tests.route.prefix') . 'demarche_slides.' . config('unit-tests.view.resources-update'), $model) + ); + $response->assertSuccessful(); + $response->assertViewIs( + config('unit-tests.view.prefix') . + 'pages.demarche_slides.' . + config('unit-tests.view.resources-update') + ); + } + + /** + * TESTS CAN ACTIONS ON MODEL. + */ + + /** @return void */ + public function testCanCreateDemarcheSlide(): void + { + $model = DemarcheSlide::factory()->createOneQuietly(); + $this->assertModelExists($model); + } + + /** @return void */ + public function testCanUpdateDemarcheSlide(): void + { + $model = DemarcheSlide::factory()->createOneQuietly(); + + $fieldTest = ""; + foreach (config('unit-tests.list-fields') as $field) { + if (Schema::hasColumn($model->getTable(), $field)) { + $model->update([$field => "test"]); + $fieldTest = $field; + break; + } + } + + $this->assertTrue($model->wasChanged()); + $this->assertTrue(array_key_exists($fieldTest, $model->getChanges())); + $this->assertModelExists($model); + } + + /** @return void */ + public function testCanDeleteDemarcheSlide(): void + { + $model = DemarcheSlide::factory()->createOneQuietly(); + $model->delete(); + $this->assertModelMissing($model); + } +} diff --git a/tests/Back/DiscountTest.php b/tests/Back/DiscountTest.php new file mode 100644 index 00000000..bbd9b5a8 --- /dev/null +++ b/tests/Back/DiscountTest.php @@ -0,0 +1,76 @@ +get(route( + config('unit-tests.route.prefix') . + 'discounts.' . + config('unit-tests.view.resources-index') + )); + $response->assertRedirect(route(config('unit-tests.route.prefix') . 'login')); + } + + /** @return void */ + public function testGuestCannotAccessDiscountsReadView(): void + { + $model = Discount::factory()->createOneQuietly(); + $response = $this->get(route( + config('unit-tests.route.prefix') . + 'discounts.' . + config('unit-tests.view.resources-read'), + $model->getKey() + )); + $response->assertRedirect(route(config('unit-tests.route.prefix') . 'login')); + } + + /** + * TESTS USER CONCEPTOR ACCESS VIEWS. + */ + + /** @return void */ + public function testUserConceptorCanAccessDiscountsIndexView(): void + { + $authModel = AuthModel::factory()->createOneQuietly(); + $authModel->update(['role' => RoleEnum::conceptor]); + $response = $this->actingAs($authModel, 'backend')->get( + route(config('unit-tests.route.prefix') . 'discounts.' . config('unit-tests.view.resources-index')) + ); + $response->assertSuccessful(); + $response->assertViewIs( + config('unit-tests.view.prefix') . + 'pages.discounts.' . + config('unit-tests.view.resources-index') + ); + } + + /** @return void */ + public function testUserConceptorCanAccessDiscountsReadView(): void + { + $authModel = AuthModel::factory()->createOneQuietly(); + $authModel->update(['role' => RoleEnum::conceptor]); + $model = Discount::factory()->createOneQuietly(); + $response = $this->actingAs($authModel, 'backend')->get( + route(config('unit-tests.route.prefix') . 'discounts.' . config('unit-tests.view.resources-read'), $model) + ); + $response->assertSuccessful(); + $response->assertViewIs( + config('unit-tests.view.prefix') . + 'pages.discounts.' . + config('unit-tests.view.resources-read') + ); + } +} diff --git a/tests/Back/HistoricalMilestoneTest.php b/tests/Back/HistoricalMilestoneTest.php new file mode 100644 index 00000000..06c0a721 --- /dev/null +++ b/tests/Back/HistoricalMilestoneTest.php @@ -0,0 +1,218 @@ +get(route( + config('unit-tests.route.prefix') . + 'historical_milestones.' . + config('unit-tests.view.resources-index') + )); + $response->assertRedirect(route(config('unit-tests.route.prefix') . 'login')); + } + + /** @return void */ + public function testGuestCannotAccessHistoricalMilestonesReadView(): void + { + $model = HistoricalMilestone::factory()->createOneQuietly(); + $response = $this->get(route( + config('unit-tests.route.prefix') . + 'historical_milestones.' . + config('unit-tests.view.resources-read'), + $model->getKey() + )); + $response->assertRedirect(route(config('unit-tests.route.prefix') . 'login')); + } + + /** @return void */ + public function testGuestCannotAccessHistoricalMilestonesCreateView(): void + { + $response = $this->get(route( + config('unit-tests.route.prefix') . + 'historical_milestones.' . + config('unit-tests.view.resources-create') + )); + $response->assertRedirect(route(config('unit-tests.route.prefix') . 'login')); + } + + /** @return void */ + public function testGuestCannotAccessHistoricalMilestonesUpdateView(): void + { + $model = HistoricalMilestone::factory()->createOneQuietly(); + $response = $this->get(route( + config('unit-tests.route.prefix') . + 'historical_milestones.' . + config('unit-tests.view.resources-update'), + $model->getKey() + )); + $response->assertRedirect(route(config('unit-tests.route.prefix') . 'login')); + } + + /** + * TESTS GUEST CANNOT POST MODEL. + */ + + /** @return void */ + public function testGuestCannotCreateHistoricalMilestone(): void + { + $model = HistoricalMilestone::factory()->createOneQuietly(); + $response = $this->post( + route( + config('unit-tests.route.prefix') . 'historical_milestones.' . config('unit-tests.route.action-create'), + $model->getKey() + ), + $model->toArray() + ); + $response->assertRedirect(route(config('unit-tests.route.prefix') . 'login')); + } + + /** @return void */ + public function testGuestCannotUpdateHistoricalMilestone(): void + { + $model = HistoricalMilestone::factory()->createOneQuietly(); + $response = $this->patch( + route( + config('unit-tests.route.prefix') . 'historical_milestones.' . config('unit-tests.route.action-update'), + $model->getKey() + ), + $model->toArray() + ); + $response->assertRedirect(route(config('unit-tests.route.prefix') . 'login')); + } + + /** @return void */ + public function testGuestCannotDeleteHistoricalMilestone(): void + { + $model = HistoricalMilestone::factory()->createOneQuietly(); + $response = $this->delete( + route( + config('unit-tests.route.prefix') . 'historical_milestones.' . config('unit-tests.route.action-delete'), + $model->getKey() + ), + $model->toArray() + ); + $response->assertRedirect(route(config('unit-tests.route.prefix') . 'login')); + } + + /** + * TESTS USER CONCEPTOR ACCESS VIEWS. + */ + + /** @return void */ + public function testUserConceptorCanAccessHistoricalMilestonesIndexView(): void + { + $authModel = AuthModel::factory()->createOneQuietly(); + $authModel->update(['role' => RoleEnum::conceptor]); + $response = $this->actingAs($authModel, 'backend')->get( + route(config('unit-tests.route.prefix') . 'historical_milestones.' . config('unit-tests.view.resources-index')) + ); + $response->assertSuccessful(); + $response->assertViewIs( + config('unit-tests.view.prefix') . + 'pages.historical_milestones.' . + config('unit-tests.view.resources-index') + ); + } + + /** @return void */ + public function testUserConceptorCanAccessHistoricalMilestonesReadView(): void + { + $authModel = AuthModel::factory()->createOneQuietly(); + $authModel->update(['role' => RoleEnum::conceptor]); + $model = HistoricalMilestone::factory()->createOneQuietly(); + $response = $this->actingAs($authModel, 'backend')->get( + route(config('unit-tests.route.prefix') . 'historical_milestones.' . config('unit-tests.view.resources-read'), $model) + ); + $response->assertSuccessful(); + $response->assertViewIs( + config('unit-tests.view.prefix') . + 'pages.historical_milestones.' . + config('unit-tests.view.resources-read') + ); + } + + /** @return void */ + public function testUserConceptorCanAccessHistoricalMilestonesCreateView(): void + { + $authModel = AuthModel::factory()->createOneQuietly(); + $authModel->update(['role' => RoleEnum::conceptor]); + $response = $this->actingAs($authModel, 'backend')->get( + route(config('unit-tests.route.prefix') . 'historical_milestones.' . config('unit-tests.view.resources-create')) + ); + $response->assertSuccessful(); + $response->assertViewIs( + config('unit-tests.view.prefix') . + 'pages.historical_milestones.' . + config('unit-tests.view.resources-create') + ); + } + + /** @return void */ + public function testUserConceptorCanAccessHistoricalMilestonesUpdateView(): void + { + $authModel = AuthModel::factory()->createOneQuietly(); + $authModel->update(['role' => RoleEnum::conceptor]); + $model = HistoricalMilestone::factory()->createOneQuietly(); + $response = $this->actingAs($authModel, 'backend')->get( + route(config('unit-tests.route.prefix') . 'historical_milestones.' . config('unit-tests.view.resources-update'), $model) + ); + $response->assertSuccessful(); + $response->assertViewIs( + config('unit-tests.view.prefix') . + 'pages.historical_milestones.' . + config('unit-tests.view.resources-update') + ); + } + + /** + * TESTS CAN ACTIONS ON MODEL. + */ + + /** @return void */ + public function testCanCreateHistoricalMilestone(): void + { + $model = HistoricalMilestone::factory()->createOneQuietly(); + $this->assertModelExists($model); + } + + /** @return void */ + public function testCanUpdateHistoricalMilestone(): void + { + $model = HistoricalMilestone::factory()->createOneQuietly(); + + $fieldTest = ""; + foreach (config('unit-tests.list-fields') as $field) { + if (Schema::hasColumn($model->getTable(), $field)) { + $model->update([$field => "test"]); + $fieldTest = $field; + break; + } + } + + $this->assertTrue($model->wasChanged()); + $this->assertTrue(array_key_exists($fieldTest, $model->getChanges())); + $this->assertModelExists($model); + } + + /** @return void */ + public function testCanDeleteHistoricalMilestone(): void + { + $model = HistoricalMilestone::factory()->createOneQuietly(); + $model->delete(); + $this->assertModelMissing($model); + } +} diff --git a/tests/Back/KeyNumberTest.php b/tests/Back/KeyNumberTest.php new file mode 100644 index 00000000..bc0c885f --- /dev/null +++ b/tests/Back/KeyNumberTest.php @@ -0,0 +1,218 @@ +get(route( + config('unit-tests.route.prefix') . + 'key_numbers.' . + config('unit-tests.view.resources-index') + )); + $response->assertRedirect(route(config('unit-tests.route.prefix') . 'login')); + } + + /** @return void */ + public function testGuestCannotAccessKeyNumbersReadView(): void + { + $model = KeyNumber::factory()->createOneQuietly(); + $response = $this->get(route( + config('unit-tests.route.prefix') . + 'key_numbers.' . + config('unit-tests.view.resources-read'), + $model->getKey() + )); + $response->assertRedirect(route(config('unit-tests.route.prefix') . 'login')); + } + + /** @return void */ + public function testGuestCannotAccessKeyNumbersCreateView(): void + { + $response = $this->get(route( + config('unit-tests.route.prefix') . + 'key_numbers.' . + config('unit-tests.view.resources-create') + )); + $response->assertRedirect(route(config('unit-tests.route.prefix') . 'login')); + } + + /** @return void */ + public function testGuestCannotAccessKeyNumbersUpdateView(): void + { + $model = KeyNumber::factory()->createOneQuietly(); + $response = $this->get(route( + config('unit-tests.route.prefix') . + 'key_numbers.' . + config('unit-tests.view.resources-update'), + $model->getKey() + )); + $response->assertRedirect(route(config('unit-tests.route.prefix') . 'login')); + } + + /** + * TESTS GUEST CANNOT POST MODEL. + */ + + /** @return void */ + public function testGuestCannotCreateKeyNumber(): void + { + $model = KeyNumber::factory()->createOneQuietly(); + $response = $this->post( + route( + config('unit-tests.route.prefix') . 'key_numbers.' . config('unit-tests.route.action-create'), + $model->getKey() + ), + $model->toArray() + ); + $response->assertRedirect(route(config('unit-tests.route.prefix') . 'login')); + } + + /** @return void */ + public function testGuestCannotUpdateKeyNumber(): void + { + $model = KeyNumber::factory()->createOneQuietly(); + $response = $this->patch( + route( + config('unit-tests.route.prefix') . 'key_numbers.' . config('unit-tests.route.action-update'), + $model->getKey() + ), + $model->toArray() + ); + $response->assertRedirect(route(config('unit-tests.route.prefix') . 'login')); + } + + /** @return void */ + public function testGuestCannotDeleteKeyNumber(): void + { + $model = KeyNumber::factory()->createOneQuietly(); + $response = $this->delete( + route( + config('unit-tests.route.prefix') . 'key_numbers.' . config('unit-tests.route.action-delete'), + $model->getKey() + ), + $model->toArray() + ); + $response->assertRedirect(route(config('unit-tests.route.prefix') . 'login')); + } + + /** + * TESTS USER CONCEPTOR ACCESS VIEWS. + */ + + /** @return void */ + public function testUserConceptorCanAccessKeyNumbersIndexView(): void + { + $authModel = AuthModel::factory()->createOneQuietly(); + $authModel->update(['role' => RoleEnum::conceptor]); + $response = $this->actingAs($authModel, 'backend')->get( + route(config('unit-tests.route.prefix') . 'key_numbers.' . config('unit-tests.view.resources-index')) + ); + $response->assertSuccessful(); + $response->assertViewIs( + config('unit-tests.view.prefix') . + 'pages.key_numbers.' . + config('unit-tests.view.resources-index') + ); + } + + /** @return void */ + public function testUserConceptorCanAccessKeyNumbersReadView(): void + { + $authModel = AuthModel::factory()->createOneQuietly(); + $authModel->update(['role' => RoleEnum::conceptor]); + $model = KeyNumber::factory()->createOneQuietly(); + $response = $this->actingAs($authModel, 'backend')->get( + route(config('unit-tests.route.prefix') . 'key_numbers.' . config('unit-tests.view.resources-read'), $model) + ); + $response->assertSuccessful(); + $response->assertViewIs( + config('unit-tests.view.prefix') . + 'pages.key_numbers.' . + config('unit-tests.view.resources-read') + ); + } + + /** @return void */ + public function testUserConceptorCanAccessKeyNumbersCreateView(): void + { + $authModel = AuthModel::factory()->createOneQuietly(); + $authModel->update(['role' => RoleEnum::conceptor]); + $response = $this->actingAs($authModel, 'backend')->get( + route(config('unit-tests.route.prefix') . 'key_numbers.' . config('unit-tests.view.resources-create')) + ); + $response->assertSuccessful(); + $response->assertViewIs( + config('unit-tests.view.prefix') . + 'pages.key_numbers.' . + config('unit-tests.view.resources-create') + ); + } + + /** @return void */ + public function testUserConceptorCanAccessKeyNumbersUpdateView(): void + { + $authModel = AuthModel::factory()->createOneQuietly(); + $authModel->update(['role' => RoleEnum::conceptor]); + $model = KeyNumber::factory()->createOneQuietly(); + $response = $this->actingAs($authModel, 'backend')->get( + route(config('unit-tests.route.prefix') . 'key_numbers.' . config('unit-tests.view.resources-update'), $model) + ); + $response->assertSuccessful(); + $response->assertViewIs( + config('unit-tests.view.prefix') . + 'pages.key_numbers.' . + config('unit-tests.view.resources-update') + ); + } + + /** + * TESTS CAN ACTIONS ON MODEL. + */ + + /** @return void */ + public function testCanCreateKeyNumber(): void + { + $model = KeyNumber::factory()->createOneQuietly(); + $this->assertModelExists($model); + } + + /** @return void */ + public function testCanUpdateKeyNumber(): void + { + $model = KeyNumber::factory()->createOneQuietly(); + + $fieldTest = ""; + foreach (config('unit-tests.list-fields') as $field) { + if (Schema::hasColumn($model->getTable(), $field)) { + $model->update([$field => "test"]); + $fieldTest = $field; + break; + } + } + + $this->assertTrue($model->wasChanged()); + $this->assertTrue(array_key_exists($fieldTest, $model->getChanges())); + $this->assertModelExists($model); + } + + /** @return void */ + public function testCanDeleteKeyNumber(): void + { + $model = KeyNumber::factory()->createOneQuietly(); + $model->delete(); + $this->assertModelMissing($model); + } +} diff --git a/tests/Back/MainSlideTest.php b/tests/Back/MainSlideTest.php new file mode 100644 index 00000000..60295c97 --- /dev/null +++ b/tests/Back/MainSlideTest.php @@ -0,0 +1,218 @@ +get(route( + config('unit-tests.route.prefix') . + 'main_slides.' . + config('unit-tests.view.resources-index') + )); + $response->assertRedirect(route(config('unit-tests.route.prefix') . 'login')); + } + + /** @return void */ + public function testGuestCannotAccessMainSlidesReadView(): void + { + $model = MainSlide::factory()->createOneQuietly(); + $response = $this->get(route( + config('unit-tests.route.prefix') . + 'main_slides.' . + config('unit-tests.view.resources-read'), + $model->getKey() + )); + $response->assertRedirect(route(config('unit-tests.route.prefix') . 'login')); + } + + /** @return void */ + public function testGuestCannotAccessMainSlidesCreateView(): void + { + $response = $this->get(route( + config('unit-tests.route.prefix') . + 'main_slides.' . + config('unit-tests.view.resources-create') + )); + $response->assertRedirect(route(config('unit-tests.route.prefix') . 'login')); + } + + /** @return void */ + public function testGuestCannotAccessMainSlidesUpdateView(): void + { + $model = MainSlide::factory()->createOneQuietly(); + $response = $this->get(route( + config('unit-tests.route.prefix') . + 'main_slides.' . + config('unit-tests.view.resources-update'), + $model->getKey() + )); + $response->assertRedirect(route(config('unit-tests.route.prefix') . 'login')); + } + + /** + * TESTS GUEST CANNOT POST MODEL. + */ + + /** @return void */ + public function testGuestCannotCreateMainSlide(): void + { + $model = MainSlide::factory()->createOneQuietly(); + $response = $this->post( + route( + config('unit-tests.route.prefix') . 'main_slides.' . config('unit-tests.route.action-create'), + $model->getKey() + ), + $model->toArray() + ); + $response->assertRedirect(route(config('unit-tests.route.prefix') . 'login')); + } + + /** @return void */ + public function testGuestCannotUpdateMainSlide(): void + { + $model = MainSlide::factory()->createOneQuietly(); + $response = $this->patch( + route( + config('unit-tests.route.prefix') . 'main_slides.' . config('unit-tests.route.action-update'), + $model->getKey() + ), + $model->toArray() + ); + $response->assertRedirect(route(config('unit-tests.route.prefix') . 'login')); + } + + /** @return void */ + public function testGuestCannotDeleteMainSlide(): void + { + $model = MainSlide::factory()->createOneQuietly(); + $response = $this->delete( + route( + config('unit-tests.route.prefix') . 'main_slides.' . config('unit-tests.route.action-delete'), + $model->getKey() + ), + $model->toArray() + ); + $response->assertRedirect(route(config('unit-tests.route.prefix') . 'login')); + } + + /** + * TESTS USER CONCEPTOR ACCESS VIEWS. + */ + + /** @return void */ + public function testUserConceptorCanAccessMainSlidesIndexView(): void + { + $authModel = AuthModel::factory()->createOneQuietly(); + $authModel->update(['role' => RoleEnum::conceptor]); + $response = $this->actingAs($authModel, 'backend')->get( + route(config('unit-tests.route.prefix') . 'main_slides.' . config('unit-tests.view.resources-index')) + ); + $response->assertSuccessful(); + $response->assertViewIs( + config('unit-tests.view.prefix') . + 'pages.main_slides.' . + config('unit-tests.view.resources-index') + ); + } + + /** @return void */ + public function testUserConceptorCanAccessMainSlidesReadView(): void + { + $authModel = AuthModel::factory()->createOneQuietly(); + $authModel->update(['role' => RoleEnum::conceptor]); + $model = MainSlide::factory()->createOneQuietly(); + $response = $this->actingAs($authModel, 'backend')->get( + route(config('unit-tests.route.prefix') . 'main_slides.' . config('unit-tests.view.resources-read'), $model) + ); + $response->assertSuccessful(); + $response->assertViewIs( + config('unit-tests.view.prefix') . + 'pages.main_slides.' . + config('unit-tests.view.resources-read') + ); + } + + /** @return void */ + public function testUserConceptorCanAccessMainSlidesCreateView(): void + { + $authModel = AuthModel::factory()->createOneQuietly(); + $authModel->update(['role' => RoleEnum::conceptor]); + $response = $this->actingAs($authModel, 'backend')->get( + route(config('unit-tests.route.prefix') . 'main_slides.' . config('unit-tests.view.resources-create')) + ); + $response->assertSuccessful(); + $response->assertViewIs( + config('unit-tests.view.prefix') . + 'pages.main_slides.' . + config('unit-tests.view.resources-create') + ); + } + + /** @return void */ + public function testUserConceptorCanAccessMainSlidesUpdateView(): void + { + $authModel = AuthModel::factory()->createOneQuietly(); + $authModel->update(['role' => RoleEnum::conceptor]); + $model = MainSlide::factory()->createOneQuietly(); + $response = $this->actingAs($authModel, 'backend')->get( + route(config('unit-tests.route.prefix') . 'main_slides.' . config('unit-tests.view.resources-update'), $model) + ); + $response->assertSuccessful(); + $response->assertViewIs( + config('unit-tests.view.prefix') . + 'pages.main_slides.' . + config('unit-tests.view.resources-update') + ); + } + + /** + * TESTS CAN ACTIONS ON MODEL. + */ + + /** @return void */ + public function testCanCreateMainSlide(): void + { + $model = MainSlide::factory()->createOneQuietly(); + $this->assertModelExists($model); + } + + /** @return void */ + public function testCanUpdateMainSlide(): void + { + $model = MainSlide::factory()->createOneQuietly(); + + $fieldTest = ""; + foreach (config('unit-tests.list-fields') as $field) { + if (Schema::hasColumn($model->getTable(), $field)) { + $model->update([$field => "test"]); + $fieldTest = $field; + break; + } + } + + $this->assertTrue($model->wasChanged()); + $this->assertTrue(array_key_exists($fieldTest, $model->getChanges())); + $this->assertModelExists($model); + } + + /** @return void */ + public function testCanDeleteMainSlide(): void + { + $model = MainSlide::factory()->createOneQuietly(); + $model->delete(); + $this->assertModelMissing($model); + } +} diff --git a/tests/Back/MeatTest.php b/tests/Back/MeatTest.php new file mode 100644 index 00000000..2db4e964 --- /dev/null +++ b/tests/Back/MeatTest.php @@ -0,0 +1,218 @@ +get(route( + config('unit-tests.route.prefix') . + 'meats.' . + config('unit-tests.view.resources-index') + )); + $response->assertRedirect(route(config('unit-tests.route.prefix') . 'login')); + } + + /** @return void */ + public function testGuestCannotAccessMeatsReadView(): void + { + $model = Meat::factory()->createOneQuietly(); + $response = $this->get(route( + config('unit-tests.route.prefix') . + 'meats.' . + config('unit-tests.view.resources-read'), + $model->getKey() + )); + $response->assertRedirect(route(config('unit-tests.route.prefix') . 'login')); + } + + /** @return void */ + public function testGuestCannotAccessMeatsCreateView(): void + { + $response = $this->get(route( + config('unit-tests.route.prefix') . + 'meats.' . + config('unit-tests.view.resources-create') + )); + $response->assertRedirect(route(config('unit-tests.route.prefix') . 'login')); + } + + /** @return void */ + public function testGuestCannotAccessMeatsUpdateView(): void + { + $model = Meat::factory()->createOneQuietly(); + $response = $this->get(route( + config('unit-tests.route.prefix') . + 'meats.' . + config('unit-tests.view.resources-update'), + $model->getKey() + )); + $response->assertRedirect(route(config('unit-tests.route.prefix') . 'login')); + } + + /** + * TESTS GUEST CANNOT POST MODEL. + */ + + /** @return void */ + public function testGuestCannotCreateMeat(): void + { + $model = Meat::factory()->createOneQuietly(); + $response = $this->post( + route( + config('unit-tests.route.prefix') . 'meats.' . config('unit-tests.route.action-create'), + $model->getKey() + ), + $model->toArray() + ); + $response->assertRedirect(route(config('unit-tests.route.prefix') . 'login')); + } + + /** @return void */ + public function testGuestCannotUpdateMeat(): void + { + $model = Meat::factory()->createOneQuietly(); + $response = $this->patch( + route( + config('unit-tests.route.prefix') . 'meats.' . config('unit-tests.route.action-update'), + $model->getKey() + ), + $model->toArray() + ); + $response->assertRedirect(route(config('unit-tests.route.prefix') . 'login')); + } + + /** @return void */ + public function testGuestCannotDeleteMeat(): void + { + $model = Meat::factory()->createOneQuietly(); + $response = $this->delete( + route( + config('unit-tests.route.prefix') . 'meats.' . config('unit-tests.route.action-delete'), + $model->getKey() + ), + $model->toArray() + ); + $response->assertRedirect(route(config('unit-tests.route.prefix') . 'login')); + } + + /** + * TESTS USER CONCEPTOR ACCESS VIEWS. + */ + + /** @return void */ + public function testUserConceptorCanAccessMeatsIndexView(): void + { + $authModel = AuthModel::factory()->createOneQuietly(); + $authModel->update(['role' => RoleEnum::conceptor]); + $response = $this->actingAs($authModel, 'backend')->get( + route(config('unit-tests.route.prefix') . 'meats.' . config('unit-tests.view.resources-index')) + ); + $response->assertSuccessful(); + $response->assertViewIs( + config('unit-tests.view.prefix') . + 'pages.meats.' . + config('unit-tests.view.resources-index') + ); + } + + /** @return void */ + public function testUserConceptorCanAccessMeatsReadView(): void + { + $authModel = AuthModel::factory()->createOneQuietly(); + $authModel->update(['role' => RoleEnum::conceptor]); + $model = Meat::factory()->createOneQuietly(); + $response = $this->actingAs($authModel, 'backend')->get( + route(config('unit-tests.route.prefix') . 'meats.' . config('unit-tests.view.resources-read'), $model) + ); + $response->assertSuccessful(); + $response->assertViewIs( + config('unit-tests.view.prefix') . + 'pages.meats.' . + config('unit-tests.view.resources-read') + ); + } + + /** @return void */ + public function testUserConceptorCanAccessMeatsCreateView(): void + { + $authModel = AuthModel::factory()->createOneQuietly(); + $authModel->update(['role' => RoleEnum::conceptor]); + $response = $this->actingAs($authModel, 'backend')->get( + route(config('unit-tests.route.prefix') . 'meats.' . config('unit-tests.view.resources-create')) + ); + $response->assertSuccessful(); + $response->assertViewIs( + config('unit-tests.view.prefix') . + 'pages.meats.' . + config('unit-tests.view.resources-create') + ); + } + + /** @return void */ + public function testUserConceptorCanAccessMeatsUpdateView(): void + { + $authModel = AuthModel::factory()->createOneQuietly(); + $authModel->update(['role' => RoleEnum::conceptor]); + $model = Meat::factory()->createOneQuietly(); + $response = $this->actingAs($authModel, 'backend')->get( + route(config('unit-tests.route.prefix') . 'meats.' . config('unit-tests.view.resources-update'), $model) + ); + $response->assertSuccessful(); + $response->assertViewIs( + config('unit-tests.view.prefix') . + 'pages.meats.' . + config('unit-tests.view.resources-update') + ); + } + + /** + * TESTS CAN ACTIONS ON MODEL. + */ + + /** @return void */ + public function testCanCreateMeat(): void + { + $model = Meat::factory()->createOneQuietly(); + $this->assertModelExists($model); + } + + /** @return void */ + public function testCanUpdateMeat(): void + { + $model = Meat::factory()->createOneQuietly(); + + $fieldTest = ""; + foreach (config('unit-tests.list-fields') as $field) { + if (Schema::hasColumn($model->getTable(), $field)) { + $model->update([$field => "test"]); + $fieldTest = $field; + break; + } + } + + $this->assertTrue($model->wasChanged()); + $this->assertTrue(array_key_exists($fieldTest, $model->getChanges())); + $this->assertModelExists($model); + } + + /** @return void */ + public function testCanDeleteMeat(): void + { + $model = Meat::factory()->createOneQuietly(); + $model->delete(); + $this->assertModelMissing($model); + } +} diff --git a/tests/Back/MenuNodeDataTest.php b/tests/Back/MenuNodeDataTest.php new file mode 100644 index 00000000..d9016662 --- /dev/null +++ b/tests/Back/MenuNodeDataTest.php @@ -0,0 +1,35 @@ +createOneQuietly(); + + $fieldTest = ""; + foreach (config('unit-tests.list-fields') as $field) { + if (Schema::hasColumn($model->getTable(), $field)) { + $model->update([$field => "test"]); + $fieldTest = $field; + break; + } + } + + $this->assertTrue($model->wasChanged()); + $this->assertTrue(array_key_exists($fieldTest, $model->getChanges())); + $this->assertModelExists($model); + } +} diff --git a/tests/Back/NewsBreedingTest.php b/tests/Back/NewsBreedingTest.php new file mode 100644 index 00000000..13245117 --- /dev/null +++ b/tests/Back/NewsBreedingTest.php @@ -0,0 +1,218 @@ +get(route( + config('unit-tests.route.prefix') . + 'news_breedings.' . + config('unit-tests.view.resources-index') + )); + $response->assertRedirect(route(config('unit-tests.route.prefix') . 'login')); + } + + /** @return void */ + public function testGuestCannotAccessNewsBreedingsReadView(): void + { + $model = NewsBreeding::factory()->createOneQuietly(); + $response = $this->get(route( + config('unit-tests.route.prefix') . + 'news_breedings.' . + config('unit-tests.view.resources-read'), + $model->getKey() + )); + $response->assertRedirect(route(config('unit-tests.route.prefix') . 'login')); + } + + /** @return void */ + public function testGuestCannotAccessNewsBreedingsCreateView(): void + { + $response = $this->get(route( + config('unit-tests.route.prefix') . + 'news_breedings.' . + config('unit-tests.view.resources-create') + )); + $response->assertRedirect(route(config('unit-tests.route.prefix') . 'login')); + } + + /** @return void */ + public function testGuestCannotAccessNewsBreedingsUpdateView(): void + { + $model = NewsBreeding::factory()->createOneQuietly(); + $response = $this->get(route( + config('unit-tests.route.prefix') . + 'news_breedings.' . + config('unit-tests.view.resources-update'), + $model->getKey() + )); + $response->assertRedirect(route(config('unit-tests.route.prefix') . 'login')); + } + + /** + * TESTS GUEST CANNOT POST MODEL. + */ + + /** @return void */ + public function testGuestCannotCreateNewsBreeding(): void + { + $model = NewsBreeding::factory()->createOneQuietly(); + $response = $this->post( + route( + config('unit-tests.route.prefix') . 'news_breedings.' . config('unit-tests.route.action-create'), + $model->getKey() + ), + $model->toArray() + ); + $response->assertRedirect(route(config('unit-tests.route.prefix') . 'login')); + } + + /** @return void */ + public function testGuestCannotUpdateNewsBreeding(): void + { + $model = NewsBreeding::factory()->createOneQuietly(); + $response = $this->patch( + route( + config('unit-tests.route.prefix') . 'news_breedings.' . config('unit-tests.route.action-update'), + $model->getKey() + ), + $model->toArray() + ); + $response->assertRedirect(route(config('unit-tests.route.prefix') . 'login')); + } + + /** @return void */ + public function testGuestCannotDeleteNewsBreeding(): void + { + $model = NewsBreeding::factory()->createOneQuietly(); + $response = $this->delete( + route( + config('unit-tests.route.prefix') . 'news_breedings.' . config('unit-tests.route.action-delete'), + $model->getKey() + ), + $model->toArray() + ); + $response->assertRedirect(route(config('unit-tests.route.prefix') . 'login')); + } + + /** + * TESTS USER CONCEPTOR ACCESS VIEWS. + */ + + /** @return void */ + public function testUserConceptorCanAccessNewsBreedingsIndexView(): void + { + $authModel = AuthModel::factory()->createOneQuietly(); + $authModel->update(['role' => RoleEnum::conceptor]); + $response = $this->actingAs($authModel, 'backend')->get( + route(config('unit-tests.route.prefix') . 'news_breedings.' . config('unit-tests.view.resources-index')) + ); + $response->assertSuccessful(); + $response->assertViewIs( + config('unit-tests.view.prefix') . + 'pages.news_breedings.' . + config('unit-tests.view.resources-index') + ); + } + + /** @return void */ + public function testUserConceptorCanAccessNewsBreedingsReadView(): void + { + $authModel = AuthModel::factory()->createOneQuietly(); + $authModel->update(['role' => RoleEnum::conceptor]); + $model = NewsBreeding::factory()->createOneQuietly(); + $response = $this->actingAs($authModel, 'backend')->get( + route(config('unit-tests.route.prefix') . 'news_breedings.' . config('unit-tests.view.resources-read'), $model) + ); + $response->assertSuccessful(); + $response->assertViewIs( + config('unit-tests.view.prefix') . + 'pages.news_breedings.' . + config('unit-tests.view.resources-read') + ); + } + + /** @return void */ + public function testUserConceptorCanAccessNewsBreedingsCreateView(): void + { + $authModel = AuthModel::factory()->createOneQuietly(); + $authModel->update(['role' => RoleEnum::conceptor]); + $response = $this->actingAs($authModel, 'backend')->get( + route(config('unit-tests.route.prefix') . 'news_breedings.' . config('unit-tests.view.resources-create')) + ); + $response->assertSuccessful(); + $response->assertViewIs( + config('unit-tests.view.prefix') . + 'pages.news_breedings.' . + config('unit-tests.view.resources-create') + ); + } + + /** @return void */ + public function testUserConceptorCanAccessNewsBreedingsUpdateView(): void + { + $authModel = AuthModel::factory()->createOneQuietly(); + $authModel->update(['role' => RoleEnum::conceptor]); + $model = NewsBreeding::factory()->createOneQuietly(); + $response = $this->actingAs($authModel, 'backend')->get( + route(config('unit-tests.route.prefix') . 'news_breedings.' . config('unit-tests.view.resources-update'), $model) + ); + $response->assertSuccessful(); + $response->assertViewIs( + config('unit-tests.view.prefix') . + 'pages.news_breedings.' . + config('unit-tests.view.resources-update') + ); + } + + /** + * TESTS CAN ACTIONS ON MODEL. + */ + + /** @return void */ + public function testCanCreateNewsBreeding(): void + { + $model = NewsBreeding::factory()->createOneQuietly(); + $this->assertModelExists($model); + } + + /** @return void */ + public function testCanUpdateNewsBreeding(): void + { + $model = NewsBreeding::factory()->createOneQuietly(); + + $fieldTest = ""; + foreach (config('unit-tests.list-fields') as $field) { + if (Schema::hasColumn($model->getTable(), $field)) { + $model->update([$field => "test"]); + $fieldTest = $field; + break; + } + } + + $this->assertTrue($model->wasChanged()); + $this->assertTrue(array_key_exists($fieldTest, $model->getChanges())); + $this->assertModelExists($model); + } + + /** @return void */ + public function testCanDeleteNewsBreeding(): void + { + $model = NewsBreeding::factory()->createOneQuietly(); + $model->delete(); + $this->assertModelMissing($model); + } +} diff --git a/tests/Back/NewsCategoryTest.php b/tests/Back/NewsCategoryTest.php new file mode 100644 index 00000000..cca31c17 --- /dev/null +++ b/tests/Back/NewsCategoryTest.php @@ -0,0 +1,218 @@ +get(route( + config('unit-tests.route.prefix') . + 'news_categories.' . + config('unit-tests.view.resources-index') + )); + $response->assertRedirect(route(config('unit-tests.route.prefix') . 'login')); + } + + /** @return void */ + public function testGuestCannotAccessNewsCategorysReadView(): void + { + $model = NewsCategory::factory()->createOneQuietly(); + $response = $this->get(route( + config('unit-tests.route.prefix') . + 'news_categories.' . + config('unit-tests.view.resources-read'), + $model->getKey() + )); + $response->assertRedirect(route(config('unit-tests.route.prefix') . 'login')); + } + + /** @return void */ + public function testGuestCannotAccessNewsCategorysCreateView(): void + { + $response = $this->get(route( + config('unit-tests.route.prefix') . + 'news_categories.' . + config('unit-tests.view.resources-create') + )); + $response->assertRedirect(route(config('unit-tests.route.prefix') . 'login')); + } + + /** @return void */ + public function testGuestCannotAccessNewsCategorysUpdateView(): void + { + $model = NewsCategory::factory()->createOneQuietly(); + $response = $this->get(route( + config('unit-tests.route.prefix') . + 'news_categories.' . + config('unit-tests.view.resources-update'), + $model->getKey() + )); + $response->assertRedirect(route(config('unit-tests.route.prefix') . 'login')); + } + + /** + * TESTS GUEST CANNOT POST MODEL. + */ + + /** @return void */ + public function testGuestCannotCreateNewsCategory(): void + { + $model = NewsCategory::factory()->createOneQuietly(); + $response = $this->post( + route( + config('unit-tests.route.prefix') . 'news_categories.' . config('unit-tests.route.action-create'), + $model->getKey() + ), + $model->toArray() + ); + $response->assertRedirect(route(config('unit-tests.route.prefix') . 'login')); + } + + /** @return void */ + public function testGuestCannotUpdateNewsCategory(): void + { + $model = NewsCategory::factory()->createOneQuietly(); + $response = $this->patch( + route( + config('unit-tests.route.prefix') . 'news_categories.' . config('unit-tests.route.action-update'), + $model->getKey() + ), + $model->toArray() + ); + $response->assertRedirect(route(config('unit-tests.route.prefix') . 'login')); + } + + /** @return void */ + public function testGuestCannotDeleteNewsCategory(): void + { + $model = NewsCategory::factory()->createOneQuietly(); + $response = $this->delete( + route( + config('unit-tests.route.prefix') . 'news_categories.' . config('unit-tests.route.action-delete'), + $model->getKey() + ), + $model->toArray() + ); + $response->assertRedirect(route(config('unit-tests.route.prefix') . 'login')); + } + + /** + * TESTS USER CONCEPTOR ACCESS VIEWS. + */ + + /** @return void */ + public function testUserConceptorCanAccessNewsCategorysIndexView(): void + { + $authModel = AuthModel::factory()->createOneQuietly(); + $authModel->update(['role' => RoleEnum::conceptor]); + $response = $this->actingAs($authModel, 'backend')->get( + route(config('unit-tests.route.prefix') . 'news_categories.' . config('unit-tests.view.resources-index')) + ); + $response->assertSuccessful(); + $response->assertViewIs( + config('unit-tests.view.prefix') . + 'pages.news_categories.' . + config('unit-tests.view.resources-index') + ); + } + + /** @return void */ + public function testUserConceptorCanAccessNewsCategorysReadView(): void + { + $authModel = AuthModel::factory()->createOneQuietly(); + $authModel->update(['role' => RoleEnum::conceptor]); + $model = NewsCategory::factory()->createOneQuietly(); + $response = $this->actingAs($authModel, 'backend')->get( + route(config('unit-tests.route.prefix') . 'news_categories.' . config('unit-tests.view.resources-read'), $model) + ); + $response->assertSuccessful(); + $response->assertViewIs( + config('unit-tests.view.prefix') . + 'pages.news_categories.' . + config('unit-tests.view.resources-read') + ); + } + + /** @return void */ + public function testUserConceptorCanAccessNewsCategorysCreateView(): void + { + $authModel = AuthModel::factory()->createOneQuietly(); + $authModel->update(['role' => RoleEnum::conceptor]); + $response = $this->actingAs($authModel, 'backend')->get( + route(config('unit-tests.route.prefix') . 'news_categories.' . config('unit-tests.view.resources-create')) + ); + $response->assertSuccessful(); + $response->assertViewIs( + config('unit-tests.view.prefix') . + 'pages.news_categories.' . + config('unit-tests.view.resources-create') + ); + } + + /** @return void */ + public function testUserConceptorCanAccessNewsCategorysUpdateView(): void + { + $authModel = AuthModel::factory()->createOneQuietly(); + $authModel->update(['role' => RoleEnum::conceptor]); + $model = NewsCategory::factory()->createOneQuietly(); + $response = $this->actingAs($authModel, 'backend')->get( + route(config('unit-tests.route.prefix') . 'news_categories.' . config('unit-tests.view.resources-update'), $model) + ); + $response->assertSuccessful(); + $response->assertViewIs( + config('unit-tests.view.prefix') . + 'pages.news_categories.' . + config('unit-tests.view.resources-update') + ); + } + + /** + * TESTS CAN ACTIONS ON MODEL. + */ + + /** @return void */ + public function testCanCreateNewsCategory(): void + { + $model = NewsCategory::factory()->createOneQuietly(); + $this->assertModelExists($model); + } + + /** @return void */ + public function testCanUpdateNewsCategory(): void + { + $model = NewsCategory::factory()->createOneQuietly(); + + $fieldTest = ""; + foreach (config('unit-tests.list-fields') as $field) { + if (Schema::hasColumn($model->getTable(), $field)) { + $model->update([$field => "test"]); + $fieldTest = $field; + break; + } + } + + $this->assertTrue($model->wasChanged()); + $this->assertTrue(array_key_exists($fieldTest, $model->getChanges())); + $this->assertModelExists($model); + } + + /** @return void */ + public function testCanDeleteNewsCategory(): void + { + $model = NewsCategory::factory()->createOneQuietly(); + $model->delete(); + $this->assertModelMissing($model); + } +} diff --git a/tests/Back/NewsClubNewsTest.php b/tests/Back/NewsClubNewsTest.php new file mode 100644 index 00000000..d9095e4b --- /dev/null +++ b/tests/Back/NewsClubNewsTest.php @@ -0,0 +1,227 @@ +get(route( + config('unit-tests.route.prefix') . + 'news_clubs.' . + config('unit-tests.view.resources-index'), + ['news_club_type' => NewsClubTypeEnum::news->value()] + )); + $response->assertRedirect(route(config('unit-tests.route.prefix') . 'login')); + } + + /** @return void */ + public function testGuestCannotAccessNewsClubsReadView(): void + { + $model = NewsClub::factory()->createOneQuietly(); + $response = $this->get(route( + config('unit-tests.route.prefix') . + 'news_clubs.' . + config('unit-tests.view.resources-read'), + $model->getKey() + )); + $response->assertRedirect(route(config('unit-tests.route.prefix') . 'login')); + } + + /** @return void */ + public function testGuestCannotAccessNewsClubsCreateView(): void + { + $response = $this->get(route( + config('unit-tests.route.prefix') . + 'news_clubs.' . + config('unit-tests.view.resources-create'), + ['news_club_type' => NewsClubTypeEnum::news->value()] + )); + $response->assertRedirect(route(config('unit-tests.route.prefix') . 'login')); + } + + /** @return void */ + public function testGuestCannotAccessNewsClubsUpdateView(): void + { + $model = NewsClub::factory()->createOneQuietly(); + $response = $this->get(route( + config('unit-tests.route.prefix') . + 'news_clubs.' . + config('unit-tests.view.resources-update'), + $model->getKey() + )); + $response->assertRedirect(route(config('unit-tests.route.prefix') . 'login')); + } + + /** + * TESTS GUEST CANNOT POST MODEL. + */ + + /** @return void */ + public function testGuestCannotCreateNewsClub(): void + { + $model = NewsClub::factory()->createOneQuietly(); + $response = $this->post( + route( + config('unit-tests.route.prefix') . 'news_clubs.' . config('unit-tests.route.action-create'), + $model->getKey() + ), + $model->toArray() + ); + $response->assertRedirect(route(config('unit-tests.route.prefix') . 'login')); + } + + /** @return void */ + public function testGuestCannotUpdateNewsClub(): void + { + $model = NewsClub::factory()->createOneQuietly(); + $response = $this->patch( + route( + config('unit-tests.route.prefix') . 'news_clubs.' . config('unit-tests.route.action-update'), + $model->getKey() + ), + $model->toArray() + ); + $response->assertRedirect(route(config('unit-tests.route.prefix') . 'login')); + } + + /** @return void */ + public function testGuestCannotDeleteNewsClub(): void + { + $model = NewsClub::factory()->createOneQuietly(); + $response = $this->delete( + route( + config('unit-tests.route.prefix') . 'news_clubs.' . config('unit-tests.route.action-delete'), + $model->getKey() + ), + $model->toArray() + ); + $response->assertRedirect(route(config('unit-tests.route.prefix') . 'login')); + } + + /** + * TESTS USER CONCEPTOR ACCESS VIEWS. + */ + + /** @return void */ + public function testUserConceptorCanAccessNewsClubsIndexView(): void + { + $authModel = AuthModel::factory()->createOneQuietly(); + $authModel->update(['role' => RoleEnum::conceptor]); + $response = $this->actingAs($authModel, 'backend')->get( + route( + config('unit-tests.route.prefix') . 'news_clubs.' . config('unit-tests.view.resources-index'), + ['news_club_type' => NewsClubTypeEnum::news->value()] + ) + ); + $response->assertSuccessful(); + $response->assertViewIs( + config('unit-tests.view.prefix') . + 'pages.news_clubs.' . + config('unit-tests.view.resources-index') + ); + } + + /** @return void */ + public function testUserConceptorCanAccessNewsClubsReadView(): void + { + $authModel = AuthModel::factory()->createOneQuietly(); + $authModel->update(['role' => RoleEnum::conceptor]); + $model = NewsClub::factory()->createOneQuietly(); + $response = $this->actingAs($authModel, 'backend')->get( + route(config('unit-tests.route.prefix') . 'news_clubs.' . config('unit-tests.view.resources-read'), $model) + ); + $response->assertSuccessful(); + $response->assertViewIs( + config('unit-tests.view.prefix') . + 'pages.news_clubs.' . + config('unit-tests.view.resources-read') + ); + } + + /** @return void */ + public function testUserConceptorCanAccessNewsClubsCreateView(): void + { + $authModel = AuthModel::factory()->createOneQuietly(); + $authModel->update(['role' => RoleEnum::conceptor]); + $response = $this->actingAs($authModel, 'backend')->get( + route( + config('unit-tests.route.prefix') . 'news_clubs.' . config('unit-tests.view.resources-create'), + ['news_club_type' => NewsClubTypeEnum::news->value()] + ) + ); + $response->assertSuccessful(); + $response->assertViewIs( + config('unit-tests.view.prefix') . + 'pages.news_clubs.' . + config('unit-tests.view.resources-create') + ); + } + + /** @return void */ + public function testUserConceptorCanAccessNewsClubsUpdateView(): void + { + $authModel = AuthModel::factory()->createOneQuietly(); + $authModel->update(['role' => RoleEnum::conceptor]); + $model = NewsClub::factory()->createOneQuietly(); + $response = $this->actingAs($authModel, 'backend')->get( + route(config('unit-tests.route.prefix') . 'news_clubs.' . config('unit-tests.view.resources-update'), $model) + ); + $response->assertSuccessful(); + $response->assertViewIs( + config('unit-tests.view.prefix') . + 'pages.news_clubs.' . + config('unit-tests.view.resources-update') + ); + } + + /** + * TESTS CAN ACTIONS ON MODEL. + */ + + /** @return void */ + public function testCanCreateNewsClub(): void + { + $model = NewsClub::factory()->createOneQuietly(); + $this->assertModelExists($model); + } + + /** @return void */ + public function testCanUpdateNewsClub(): void + { + $model = NewsClub::factory()->createOneQuietly(); + + $fieldTest = ""; + foreach (config('unit-tests.list-fields') as $field) { + if (Schema::hasColumn($model->getTable(), $field)) { + $model->update([$field => "test"]); + $fieldTest = $field; + break; + } + } + + $this->assertTrue($model->wasChanged()); + $this->assertTrue(array_key_exists($fieldTest, $model->getChanges())); + $this->assertModelExists($model); + } + + /** @return void */ + public function testCanDeleteNewsClub(): void + { + $model = NewsClub::factory()->createOneQuietly(); + $model->delete(); + $this->assertModelMissing($model); + } +} diff --git a/tests/Back/NewsClubSurveyTest.php b/tests/Back/NewsClubSurveyTest.php new file mode 100644 index 00000000..5d44b562 --- /dev/null +++ b/tests/Back/NewsClubSurveyTest.php @@ -0,0 +1,227 @@ +get(route( + config('unit-tests.route.prefix') . + 'news_clubs.' . + config('unit-tests.view.resources-index'), + ['news_club_type' => NewsClubTypeEnum::survey->value()] + )); + $response->assertRedirect(route(config('unit-tests.route.prefix') . 'login')); + } + + /** @return void */ + public function testGuestCannotAccessNewsClubsReadView(): void + { + $model = NewsClub::factory()->createOneQuietly(); + $response = $this->get(route( + config('unit-tests.route.prefix') . + 'news_clubs.' . + config('unit-tests.view.resources-read'), + $model->getKey() + )); + $response->assertRedirect(route(config('unit-tests.route.prefix') . 'login')); + } + + /** @return void */ + public function testGuestCannotAccessNewsClubsCreateView(): void + { + $response = $this->get(route( + config('unit-tests.route.prefix') . + 'news_clubs.' . + config('unit-tests.view.resources-create'), + ['news_club_type' => NewsClubTypeEnum::survey->value()] + )); + $response->assertRedirect(route(config('unit-tests.route.prefix') . 'login')); + } + + /** @return void */ + public function testGuestCannotAccessNewsClubsUpdateView(): void + { + $model = NewsClub::factory()->createOneQuietly(); + $response = $this->get(route( + config('unit-tests.route.prefix') . + 'news_clubs.' . + config('unit-tests.view.resources-update'), + $model->getKey() + )); + $response->assertRedirect(route(config('unit-tests.route.prefix') . 'login')); + } + + /** + * TESTS GUEST CANNOT POST MODEL. + */ + + /** @return void */ + public function testGuestCannotCreateNewsClub(): void + { + $model = NewsClub::factory()->createOneQuietly(); + $response = $this->post( + route( + config('unit-tests.route.prefix') . 'news_clubs.' . config('unit-tests.route.action-create'), + $model->getKey() + ), + $model->toArray() + ); + $response->assertRedirect(route(config('unit-tests.route.prefix') . 'login')); + } + + /** @return void */ + public function testGuestCannotUpdateNewsClub(): void + { + $model = NewsClub::factory()->createOneQuietly(); + $response = $this->patch( + route( + config('unit-tests.route.prefix') . 'news_clubs.' . config('unit-tests.route.action-update'), + $model->getKey() + ), + $model->toArray() + ); + $response->assertRedirect(route(config('unit-tests.route.prefix') . 'login')); + } + + /** @return void */ + public function testGuestCannotDeleteNewsClub(): void + { + $model = NewsClub::factory()->createOneQuietly(); + $response = $this->delete( + route( + config('unit-tests.route.prefix') . 'news_clubs.' . config('unit-tests.route.action-delete'), + $model->getKey() + ), + $model->toArray() + ); + $response->assertRedirect(route(config('unit-tests.route.prefix') . 'login')); + } + + /** + * TESTS USER CONCEPTOR ACCESS VIEWS. + */ + + /** @return void */ + public function testUserConceptorCanAccessNewsClubsIndexView(): void + { + $authModel = AuthModel::factory()->createOneQuietly(); + $authModel->update(['role' => RoleEnum::conceptor]); + $response = $this->actingAs($authModel, 'backend')->get( + route( + config('unit-tests.route.prefix') . 'news_clubs.' . config('unit-tests.view.resources-index'), + ['news_club_type' => NewsClubTypeEnum::survey->value()] + ) + ); + $response->assertSuccessful(); + $response->assertViewIs( + config('unit-tests.view.prefix') . + 'pages.news_clubs.' . + config('unit-tests.view.resources-index') + ); + } + + /** @return void */ + public function testUserConceptorCanAccessNewsClubsReadView(): void + { + $authModel = AuthModel::factory()->createOneQuietly(); + $authModel->update(['role' => RoleEnum::conceptor]); + $model = NewsClub::factory()->createOneQuietly(); + $response = $this->actingAs($authModel, 'backend')->get( + route(config('unit-tests.route.prefix') . 'news_clubs.' . config('unit-tests.view.resources-read'), $model) + ); + $response->assertSuccessful(); + $response->assertViewIs( + config('unit-tests.view.prefix') . + 'pages.news_clubs.' . + config('unit-tests.view.resources-read') + ); + } + + /** @return void */ + public function testUserConceptorCanAccessNewsClubsCreateView(): void + { + $authModel = AuthModel::factory()->createOneQuietly(); + $authModel->update(['role' => RoleEnum::conceptor]); + $response = $this->actingAs($authModel, 'backend')->get( + route( + config('unit-tests.route.prefix') . 'news_clubs.' . config('unit-tests.view.resources-create'), + ['news_club_type' => NewsClubTypeEnum::survey->value()] + ) + ); + $response->assertSuccessful(); + $response->assertViewIs( + config('unit-tests.view.prefix') . + 'pages.news_clubs.' . + config('unit-tests.view.resources-create') + ); + } + + /** @return void */ + public function testUserConceptorCanAccessNewsClubsUpdateView(): void + { + $authModel = AuthModel::factory()->createOneQuietly(); + $authModel->update(['role' => RoleEnum::conceptor]); + $model = NewsClub::factory()->createOneQuietly(); + $response = $this->actingAs($authModel, 'backend')->get( + route(config('unit-tests.route.prefix') . 'news_clubs.' . config('unit-tests.view.resources-update'), $model) + ); + $response->assertSuccessful(); + $response->assertViewIs( + config('unit-tests.view.prefix') . + 'pages.news_clubs.' . + config('unit-tests.view.resources-update') + ); + } + + /** + * TESTS CAN ACTIONS ON MODEL. + */ + + /** @return void */ + public function testCanCreateNewsClub(): void + { + $model = NewsClub::factory()->createOneQuietly(); + $this->assertModelExists($model); + } + + /** @return void */ + public function testCanUpdateNewsClub(): void + { + $model = NewsClub::factory()->createOneQuietly(); + + $fieldTest = ""; + foreach (config('unit-tests.list-fields') as $field) { + if (Schema::hasColumn($model->getTable(), $field)) { + $model->update([$field => "test"]); + $fieldTest = $field; + break; + } + } + + $this->assertTrue($model->wasChanged()); + $this->assertTrue(array_key_exists($fieldTest, $model->getChanges())); + $this->assertModelExists($model); + } + + /** @return void */ + public function testCanDeleteNewsClub(): void + { + $model = NewsClub::factory()->createOneQuietly(); + $model->delete(); + $this->assertModelMissing($model); + } +} diff --git a/tests/Back/NewsCorporateTest.php b/tests/Back/NewsCorporateTest.php new file mode 100644 index 00000000..41916c84 --- /dev/null +++ b/tests/Back/NewsCorporateTest.php @@ -0,0 +1,218 @@ +get(route( + config('unit-tests.route.prefix') . + 'news_corporates.' . + config('unit-tests.view.resources-index') + )); + $response->assertRedirect(route(config('unit-tests.route.prefix') . 'login')); + } + + /** @return void */ + public function testGuestCannotAccessNewsCorporatesReadView(): void + { + $model = NewsCorporate::factory()->createOneQuietly(); + $response = $this->get(route( + config('unit-tests.route.prefix') . + 'news_corporates.' . + config('unit-tests.view.resources-read'), + $model->getKey() + )); + $response->assertRedirect(route(config('unit-tests.route.prefix') . 'login')); + } + + /** @return void */ + public function testGuestCannotAccessNewsCorporatesCreateView(): void + { + $response = $this->get(route( + config('unit-tests.route.prefix') . + 'news_corporates.' . + config('unit-tests.view.resources-create') + )); + $response->assertRedirect(route(config('unit-tests.route.prefix') . 'login')); + } + + /** @return void */ + public function testGuestCannotAccessNewsCorporatesUpdateView(): void + { + $model = NewsCorporate::factory()->createOneQuietly(); + $response = $this->get(route( + config('unit-tests.route.prefix') . + 'news_corporates.' . + config('unit-tests.view.resources-update'), + $model->getKey() + )); + $response->assertRedirect(route(config('unit-tests.route.prefix') . 'login')); + } + + /** + * TESTS GUEST CANNOT POST MODEL. + */ + + /** @return void */ + public function testGuestCannotCreateNewsCorporate(): void + { + $model = NewsCorporate::factory()->createOneQuietly(); + $response = $this->post( + route( + config('unit-tests.route.prefix') . 'news_corporates.' . config('unit-tests.route.action-create'), + $model->getKey() + ), + $model->toArray() + ); + $response->assertRedirect(route(config('unit-tests.route.prefix') . 'login')); + } + + /** @return void */ + public function testGuestCannotUpdateNewsCorporate(): void + { + $model = NewsCorporate::factory()->createOneQuietly(); + $response = $this->patch( + route( + config('unit-tests.route.prefix') . 'news_corporates.' . config('unit-tests.route.action-update'), + $model->getKey() + ), + $model->toArray() + ); + $response->assertRedirect(route(config('unit-tests.route.prefix') . 'login')); + } + + /** @return void */ + public function testGuestCannotDeleteNewsCorporate(): void + { + $model = NewsCorporate::factory()->createOneQuietly(); + $response = $this->delete( + route( + config('unit-tests.route.prefix') . 'news_corporates.' . config('unit-tests.route.action-delete'), + $model->getKey() + ), + $model->toArray() + ); + $response->assertRedirect(route(config('unit-tests.route.prefix') . 'login')); + } + + /** + * TESTS USER CONCEPTOR ACCESS VIEWS. + */ + + /** @return void */ + public function testUserConceptorCanAccessNewsCorporatesIndexView(): void + { + $authModel = AuthModel::factory()->createOneQuietly(); + $authModel->update(['role' => RoleEnum::conceptor]); + $response = $this->actingAs($authModel, 'backend')->get( + route(config('unit-tests.route.prefix') . 'news_corporates.' . config('unit-tests.view.resources-index')) + ); + $response->assertSuccessful(); + $response->assertViewIs( + config('unit-tests.view.prefix') . + 'pages.news_corporates.' . + config('unit-tests.view.resources-index') + ); + } + + /** @return void */ + public function testUserConceptorCanAccessNewsCorporatesReadView(): void + { + $authModel = AuthModel::factory()->createOneQuietly(); + $authModel->update(['role' => RoleEnum::conceptor]); + $model = NewsCorporate::factory()->createOneQuietly(); + $response = $this->actingAs($authModel, 'backend')->get( + route(config('unit-tests.route.prefix') . 'news_corporates.' . config('unit-tests.view.resources-read'), $model) + ); + $response->assertSuccessful(); + $response->assertViewIs( + config('unit-tests.view.prefix') . + 'pages.news_corporates.' . + config('unit-tests.view.resources-read') + ); + } + + /** @return void */ + public function testUserConceptorCanAccessNewsCorporatesCreateView(): void + { + $authModel = AuthModel::factory()->createOneQuietly(); + $authModel->update(['role' => RoleEnum::conceptor]); + $response = $this->actingAs($authModel, 'backend')->get( + route(config('unit-tests.route.prefix') . 'news_corporates.' . config('unit-tests.view.resources-create')) + ); + $response->assertSuccessful(); + $response->assertViewIs( + config('unit-tests.view.prefix') . + 'pages.news_corporates.' . + config('unit-tests.view.resources-create') + ); + } + + /** @return void */ + public function testUserConceptorCanAccessNewsCorporatesUpdateView(): void + { + $authModel = AuthModel::factory()->createOneQuietly(); + $authModel->update(['role' => RoleEnum::conceptor]); + $model = NewsCorporate::factory()->createOneQuietly(); + $response = $this->actingAs($authModel, 'backend')->get( + route(config('unit-tests.route.prefix') . 'news_corporates.' . config('unit-tests.view.resources-update'), $model) + ); + $response->assertSuccessful(); + $response->assertViewIs( + config('unit-tests.view.prefix') . + 'pages.news_corporates.' . + config('unit-tests.view.resources-update') + ); + } + + /** + * TESTS CAN ACTIONS ON MODEL. + */ + + /** @return void */ + public function testCanCreateNewsCorporate(): void + { + $model = NewsCorporate::factory()->createOneQuietly(); + $this->assertModelExists($model); + } + + /** @return void */ + public function testCanUpdateNewsCorporate(): void + { + $model = NewsCorporate::factory()->createOneQuietly(); + + $fieldTest = ""; + foreach (config('unit-tests.list-fields') as $field) { + if (Schema::hasColumn($model->getTable(), $field)) { + $model->update([$field => "test"]); + $fieldTest = $field; + break; + } + } + + $this->assertTrue($model->wasChanged()); + $this->assertTrue(array_key_exists($fieldTest, $model->getChanges())); + $this->assertModelExists($model); + } + + /** @return void */ + public function testCanDeleteNewsCorporate(): void + { + $model = NewsCorporate::factory()->createOneQuietly(); + $model->delete(); + $this->assertModelMissing($model); + } +} diff --git a/tests/Back/NewsTest.php b/tests/Back/NewsTest.php new file mode 100644 index 00000000..6679744c --- /dev/null +++ b/tests/Back/NewsTest.php @@ -0,0 +1,218 @@ +get(route( + config('unit-tests.route.prefix') . + 'news.' . + config('unit-tests.view.resources-index') + )); + $response->assertRedirect(route(config('unit-tests.route.prefix') . 'login')); + } + + /** @return void */ + public function testGuestCannotAccessNewsReadView(): void + { + $model = News::factory()->createOneQuietly(); + $response = $this->get(route( + config('unit-tests.route.prefix') . + 'news.' . + config('unit-tests.view.resources-read'), + $model->getKey() + )); + $response->assertRedirect(route(config('unit-tests.route.prefix') . 'login')); + } + + /** @return void */ + public function testGuestCannotAccessNewsCreateView(): void + { + $response = $this->get(route( + config('unit-tests.route.prefix') . + 'news.' . + config('unit-tests.view.resources-create') + )); + $response->assertRedirect(route(config('unit-tests.route.prefix') . 'login')); + } + + /** @return void */ + public function testGuestCannotAccessNewsUpdateView(): void + { + $model = News::factory()->createOneQuietly(); + $response = $this->get(route( + config('unit-tests.route.prefix') . + 'news.' . + config('unit-tests.view.resources-update'), + $model->getKey() + )); + $response->assertRedirect(route(config('unit-tests.route.prefix') . 'login')); + } + + /** + * TESTS GUEST CANNOT POST MODEL. + */ + + /** @return void */ + public function testGuestCannotCreateNews(): void + { + $model = News::factory()->createOneQuietly(); + $response = $this->post( + route( + config('unit-tests.route.prefix') . 'news.' . config('unit-tests.route.action-create'), + $model->getKey() + ), + $model->toArray() + ); + $response->assertRedirect(route(config('unit-tests.route.prefix') . 'login')); + } + + /** @return void */ + public function testGuestCannotUpdateNews(): void + { + $model = News::factory()->createOneQuietly(); + $response = $this->patch( + route( + config('unit-tests.route.prefix') . 'news.' . config('unit-tests.route.action-update'), + $model->getKey() + ), + $model->toArray() + ); + $response->assertRedirect(route(config('unit-tests.route.prefix') . 'login')); + } + + /** @return void */ + public function testGuestCannotDeleteNews(): void + { + $model = News::factory()->createOneQuietly(); + $response = $this->delete( + route( + config('unit-tests.route.prefix') . 'news.' . config('unit-tests.route.action-delete'), + $model->getKey() + ), + $model->toArray() + ); + $response->assertRedirect(route(config('unit-tests.route.prefix') . 'login')); + } + + /** + * TESTS USER CONCEPTOR ACCESS VIEWS. + */ + + /** @return void */ + public function testUserConceptorCanAccessNewsIndexView(): void + { + $authModel = AuthModel::factory()->createOneQuietly(); + $authModel->update(['role' => RoleEnum::conceptor]); + $response = $this->actingAs($authModel, 'backend')->get( + route(config('unit-tests.route.prefix') . 'news.' . config('unit-tests.view.resources-index')) + ); + $response->assertSuccessful(); + $response->assertViewIs( + config('unit-tests.view.prefix') . + 'pages.news.' . + config('unit-tests.view.resources-index') + ); + } + + /** @return void */ + public function testUserConceptorCanAccessNewsReadView(): void + { + $authModel = AuthModel::factory()->createOneQuietly(); + $authModel->update(['role' => RoleEnum::conceptor]); + $model = News::factory()->createOneQuietly(); + $response = $this->actingAs($authModel, 'backend')->get( + route(config('unit-tests.route.prefix') . 'news.' . config('unit-tests.view.resources-read'), $model) + ); + $response->assertSuccessful(); + $response->assertViewIs( + config('unit-tests.view.prefix') . + 'pages.news.' . + config('unit-tests.view.resources-read') + ); + } + + /** @return void */ + public function testUserConceptorCanAccessNewsCreateView(): void + { + $authModel = AuthModel::factory()->createOneQuietly(); + $authModel->update(['role' => RoleEnum::conceptor]); + $response = $this->actingAs($authModel, 'backend')->get( + route(config('unit-tests.route.prefix') . 'news.' . config('unit-tests.view.resources-create')) + ); + $response->assertSuccessful(); + $response->assertViewIs( + config('unit-tests.view.prefix') . + 'pages.news.' . + config('unit-tests.view.resources-create') + ); + } + + /** @return void */ + public function testUserConceptorCanAccessNewsUpdateView(): void + { + $authModel = AuthModel::factory()->createOneQuietly(); + $authModel->update(['role' => RoleEnum::conceptor]); + $model = News::factory()->createOneQuietly(); + $response = $this->actingAs($authModel, 'backend')->get( + route(config('unit-tests.route.prefix') . 'news.' . config('unit-tests.view.resources-update'), $model) + ); + $response->assertSuccessful(); + $response->assertViewIs( + config('unit-tests.view.prefix') . + 'pages.news.' . + config('unit-tests.view.resources-update') + ); + } + + /** + * TESTS CAN ACTIONS ON MODEL. + */ + + /** @return void */ + public function testCanCreateNews(): void + { + $model = News::factory()->createOneQuietly(); + $this->assertModelExists($model); + } + + /** @return void */ + public function testCanUpdateNews(): void + { + $model = News::factory()->createOneQuietly(); + + $fieldTest = ""; + foreach (config('unit-tests.list-fields') as $field) { + if (Schema::hasColumn($model->getTable(), $field)) { + $model->update([$field => "test"]); + $fieldTest = $field; + break; + } + } + + $this->assertTrue($model->wasChanged()); + $this->assertTrue(array_key_exists($fieldTest, $model->getChanges())); + $this->assertModelExists($model); + } + + /** @return void */ + public function testCanDeleteNews(): void + { + $model = News::factory()->createOneQuietly(); + $model->delete(); + $this->assertModelMissing($model); + } +} diff --git a/tests/Back/OfferTest.php b/tests/Back/OfferTest.php new file mode 100644 index 00000000..2db4b3b7 --- /dev/null +++ b/tests/Back/OfferTest.php @@ -0,0 +1,218 @@ +get(route( + config('unit-tests.route.prefix') . + 'offers.' . + config('unit-tests.view.resources-index') + )); + $response->assertRedirect(route(config('unit-tests.route.prefix') . 'login')); + } + + /** @return void */ + public function testGuestCannotAccessOffersReadView(): void + { + $model = Offer::factory()->createOneQuietly(); + $response = $this->get(route( + config('unit-tests.route.prefix') . + 'offers.' . + config('unit-tests.view.resources-read'), + $model->getKey() + )); + $response->assertRedirect(route(config('unit-tests.route.prefix') . 'login')); + } + + /** @return void */ + public function testGuestCannotAccessOffersCreateView(): void + { + $response = $this->get(route( + config('unit-tests.route.prefix') . + 'offers.' . + config('unit-tests.view.resources-create') + )); + $response->assertRedirect(route(config('unit-tests.route.prefix') . 'login')); + } + + /** @return void */ + public function testGuestCannotAccessOffersUpdateView(): void + { + $model = Offer::factory()->createOneQuietly(); + $response = $this->get(route( + config('unit-tests.route.prefix') . + 'offers.' . + config('unit-tests.view.resources-update'), + $model->getKey() + )); + $response->assertRedirect(route(config('unit-tests.route.prefix') . 'login')); + } + + /** + * TESTS GUEST CANNOT POST MODEL. + */ + + /** @return void */ + public function testGuestCannotCreateOffer(): void + { + $model = Offer::factory()->createOneQuietly(); + $response = $this->post( + route( + config('unit-tests.route.prefix') . 'offers.' . config('unit-tests.route.action-create'), + $model->getKey() + ), + $model->toArray() + ); + $response->assertRedirect(route(config('unit-tests.route.prefix') . 'login')); + } + + /** @return void */ + public function testGuestCannotUpdateOffer(): void + { + $model = Offer::factory()->createOneQuietly(); + $response = $this->patch( + route( + config('unit-tests.route.prefix') . 'offers.' . config('unit-tests.route.action-update'), + $model->getKey() + ), + $model->toArray() + ); + $response->assertRedirect(route(config('unit-tests.route.prefix') . 'login')); + } + + /** @return void */ + public function testGuestCannotDeleteOffer(): void + { + $model = Offer::factory()->createOneQuietly(); + $response = $this->delete( + route( + config('unit-tests.route.prefix') . 'offers.' . config('unit-tests.route.action-delete'), + $model->getKey() + ), + $model->toArray() + ); + $response->assertRedirect(route(config('unit-tests.route.prefix') . 'login')); + } + + /** + * TESTS USER CONCEPTOR ACCESS VIEWS. + */ + + /** @return void */ + public function testUserConceptorCanAccessOffersIndexView(): void + { + $authModel = AuthModel::factory()->createOneQuietly(); + $authModel->update(['role' => RoleEnum::conceptor]); + $response = $this->actingAs($authModel, 'backend')->get( + route(config('unit-tests.route.prefix') . 'offers.' . config('unit-tests.view.resources-index')) + ); + $response->assertSuccessful(); + $response->assertViewIs( + config('unit-tests.view.prefix') . + 'pages.offers.' . + config('unit-tests.view.resources-index') + ); + } + + /** @return void */ + public function testUserConceptorCanAccessOffersReadView(): void + { + $authModel = AuthModel::factory()->createOneQuietly(); + $authModel->update(['role' => RoleEnum::conceptor]); + $model = Offer::factory()->createOneQuietly(); + $response = $this->actingAs($authModel, 'backend')->get( + route(config('unit-tests.route.prefix') . 'offers.' . config('unit-tests.view.resources-read'), $model) + ); + $response->assertSuccessful(); + $response->assertViewIs( + config('unit-tests.view.prefix') . + 'pages.offers.' . + config('unit-tests.view.resources-read') + ); + } + + /** @return void */ + public function testUserConceptorCanAccessOffersCreateView(): void + { + $authModel = AuthModel::factory()->createOneQuietly(); + $authModel->update(['role' => RoleEnum::conceptor]); + $response = $this->actingAs($authModel, 'backend')->get( + route(config('unit-tests.route.prefix') . 'offers.' . config('unit-tests.view.resources-create')) + ); + $response->assertSuccessful(); + $response->assertViewIs( + config('unit-tests.view.prefix') . + 'pages.offers.' . + config('unit-tests.view.resources-create') + ); + } + + /** @return void */ + public function testUserConceptorCanAccessOffersUpdateView(): void + { + $authModel = AuthModel::factory()->createOneQuietly(); + $authModel->update(['role' => RoleEnum::conceptor]); + $model = Offer::factory()->createOneQuietly(); + $response = $this->actingAs($authModel, 'backend')->get( + route(config('unit-tests.route.prefix') . 'offers.' . config('unit-tests.view.resources-update'), $model) + ); + $response->assertSuccessful(); + $response->assertViewIs( + config('unit-tests.view.prefix') . + 'pages.offers.' . + config('unit-tests.view.resources-update') + ); + } + + /** + * TESTS CAN ACTIONS ON MODEL. + */ + + /** @return void */ + public function testCanCreateOffer(): void + { + $model = Offer::factory()->createOneQuietly(); + $this->assertModelExists($model); + } + + /** @return void */ + public function testCanUpdateOffer(): void + { + $model = Offer::factory()->createOneQuietly(); + + $fieldTest = ""; + foreach (config('unit-tests.list-fields') as $field) { + if (Schema::hasColumn($model->getTable(), $field)) { + $model->update([$field => "test"]); + $fieldTest = $field; + break; + } + } + + $this->assertTrue($model->wasChanged()); + $this->assertTrue(array_key_exists($fieldTest, $model->getChanges())); + $this->assertModelExists($model); + } + + /** @return void */ + public function testCanDeleteOffer(): void + { + $model = Offer::factory()->createOneQuietly(); + $model->delete(); + $this->assertModelMissing($model); + } +} diff --git a/tests/Back/ProductTest.php b/tests/Back/ProductTest.php new file mode 100644 index 00000000..1db4e157 --- /dev/null +++ b/tests/Back/ProductTest.php @@ -0,0 +1,218 @@ +get(route( + config('unit-tests.route.prefix') . + 'products.' . + config('unit-tests.view.resources-index') + )); + $response->assertRedirect(route(config('unit-tests.route.prefix') . 'login')); + } + + /** @return void */ + public function testGuestCannotAccessProductsReadView(): void + { + $model = Product::factory()->createOneQuietly(); + $response = $this->get(route( + config('unit-tests.route.prefix') . + 'products.' . + config('unit-tests.view.resources-read'), + $model->getKey() + )); + $response->assertRedirect(route(config('unit-tests.route.prefix') . 'login')); + } + + /** @return void */ + public function testGuestCannotAccessProductsCreateView(): void + { + $response = $this->get(route( + config('unit-tests.route.prefix') . + 'products.' . + config('unit-tests.view.resources-create') + )); + $response->assertRedirect(route(config('unit-tests.route.prefix') . 'login')); + } + + /** @return void */ + public function testGuestCannotAccessProductsUpdateView(): void + { + $model = Product::factory()->createOneQuietly(); + $response = $this->get(route( + config('unit-tests.route.prefix') . + 'products.' . + config('unit-tests.view.resources-update'), + $model->getKey() + )); + $response->assertRedirect(route(config('unit-tests.route.prefix') . 'login')); + } + + /** + * TESTS GUEST CANNOT POST MODEL. + */ + + /** @return void */ + public function testGuestCannotCreateProduct(): void + { + $model = Product::factory()->createOneQuietly(); + $response = $this->post( + route( + config('unit-tests.route.prefix') . 'products.' . config('unit-tests.route.action-create'), + $model->getKey() + ), + $model->toArray() + ); + $response->assertRedirect(route(config('unit-tests.route.prefix') . 'login')); + } + + /** @return void */ + public function testGuestCannotUpdateProduct(): void + { + $model = Product::factory()->createOneQuietly(); + $response = $this->patch( + route( + config('unit-tests.route.prefix') . 'products.' . config('unit-tests.route.action-update'), + $model->getKey() + ), + $model->toArray() + ); + $response->assertRedirect(route(config('unit-tests.route.prefix') . 'login')); + } + + /** @return void */ + public function testGuestCannotDeleteProduct(): void + { + $model = Product::factory()->createOneQuietly(); + $response = $this->delete( + route( + config('unit-tests.route.prefix') . 'products.' . config('unit-tests.route.action-delete'), + $model->getKey() + ), + $model->toArray() + ); + $response->assertRedirect(route(config('unit-tests.route.prefix') . 'login')); + } + + /** + * TESTS USER CONCEPTOR ACCESS VIEWS. + */ + + /** @return void */ + public function testUserConceptorCanAccessProductsIndexView(): void + { + $authModel = AuthModel::factory()->createOneQuietly(); + $authModel->update(['role' => RoleEnum::conceptor]); + $response = $this->actingAs($authModel, 'backend')->get( + route(config('unit-tests.route.prefix') . 'products.' . config('unit-tests.view.resources-index')) + ); + $response->assertSuccessful(); + $response->assertViewIs( + config('unit-tests.view.prefix') . + 'pages.products.' . + config('unit-tests.view.resources-index') + ); + } + + /** @return void */ + public function testUserConceptorCanAccessProductsReadView(): void + { + $authModel = AuthModel::factory()->createOneQuietly(); + $authModel->update(['role' => RoleEnum::conceptor]); + $model = Product::factory()->createOneQuietly(); + $response = $this->actingAs($authModel, 'backend')->get( + route(config('unit-tests.route.prefix') . 'products.' . config('unit-tests.view.resources-read'), $model) + ); + $response->assertSuccessful(); + $response->assertViewIs( + config('unit-tests.view.prefix') . + 'pages.products.' . + config('unit-tests.view.resources-read') + ); + } + + /** @return void */ + public function testUserConceptorCanAccessProductsCreateView(): void + { + $authModel = AuthModel::factory()->createOneQuietly(); + $authModel->update(['role' => RoleEnum::conceptor]); + $response = $this->actingAs($authModel, 'backend')->get( + route(config('unit-tests.route.prefix') . 'products.' . config('unit-tests.view.resources-create')) + ); + $response->assertSuccessful(); + $response->assertViewIs( + config('unit-tests.view.prefix') . + 'pages.products.' . + config('unit-tests.view.resources-create') + ); + } + + /** @return void */ + public function testUserConceptorCanAccessProductsUpdateView(): void + { + $authModel = AuthModel::factory()->createOneQuietly(); + $authModel->update(['role' => RoleEnum::conceptor]); + $model = Product::factory()->createOneQuietly(); + $response = $this->actingAs($authModel, 'backend')->get( + route(config('unit-tests.route.prefix') . 'products.' . config('unit-tests.view.resources-update'), $model) + ); + $response->assertSuccessful(); + $response->assertViewIs( + config('unit-tests.view.prefix') . + 'pages.products.' . + config('unit-tests.view.resources-update') + ); + } + + /** + * TESTS CAN ACTIONS ON MODEL. + */ + + /** @return void */ + public function testCanCreateProduct(): void + { + $model = Product::factory()->createOneQuietly(); + $this->assertModelExists($model); + } + + /** @return void */ + public function testCanUpdateProduct(): void + { + $model = Product::factory()->createOneQuietly(); + + $fieldTest = ""; + foreach (config('unit-tests.list-fields') as $field) { + if (Schema::hasColumn($model->getTable(), $field)) { + $model->update([$field => "test"]); + $fieldTest = $field; + break; + } + } + + $this->assertTrue($model->wasChanged()); + $this->assertTrue(array_key_exists($fieldTest, $model->getChanges())); + $this->assertModelExists($model); + } + + /** @return void */ + public function testCanDeleteProduct(): void + { + $model = Product::factory()->createOneQuietly(); + $model->delete(); + $this->assertModelMissing($model); + } +} diff --git a/tests/Back/ProductTypeTest.php b/tests/Back/ProductTypeTest.php new file mode 100644 index 00000000..94e421b5 --- /dev/null +++ b/tests/Back/ProductTypeTest.php @@ -0,0 +1,218 @@ +get(route( + config('unit-tests.route.prefix') . + 'product_types.' . + config('unit-tests.view.resources-index') + )); + $response->assertRedirect(route(config('unit-tests.route.prefix') . 'login')); + } + + /** @return void */ + public function testGuestCannotAccessProductTypesReadView(): void + { + $model = ProductType::factory()->createOneQuietly(); + $response = $this->get(route( + config('unit-tests.route.prefix') . + 'product_types.' . + config('unit-tests.view.resources-read'), + $model->getKey() + )); + $response->assertRedirect(route(config('unit-tests.route.prefix') . 'login')); + } + + /** @return void */ + public function testGuestCannotAccessProductTypesCreateView(): void + { + $response = $this->get(route( + config('unit-tests.route.prefix') . + 'product_types.' . + config('unit-tests.view.resources-create') + )); + $response->assertRedirect(route(config('unit-tests.route.prefix') . 'login')); + } + + /** @return void */ + public function testGuestCannotAccessProductTypesUpdateView(): void + { + $model = ProductType::factory()->createOneQuietly(); + $response = $this->get(route( + config('unit-tests.route.prefix') . + 'product_types.' . + config('unit-tests.view.resources-update'), + $model->getKey() + )); + $response->assertRedirect(route(config('unit-tests.route.prefix') . 'login')); + } + + /** + * TESTS GUEST CANNOT POST MODEL. + */ + + /** @return void */ + public function testGuestCannotCreateProductType(): void + { + $model = ProductType::factory()->createOneQuietly(); + $response = $this->post( + route( + config('unit-tests.route.prefix') . 'product_types.' . config('unit-tests.route.action-create'), + $model->getKey() + ), + $model->toArray() + ); + $response->assertRedirect(route(config('unit-tests.route.prefix') . 'login')); + } + + /** @return void */ + public function testGuestCannotUpdateProductType(): void + { + $model = ProductType::factory()->createOneQuietly(); + $response = $this->patch( + route( + config('unit-tests.route.prefix') . 'product_types.' . config('unit-tests.route.action-update'), + $model->getKey() + ), + $model->toArray() + ); + $response->assertRedirect(route(config('unit-tests.route.prefix') . 'login')); + } + + /** @return void */ + public function testGuestCannotDeleteProductType(): void + { + $model = ProductType::factory()->createOneQuietly(); + $response = $this->delete( + route( + config('unit-tests.route.prefix') . 'product_types.' . config('unit-tests.route.action-delete'), + $model->getKey() + ), + $model->toArray() + ); + $response->assertRedirect(route(config('unit-tests.route.prefix') . 'login')); + } + + /** + * TESTS USER CONCEPTOR ACCESS VIEWS. + */ + + /** @return void */ + public function testUserConceptorCanAccessProductTypesIndexView(): void + { + $authModel = AuthModel::factory()->createOneQuietly(); + $authModel->update(['role' => RoleEnum::conceptor]); + $response = $this->actingAs($authModel, 'backend')->get( + route(config('unit-tests.route.prefix') . 'product_types.' . config('unit-tests.view.resources-index')) + ); + $response->assertSuccessful(); + $response->assertViewIs( + config('unit-tests.view.prefix') . + 'pages.product_types.' . + config('unit-tests.view.resources-index') + ); + } + + /** @return void */ + public function testUserConceptorCanAccessProductTypesReadView(): void + { + $authModel = AuthModel::factory()->createOneQuietly(); + $authModel->update(['role' => RoleEnum::conceptor]); + $model = ProductType::factory()->createOneQuietly(); + $response = $this->actingAs($authModel, 'backend')->get( + route(config('unit-tests.route.prefix') . 'product_types.' . config('unit-tests.view.resources-read'), $model) + ); + $response->assertSuccessful(); + $response->assertViewIs( + config('unit-tests.view.prefix') . + 'pages.product_types.' . + config('unit-tests.view.resources-read') + ); + } + + /** @return void */ + public function testUserConceptorCanAccessProductTypesCreateView(): void + { + $authModel = AuthModel::factory()->createOneQuietly(); + $authModel->update(['role' => RoleEnum::conceptor]); + $response = $this->actingAs($authModel, 'backend')->get( + route(config('unit-tests.route.prefix') . 'product_types.' . config('unit-tests.view.resources-create')) + ); + $response->assertSuccessful(); + $response->assertViewIs( + config('unit-tests.view.prefix') . + 'pages.product_types.' . + config('unit-tests.view.resources-create') + ); + } + + /** @return void */ + public function testUserConceptorCanAccessProductTypesUpdateView(): void + { + $authModel = AuthModel::factory()->createOneQuietly(); + $authModel->update(['role' => RoleEnum::conceptor]); + $model = ProductType::factory()->createOneQuietly(); + $response = $this->actingAs($authModel, 'backend')->get( + route(config('unit-tests.route.prefix') . 'product_types.' . config('unit-tests.view.resources-update'), $model) + ); + $response->assertSuccessful(); + $response->assertViewIs( + config('unit-tests.view.prefix') . + 'pages.product_types.' . + config('unit-tests.view.resources-update') + ); + } + + /** + * TESTS CAN ACTIONS ON MODEL. + */ + + /** @return void */ + public function testCanCreateProductType(): void + { + $model = ProductType::factory()->createOneQuietly(); + $this->assertModelExists($model); + } + + /** @return void */ + public function testCanUpdateProductType(): void + { + $model = ProductType::factory()->createOneQuietly(); + + $fieldTest = ""; + foreach (config('unit-tests.list-fields') as $field) { + if (Schema::hasColumn($model->getTable(), $field)) { + $model->update([$field => "test"]); + $fieldTest = $field; + break; + } + } + + $this->assertTrue($model->wasChanged()); + $this->assertTrue(array_key_exists($fieldTest, $model->getChanges())); + $this->assertModelExists($model); + } + + /** @return void */ + public function testCanDeleteProductType(): void + { + $model = ProductType::factory()->createOneQuietly(); + $model->delete(); + $this->assertModelMissing($model); + } +} diff --git a/tests/Back/ProfessionTest.php b/tests/Back/ProfessionTest.php new file mode 100644 index 00000000..c196824f --- /dev/null +++ b/tests/Back/ProfessionTest.php @@ -0,0 +1,218 @@ +get(route( + config('unit-tests.route.prefix') . + 'professions.' . + config('unit-tests.view.resources-index') + )); + $response->assertRedirect(route(config('unit-tests.route.prefix') . 'login')); + } + + /** @return void */ + public function testGuestCannotAccessProfessionsReadView(): void + { + $model = Profession::factory()->createOneQuietly(); + $response = $this->get(route( + config('unit-tests.route.prefix') . + 'professions.' . + config('unit-tests.view.resources-read'), + $model->getKey() + )); + $response->assertRedirect(route(config('unit-tests.route.prefix') . 'login')); + } + + /** @return void */ + public function testGuestCannotAccessProfessionsCreateView(): void + { + $response = $this->get(route( + config('unit-tests.route.prefix') . + 'professions.' . + config('unit-tests.view.resources-create') + )); + $response->assertRedirect(route(config('unit-tests.route.prefix') . 'login')); + } + + /** @return void */ + public function testGuestCannotAccessProfessionsUpdateView(): void + { + $model = Profession::factory()->createOneQuietly(); + $response = $this->get(route( + config('unit-tests.route.prefix') . + 'professions.' . + config('unit-tests.view.resources-update'), + $model->getKey() + )); + $response->assertRedirect(route(config('unit-tests.route.prefix') . 'login')); + } + + /** + * TESTS GUEST CANNOT POST MODEL. + */ + + /** @return void */ + public function testGuestCannotCreateProfession(): void + { + $model = Profession::factory()->createOneQuietly(); + $response = $this->post( + route( + config('unit-tests.route.prefix') . 'professions.' . config('unit-tests.route.action-create'), + $model->getKey() + ), + $model->toArray() + ); + $response->assertRedirect(route(config('unit-tests.route.prefix') . 'login')); + } + + /** @return void */ + public function testGuestCannotUpdateProfession(): void + { + $model = Profession::factory()->createOneQuietly(); + $response = $this->patch( + route( + config('unit-tests.route.prefix') . 'professions.' . config('unit-tests.route.action-update'), + $model->getKey() + ), + $model->toArray() + ); + $response->assertRedirect(route(config('unit-tests.route.prefix') . 'login')); + } + + /** @return void */ + public function testGuestCannotDeleteProfession(): void + { + $model = Profession::factory()->createOneQuietly(); + $response = $this->delete( + route( + config('unit-tests.route.prefix') . 'professions.' . config('unit-tests.route.action-delete'), + $model->getKey() + ), + $model->toArray() + ); + $response->assertRedirect(route(config('unit-tests.route.prefix') . 'login')); + } + + /** + * TESTS USER CONCEPTOR ACCESS VIEWS. + */ + + /** @return void */ + public function testUserConceptorCanAccessProfessionsIndexView(): void + { + $authModel = AuthModel::factory()->createOneQuietly(); + $authModel->update(['role' => RoleEnum::conceptor]); + $response = $this->actingAs($authModel, 'backend')->get( + route(config('unit-tests.route.prefix') . 'professions.' . config('unit-tests.view.resources-index')) + ); + $response->assertSuccessful(); + $response->assertViewIs( + config('unit-tests.view.prefix') . + 'pages.professions.' . + config('unit-tests.view.resources-index') + ); + } + + /** @return void */ + public function testUserConceptorCanAccessProfessionsReadView(): void + { + $authModel = AuthModel::factory()->createOneQuietly(); + $authModel->update(['role' => RoleEnum::conceptor]); + $model = Profession::factory()->createOneQuietly(); + $response = $this->actingAs($authModel, 'backend')->get( + route(config('unit-tests.route.prefix') . 'professions.' . config('unit-tests.view.resources-read'), $model) + ); + $response->assertSuccessful(); + $response->assertViewIs( + config('unit-tests.view.prefix') . + 'pages.professions.' . + config('unit-tests.view.resources-read') + ); + } + + /** @return void */ + public function testUserConceptorCanAccessProfessionsCreateView(): void + { + $authModel = AuthModel::factory()->createOneQuietly(); + $authModel->update(['role' => RoleEnum::conceptor]); + $response = $this->actingAs($authModel, 'backend')->get( + route(config('unit-tests.route.prefix') . 'professions.' . config('unit-tests.view.resources-create')) + ); + $response->assertSuccessful(); + $response->assertViewIs( + config('unit-tests.view.prefix') . + 'pages.professions.' . + config('unit-tests.view.resources-create') + ); + } + + /** @return void */ + public function testUserConceptorCanAccessProfessionsUpdateView(): void + { + $authModel = AuthModel::factory()->createOneQuietly(); + $authModel->update(['role' => RoleEnum::conceptor]); + $model = Profession::factory()->createOneQuietly(); + $response = $this->actingAs($authModel, 'backend')->get( + route(config('unit-tests.route.prefix') . 'professions.' . config('unit-tests.view.resources-update'), $model) + ); + $response->assertSuccessful(); + $response->assertViewIs( + config('unit-tests.view.prefix') . + 'pages.professions.' . + config('unit-tests.view.resources-update') + ); + } + + /** + * TESTS CAN ACTIONS ON MODEL. + */ + + /** @return void */ + public function testCanCreateProfession(): void + { + $model = Profession::factory()->createOneQuietly(); + $this->assertModelExists($model); + } + + /** @return void */ + public function testCanUpdateProfession(): void + { + $model = Profession::factory()->createOneQuietly(); + + $fieldTest = ""; + foreach (config('unit-tests.list-fields') as $field) { + if (Schema::hasColumn($model->getTable(), $field)) { + $model->update([$field => "test"]); + $fieldTest = $field; + break; + } + } + + $this->assertTrue($model->wasChanged()); + $this->assertTrue(array_key_exists($fieldTest, $model->getChanges())); + $this->assertModelExists($model); + } + + /** @return void */ + public function testCanDeleteProfession(): void + { + $model = Profession::factory()->createOneQuietly(); + $model->delete(); + $this->assertModelMissing($model); + } +} diff --git a/tests/Back/RangeTest.php b/tests/Back/RangeTest.php new file mode 100644 index 00000000..d15c8308 --- /dev/null +++ b/tests/Back/RangeTest.php @@ -0,0 +1,218 @@ +get(route( + config('unit-tests.route.prefix') . + 'ranges.' . + config('unit-tests.view.resources-index') + )); + $response->assertRedirect(route(config('unit-tests.route.prefix') . 'login')); + } + + /** @return void */ + public function testGuestCannotAccessRangesReadView(): void + { + $model = Range::factory()->createOneQuietly(); + $response = $this->get(route( + config('unit-tests.route.prefix') . + 'ranges.' . + config('unit-tests.view.resources-read'), + $model->getKey() + )); + $response->assertRedirect(route(config('unit-tests.route.prefix') . 'login')); + } + + /** @return void */ + public function testGuestCannotAccessRangesCreateView(): void + { + $response = $this->get(route( + config('unit-tests.route.prefix') . + 'ranges.' . + config('unit-tests.view.resources-create') + )); + $response->assertRedirect(route(config('unit-tests.route.prefix') . 'login')); + } + + /** @return void */ + public function testGuestCannotAccessRangesUpdateView(): void + { + $model = Range::factory()->createOneQuietly(); + $response = $this->get(route( + config('unit-tests.route.prefix') . + 'ranges.' . + config('unit-tests.view.resources-update'), + $model->getKey() + )); + $response->assertRedirect(route(config('unit-tests.route.prefix') . 'login')); + } + + /** + * TESTS GUEST CANNOT POST MODEL. + */ + + /** @return void */ + public function testGuestCannotCreateRange(): void + { + $model = Range::factory()->createOneQuietly(); + $response = $this->post( + route( + config('unit-tests.route.prefix') . 'ranges.' . config('unit-tests.route.action-create'), + $model->getKey() + ), + $model->toArray() + ); + $response->assertRedirect(route(config('unit-tests.route.prefix') . 'login')); + } + + /** @return void */ + public function testGuestCannotUpdateRange(): void + { + $model = Range::factory()->createOneQuietly(); + $response = $this->patch( + route( + config('unit-tests.route.prefix') . 'ranges.' . config('unit-tests.route.action-update'), + $model->getKey() + ), + $model->toArray() + ); + $response->assertRedirect(route(config('unit-tests.route.prefix') . 'login')); + } + + /** @return void */ + public function testGuestCannotDeleteRange(): void + { + $model = Range::factory()->createOneQuietly(); + $response = $this->delete( + route( + config('unit-tests.route.prefix') . 'ranges.' . config('unit-tests.route.action-delete'), + $model->getKey() + ), + $model->toArray() + ); + $response->assertRedirect(route(config('unit-tests.route.prefix') . 'login')); + } + + /** + * TESTS USER CONCEPTOR ACCESS VIEWS. + */ + + /** @return void */ + public function testUserConceptorCanAccessRangesIndexView(): void + { + $authModel = AuthModel::factory()->createOneQuietly(); + $authModel->update(['role' => RoleEnum::conceptor]); + $response = $this->actingAs($authModel, 'backend')->get( + route(config('unit-tests.route.prefix') . 'ranges.' . config('unit-tests.view.resources-index')) + ); + $response->assertSuccessful(); + $response->assertViewIs( + config('unit-tests.view.prefix') . + 'pages.ranges.' . + config('unit-tests.view.resources-index') + ); + } + + /** @return void */ + public function testUserConceptorCanAccessRangesReadView(): void + { + $authModel = AuthModel::factory()->createOneQuietly(); + $authModel->update(['role' => RoleEnum::conceptor]); + $model = Range::factory()->createOneQuietly(); + $response = $this->actingAs($authModel, 'backend')->get( + route(config('unit-tests.route.prefix') . 'ranges.' . config('unit-tests.view.resources-read'), $model) + ); + $response->assertSuccessful(); + $response->assertViewIs( + config('unit-tests.view.prefix') . + 'pages.ranges.' . + config('unit-tests.view.resources-read') + ); + } + + /** @return void */ + public function testUserConceptorCanAccessRangesCreateView(): void + { + $authModel = AuthModel::factory()->createOneQuietly(); + $authModel->update(['role' => RoleEnum::conceptor]); + $response = $this->actingAs($authModel, 'backend')->get( + route(config('unit-tests.route.prefix') . 'ranges.' . config('unit-tests.view.resources-create')) + ); + $response->assertSuccessful(); + $response->assertViewIs( + config('unit-tests.view.prefix') . + 'pages.ranges.' . + config('unit-tests.view.resources-create') + ); + } + + /** @return void */ + public function testUserConceptorCanAccessRangesUpdateView(): void + { + $authModel = AuthModel::factory()->createOneQuietly(); + $authModel->update(['role' => RoleEnum::conceptor]); + $model = Range::factory()->createOneQuietly(); + $response = $this->actingAs($authModel, 'backend')->get( + route(config('unit-tests.route.prefix') . 'ranges.' . config('unit-tests.view.resources-update'), $model) + ); + $response->assertSuccessful(); + $response->assertViewIs( + config('unit-tests.view.prefix') . + 'pages.ranges.' . + config('unit-tests.view.resources-update') + ); + } + + /** + * TESTS CAN ACTIONS ON MODEL. + */ + + /** @return void */ + public function testCanCreateRange(): void + { + $model = Range::factory()->createOneQuietly(); + $this->assertModelExists($model); + } + + /** @return void */ + public function testCanUpdateRange(): void + { + $model = Range::factory()->createOneQuietly(); + + $fieldTest = ""; + foreach (config('unit-tests.list-fields') as $field) { + if (Schema::hasColumn($model->getTable(), $field)) { + $model->update([$field => "test"]); + $fieldTest = $field; + break; + } + } + + $this->assertTrue($model->wasChanged()); + $this->assertTrue(array_key_exists($fieldTest, $model->getChanges())); + $this->assertModelExists($model); + } + + /** @return void */ + public function testCanDeleteRange(): void + { + $model = Range::factory()->createOneQuietly(); + $model->delete(); + $this->assertModelMissing($model); + } +} diff --git a/tests/Back/RecipeTest.php b/tests/Back/RecipeTest.php new file mode 100644 index 00000000..92671d42 --- /dev/null +++ b/tests/Back/RecipeTest.php @@ -0,0 +1,218 @@ +get(route( + config('unit-tests.route.prefix') . + 'recipes.' . + config('unit-tests.view.resources-index') + )); + $response->assertRedirect(route(config('unit-tests.route.prefix') . 'login')); + } + + /** @return void */ + public function testGuestCannotAccessRecipesReadView(): void + { + $model = Recipe::factory()->createOneQuietly(); + $response = $this->get(route( + config('unit-tests.route.prefix') . + 'recipes.' . + config('unit-tests.view.resources-read'), + $model->getKey() + )); + $response->assertRedirect(route(config('unit-tests.route.prefix') . 'login')); + } + + /** @return void */ + public function testGuestCannotAccessRecipesCreateView(): void + { + $response = $this->get(route( + config('unit-tests.route.prefix') . + 'recipes.' . + config('unit-tests.view.resources-create') + )); + $response->assertRedirect(route(config('unit-tests.route.prefix') . 'login')); + } + + /** @return void */ + public function testGuestCannotAccessRecipesUpdateView(): void + { + $model = Recipe::factory()->createOneQuietly(); + $response = $this->get(route( + config('unit-tests.route.prefix') . + 'recipes.' . + config('unit-tests.view.resources-update'), + $model->getKey() + )); + $response->assertRedirect(route(config('unit-tests.route.prefix') . 'login')); + } + + /** + * TESTS GUEST CANNOT POST MODEL. + */ + + /** @return void */ + public function testGuestCannotCreateRecipe(): void + { + $model = Recipe::factory()->createOneQuietly(); + $response = $this->post( + route( + config('unit-tests.route.prefix') . 'recipes.' . config('unit-tests.route.action-create'), + $model->getKey() + ), + $model->toArray() + ); + $response->assertRedirect(route(config('unit-tests.route.prefix') . 'login')); + } + + /** @return void */ + public function testGuestCannotUpdateRecipe(): void + { + $model = Recipe::factory()->createOneQuietly(); + $response = $this->patch( + route( + config('unit-tests.route.prefix') . 'recipes.' . config('unit-tests.route.action-update'), + $model->getKey() + ), + $model->toArray() + ); + $response->assertRedirect(route(config('unit-tests.route.prefix') . 'login')); + } + + /** @return void */ + public function testGuestCannotDeleteRecipe(): void + { + $model = Recipe::factory()->createOneQuietly(); + $response = $this->delete( + route( + config('unit-tests.route.prefix') . 'recipes.' . config('unit-tests.route.action-delete'), + $model->getKey() + ), + $model->toArray() + ); + $response->assertRedirect(route(config('unit-tests.route.prefix') . 'login')); + } + + /** + * TESTS USER CONCEPTOR ACCESS VIEWS. + */ + + /** @return void */ + public function testUserConceptorCanAccessRecipesIndexView(): void + { + $authModel = AuthModel::factory()->createOneQuietly(); + $authModel->update(['role' => RoleEnum::conceptor]); + $response = $this->actingAs($authModel, 'backend')->get( + route(config('unit-tests.route.prefix') . 'recipes.' . config('unit-tests.view.resources-index')) + ); + $response->assertSuccessful(); + $response->assertViewIs( + config('unit-tests.view.prefix') . + 'pages.recipes.' . + config('unit-tests.view.resources-index') + ); + } + + /** @return void */ + public function testUserConceptorCanAccessRecipesReadView(): void + { + $authModel = AuthModel::factory()->createOneQuietly(); + $authModel->update(['role' => RoleEnum::conceptor]); + $model = Recipe::factory()->createOneQuietly(); + $response = $this->actingAs($authModel, 'backend')->get( + route(config('unit-tests.route.prefix') . 'recipes.' . config('unit-tests.view.resources-read'), $model) + ); + $response->assertSuccessful(); + $response->assertViewIs( + config('unit-tests.view.prefix') . + 'pages.recipes.' . + config('unit-tests.view.resources-read') + ); + } + + /** @return void */ + public function testUserConceptorCanAccessRecipesCreateView(): void + { + $authModel = AuthModel::factory()->createOneQuietly(); + $authModel->update(['role' => RoleEnum::conceptor]); + $response = $this->actingAs($authModel, 'backend')->get( + route(config('unit-tests.route.prefix') . 'recipes.' . config('unit-tests.view.resources-create')) + ); + $response->assertSuccessful(); + $response->assertViewIs( + config('unit-tests.view.prefix') . + 'pages.recipes.' . + config('unit-tests.view.resources-create') + ); + } + + /** @return void */ + public function testUserConceptorCanAccessRecipesUpdateView(): void + { + $authModel = AuthModel::factory()->createOneQuietly(); + $authModel->update(['role' => RoleEnum::conceptor]); + $model = Recipe::factory()->createOneQuietly(); + $response = $this->actingAs($authModel, 'backend')->get( + route(config('unit-tests.route.prefix') . 'recipes.' . config('unit-tests.view.resources-update'), $model) + ); + $response->assertSuccessful(); + $response->assertViewIs( + config('unit-tests.view.prefix') . + 'pages.recipes.' . + config('unit-tests.view.resources-update') + ); + } + + /** + * TESTS CAN ACTIONS ON MODEL. + */ + + /** @return void */ + public function testCanCreateRecipe(): void + { + $model = Recipe::factory()->createOneQuietly(); + $this->assertModelExists($model); + } + + /** @return void */ + public function testCanUpdateRecipe(): void + { + $model = Recipe::factory()->createOneQuietly(); + + $fieldTest = ""; + foreach (config('unit-tests.list-fields') as $field) { + if (Schema::hasColumn($model->getTable(), $field)) { + $model->update([$field => "test"]); + $fieldTest = $field; + break; + } + } + + $this->assertTrue($model->wasChanged()); + $this->assertTrue(array_key_exists($fieldTest, $model->getChanges())); + $this->assertModelExists($model); + } + + /** @return void */ + public function testCanDeleteRecipe(): void + { + $model = Recipe::factory()->createOneQuietly(); + $model->delete(); + $this->assertModelMissing($model); + } +} diff --git a/tests/Back/SellItemTest.php b/tests/Back/SellItemTest.php new file mode 100644 index 00000000..f1da740b --- /dev/null +++ b/tests/Back/SellItemTest.php @@ -0,0 +1,218 @@ +get(route( + config('unit-tests.route.prefix') . + 'sell_items.' . + config('unit-tests.view.resources-index') + )); + $response->assertRedirect(route(config('unit-tests.route.prefix') . 'login')); + } + + /** @return void */ + public function testGuestCannotAccessSellItemsReadView(): void + { + $model = SellItem::factory()->createOneQuietly(); + $response = $this->get(route( + config('unit-tests.route.prefix') . + 'sell_items.' . + config('unit-tests.view.resources-read'), + $model->getKey() + )); + $response->assertRedirect(route(config('unit-tests.route.prefix') . 'login')); + } + + /** @return void */ + public function testGuestCannotAccessSellItemsCreateView(): void + { + $response = $this->get(route( + config('unit-tests.route.prefix') . + 'sell_items.' . + config('unit-tests.view.resources-create') + )); + $response->assertRedirect(route(config('unit-tests.route.prefix') . 'login')); + } + + /** @return void */ + public function testGuestCannotAccessSellItemsUpdateView(): void + { + $model = SellItem::factory()->createOneQuietly(); + $response = $this->get(route( + config('unit-tests.route.prefix') . + 'sell_items.' . + config('unit-tests.view.resources-update'), + $model->getKey() + )); + $response->assertRedirect(route(config('unit-tests.route.prefix') . 'login')); + } + + /** + * TESTS GUEST CANNOT POST MODEL. + */ + + /** @return void */ + public function testGuestCannotCreateSellItem(): void + { + $model = SellItem::factory()->createOneQuietly(); + $response = $this->post( + route( + config('unit-tests.route.prefix') . 'sell_items.' . config('unit-tests.route.action-create'), + $model->getKey() + ), + $model->toArray() + ); + $response->assertRedirect(route(config('unit-tests.route.prefix') . 'login')); + } + + /** @return void */ + public function testGuestCannotUpdateSellItem(): void + { + $model = SellItem::factory()->createOneQuietly(); + $response = $this->patch( + route( + config('unit-tests.route.prefix') . 'sell_items.' . config('unit-tests.route.action-update'), + $model->getKey() + ), + $model->toArray() + ); + $response->assertRedirect(route(config('unit-tests.route.prefix') . 'login')); + } + + /** @return void */ + public function testGuestCannotDeleteSellItem(): void + { + $model = SellItem::factory()->createOneQuietly(); + $response = $this->delete( + route( + config('unit-tests.route.prefix') . 'sell_items.' . config('unit-tests.route.action-delete'), + $model->getKey() + ), + $model->toArray() + ); + $response->assertRedirect(route(config('unit-tests.route.prefix') . 'login')); + } + + /** + * TESTS USER CONCEPTOR ACCESS VIEWS. + */ + + /** @return void */ + public function testUserConceptorCanAccessSellItemsIndexView(): void + { + $authModel = AuthModel::factory()->createOneQuietly(); + $authModel->update(['role' => RoleEnum::conceptor]); + $response = $this->actingAs($authModel, 'backend')->get( + route(config('unit-tests.route.prefix') . 'sell_items.' . config('unit-tests.view.resources-index')) + ); + $response->assertSuccessful(); + $response->assertViewIs( + config('unit-tests.view.prefix') . + 'pages.sell_items.' . + config('unit-tests.view.resources-index') + ); + } + + /** @return void */ + public function testUserConceptorCanAccessSellItemsReadView(): void + { + $authModel = AuthModel::factory()->createOneQuietly(); + $authModel->update(['role' => RoleEnum::conceptor]); + $model = SellItem::factory()->createOneQuietly(); + $response = $this->actingAs($authModel, 'backend')->get( + route(config('unit-tests.route.prefix') . 'sell_items.' . config('unit-tests.view.resources-read'), $model) + ); + $response->assertSuccessful(); + $response->assertViewIs( + config('unit-tests.view.prefix') . + 'pages.sell_items.' . + config('unit-tests.view.resources-read') + ); + } + + /** @return void */ + public function testUserConceptorCanAccessSellItemsCreateView(): void + { + $authModel = AuthModel::factory()->createOneQuietly(); + $authModel->update(['role' => RoleEnum::conceptor]); + $response = $this->actingAs($authModel, 'backend')->get( + route(config('unit-tests.route.prefix') . 'sell_items.' . config('unit-tests.view.resources-create')) + ); + $response->assertSuccessful(); + $response->assertViewIs( + config('unit-tests.view.prefix') . + 'pages.sell_items.' . + config('unit-tests.view.resources-create') + ); + } + + /** @return void */ + public function testUserConceptorCanAccessSellItemsUpdateView(): void + { + $authModel = AuthModel::factory()->createOneQuietly(); + $authModel->update(['role' => RoleEnum::conceptor]); + $model = SellItem::factory()->createOneQuietly(); + $response = $this->actingAs($authModel, 'backend')->get( + route(config('unit-tests.route.prefix') . 'sell_items.' . config('unit-tests.view.resources-update'), $model) + ); + $response->assertSuccessful(); + $response->assertViewIs( + config('unit-tests.view.prefix') . + 'pages.sell_items.' . + config('unit-tests.view.resources-update') + ); + } + + /** + * TESTS CAN ACTIONS ON MODEL. + */ + + /** @return void */ + public function testCanCreateSellItem(): void + { + $model = SellItem::factory()->createOneQuietly(); + $this->assertModelExists($model); + } + + /** @return void */ + public function testCanUpdateSellItem(): void + { + $model = SellItem::factory()->createOneQuietly(); + + $fieldTest = ""; + foreach (config('unit-tests.list-fields') as $field) { + if (Schema::hasColumn($model->getTable(), $field)) { + $model->update([$field => "test"]); + $fieldTest = $field; + break; + } + } + + $this->assertTrue($model->wasChanged()); + $this->assertTrue(array_key_exists($fieldTest, $model->getChanges())); + $this->assertModelExists($model); + } + + /** @return void */ + public function testCanDeleteSellItem(): void + { + $model = SellItem::factory()->createOneQuietly(); + $model->delete(); + $this->assertModelMissing($model); + } +} diff --git a/tests/Back/StaticPageTest.php b/tests/Back/StaticPageTest.php new file mode 100644 index 00000000..22b895f3 --- /dev/null +++ b/tests/Back/StaticPageTest.php @@ -0,0 +1,91 @@ +createOneQuietly(); + $response = $this->get(route( + config('unit-tests.route.prefix') . + 'static_pages.' . + config('unit-tests.view.resources-update'), + $model->getKey() + )); + $response->assertRedirect(route(config('unit-tests.route.prefix') . 'login')); + } + + /** + * TESTS GUEST CANNOT POST MODEL. + */ + + /** @return void */ + public function testGuestCannotUpdateStaticPage(): void + { + $model = StaticPage::factory()->createOneQuietly(); + $response = $this->patch( + route( + config('unit-tests.route.prefix') . 'static_pages.' . config('unit-tests.route.action-update'), + $model->getKey() + ), + $model->toArray() + ); + $response->assertRedirect(route(config('unit-tests.route.prefix') . 'login')); + } + + /** + * TESTS USER CONCEPTOR ACCESS VIEWS. + */ + + /** @return void */ + public function testUserConceptorCanAccessStaticPagesUpdateView(): void + { + $authModel = AuthModel::factory()->createOneQuietly(); + $authModel->update(['role' => RoleEnum::conceptor]); + $model = StaticPage::factory()->createOneQuietly(); + $response = $this->actingAs($authModel, 'backend')->get( + route(config('unit-tests.route.prefix') . 'static_pages.' . config('unit-tests.view.resources-update'), $model) + ); + $response->assertSuccessful(); + $response->assertViewIs( + config('unit-tests.view.prefix') . + 'pages.static_pages.' . + config('unit-tests.view.resources-update') + ); + } + + /** + * TESTS CAN ACTIONS ON MODEL. + */ + + /** @return void */ + public function testCanUpdateStaticPage(): void + { + $model = StaticPage::factory()->createOneQuietly(); + + $fieldTest = ""; + foreach (config('unit-tests.list-fields') as $field) { + if (Schema::hasColumn($model->getTable(), $field)) { + $model->update([$field => "test"]); + $fieldTest = $field; + break; + } + } + + $this->assertTrue($model->wasChanged()); + $this->assertTrue(array_key_exists($fieldTest, $model->getChanges())); + $this->assertModelExists($model); + } +} diff --git a/tests/Back/SubmeatTest.php b/tests/Back/SubmeatTest.php new file mode 100644 index 00000000..7524ec6e --- /dev/null +++ b/tests/Back/SubmeatTest.php @@ -0,0 +1,218 @@ +get(route( + config('unit-tests.route.prefix') . + 'submeats.' . + config('unit-tests.view.resources-index') + )); + $response->assertRedirect(route(config('unit-tests.route.prefix') . 'login')); + } + + /** @return void */ + public function testGuestCannotAccessSubmeatsReadView(): void + { + $model = Submeat::factory()->createOneQuietly(); + $response = $this->get(route( + config('unit-tests.route.prefix') . + 'submeats.' . + config('unit-tests.view.resources-read'), + $model->getKey() + )); + $response->assertRedirect(route(config('unit-tests.route.prefix') . 'login')); + } + + /** @return void */ + public function testGuestCannotAccessSubmeatsCreateView(): void + { + $response = $this->get(route( + config('unit-tests.route.prefix') . + 'submeats.' . + config('unit-tests.view.resources-create') + )); + $response->assertRedirect(route(config('unit-tests.route.prefix') . 'login')); + } + + /** @return void */ + public function testGuestCannotAccessSubmeatsUpdateView(): void + { + $model = Submeat::factory()->createOneQuietly(); + $response = $this->get(route( + config('unit-tests.route.prefix') . + 'submeats.' . + config('unit-tests.view.resources-update'), + $model->getKey() + )); + $response->assertRedirect(route(config('unit-tests.route.prefix') . 'login')); + } + + /** + * TESTS GUEST CANNOT POST MODEL. + */ + + /** @return void */ + public function testGuestCannotCreateSubmeat(): void + { + $model = Submeat::factory()->createOneQuietly(); + $response = $this->post( + route( + config('unit-tests.route.prefix') . 'submeats.' . config('unit-tests.route.action-create'), + $model->getKey() + ), + $model->toArray() + ); + $response->assertRedirect(route(config('unit-tests.route.prefix') . 'login')); + } + + /** @return void */ + public function testGuestCannotUpdateSubmeat(): void + { + $model = Submeat::factory()->createOneQuietly(); + $response = $this->patch( + route( + config('unit-tests.route.prefix') . 'submeats.' . config('unit-tests.route.action-update'), + $model->getKey() + ), + $model->toArray() + ); + $response->assertRedirect(route(config('unit-tests.route.prefix') . 'login')); + } + + /** @return void */ + public function testGuestCannotDeleteSubmeat(): void + { + $model = Submeat::factory()->createOneQuietly(); + $response = $this->delete( + route( + config('unit-tests.route.prefix') . 'submeats.' . config('unit-tests.route.action-delete'), + $model->getKey() + ), + $model->toArray() + ); + $response->assertRedirect(route(config('unit-tests.route.prefix') . 'login')); + } + + /** + * TESTS USER CONCEPTOR ACCESS VIEWS. + */ + + /** @return void */ + public function testUserConceptorCanAccessSubmeatsIndexView(): void + { + $authModel = AuthModel::factory()->createOneQuietly(); + $authModel->update(['role' => RoleEnum::conceptor]); + $response = $this->actingAs($authModel, 'backend')->get( + route(config('unit-tests.route.prefix') . 'submeats.' . config('unit-tests.view.resources-index')) + ); + $response->assertSuccessful(); + $response->assertViewIs( + config('unit-tests.view.prefix') . + 'pages.submeats.' . + config('unit-tests.view.resources-index') + ); + } + + /** @return void */ + public function testUserConceptorCanAccessSubmeatsReadView(): void + { + $authModel = AuthModel::factory()->createOneQuietly(); + $authModel->update(['role' => RoleEnum::conceptor]); + $model = Submeat::factory()->createOneQuietly(); + $response = $this->actingAs($authModel, 'backend')->get( + route(config('unit-tests.route.prefix') . 'submeats.' . config('unit-tests.view.resources-read'), $model) + ); + $response->assertSuccessful(); + $response->assertViewIs( + config('unit-tests.view.prefix') . + 'pages.submeats.' . + config('unit-tests.view.resources-read') + ); + } + + /** @return void */ + public function testUserConceptorCanAccessSubmeatsCreateView(): void + { + $authModel = AuthModel::factory()->createOneQuietly(); + $authModel->update(['role' => RoleEnum::conceptor]); + $response = $this->actingAs($authModel, 'backend')->get( + route(config('unit-tests.route.prefix') . 'submeats.' . config('unit-tests.view.resources-create')) + ); + $response->assertSuccessful(); + $response->assertViewIs( + config('unit-tests.view.prefix') . + 'pages.submeats.' . + config('unit-tests.view.resources-create') + ); + } + + /** @return void */ + public function testUserConceptorCanAccessSubmeatsUpdateView(): void + { + $authModel = AuthModel::factory()->createOneQuietly(); + $authModel->update(['role' => RoleEnum::conceptor]); + $model = Submeat::factory()->createOneQuietly(); + $response = $this->actingAs($authModel, 'backend')->get( + route(config('unit-tests.route.prefix') . 'submeats.' . config('unit-tests.view.resources-update'), $model) + ); + $response->assertSuccessful(); + $response->assertViewIs( + config('unit-tests.view.prefix') . + 'pages.submeats.' . + config('unit-tests.view.resources-update') + ); + } + + /** + * TESTS CAN ACTIONS ON MODEL. + */ + + /** @return void */ + public function testCanCreateSubmeat(): void + { + $model = Submeat::factory()->createOneQuietly(); + $this->assertModelExists($model); + } + + /** @return void */ + public function testCanUpdateSubmeat(): void + { + $model = Submeat::factory()->createOneQuietly(); + + $fieldTest = ""; + foreach (config('unit-tests.list-fields') as $field) { + if (Schema::hasColumn($model->getTable(), $field)) { + $model->update([$field => "test"]); + $fieldTest = $field; + break; + } + } + + $this->assertTrue($model->wasChanged()); + $this->assertTrue(array_key_exists($fieldTest, $model->getChanges())); + $this->assertModelExists($model); + } + + /** @return void */ + public function testCanDeleteSubmeat(): void + { + $model = Submeat::factory()->createOneQuietly(); + $model->delete(); + $this->assertModelMissing($model); + } +} diff --git a/tests/Back/SubrangeTest.php b/tests/Back/SubrangeTest.php new file mode 100644 index 00000000..8beb15fc --- /dev/null +++ b/tests/Back/SubrangeTest.php @@ -0,0 +1,218 @@ +get(route( + config('unit-tests.route.prefix') . + 'subranges.' . + config('unit-tests.view.resources-index') + )); + $response->assertRedirect(route(config('unit-tests.route.prefix') . 'login')); + } + + /** @return void */ + public function testGuestCannotAccessSubrangesReadView(): void + { + $model = Subrange::factory()->createOneQuietly(); + $response = $this->get(route( + config('unit-tests.route.prefix') . + 'subranges.' . + config('unit-tests.view.resources-read'), + $model->getKey() + )); + $response->assertRedirect(route(config('unit-tests.route.prefix') . 'login')); + } + + /** @return void */ + public function testGuestCannotAccessSubrangesCreateView(): void + { + $response = $this->get(route( + config('unit-tests.route.prefix') . + 'subranges.' . + config('unit-tests.view.resources-create') + )); + $response->assertRedirect(route(config('unit-tests.route.prefix') . 'login')); + } + + /** @return void */ + public function testGuestCannotAccessSubrangesUpdateView(): void + { + $model = Subrange::factory()->createOneQuietly(); + $response = $this->get(route( + config('unit-tests.route.prefix') . + 'subranges.' . + config('unit-tests.view.resources-update'), + $model->getKey() + )); + $response->assertRedirect(route(config('unit-tests.route.prefix') . 'login')); + } + + /** + * TESTS GUEST CANNOT POST MODEL. + */ + + /** @return void */ + public function testGuestCannotCreateSubrange(): void + { + $model = Subrange::factory()->createOneQuietly(); + $response = $this->post( + route( + config('unit-tests.route.prefix') . 'subranges.' . config('unit-tests.route.action-create'), + $model->getKey() + ), + $model->toArray() + ); + $response->assertRedirect(route(config('unit-tests.route.prefix') . 'login')); + } + + /** @return void */ + public function testGuestCannotUpdateSubrange(): void + { + $model = Subrange::factory()->createOneQuietly(); + $response = $this->patch( + route( + config('unit-tests.route.prefix') . 'subranges.' . config('unit-tests.route.action-update'), + $model->getKey() + ), + $model->toArray() + ); + $response->assertRedirect(route(config('unit-tests.route.prefix') . 'login')); + } + + /** @return void */ + public function testGuestCannotDeleteSubrange(): void + { + $model = Subrange::factory()->createOneQuietly(); + $response = $this->delete( + route( + config('unit-tests.route.prefix') . 'subranges.' . config('unit-tests.route.action-delete'), + $model->getKey() + ), + $model->toArray() + ); + $response->assertRedirect(route(config('unit-tests.route.prefix') . 'login')); + } + + /** + * TESTS USER CONCEPTOR ACCESS VIEWS. + */ + + /** @return void */ + public function testUserConceptorCanAccessSubrangesIndexView(): void + { + $authModel = AuthModel::factory()->createOneQuietly(); + $authModel->update(['role' => RoleEnum::conceptor]); + $response = $this->actingAs($authModel, 'backend')->get( + route(config('unit-tests.route.prefix') . 'subranges.' . config('unit-tests.view.resources-index')) + ); + $response->assertSuccessful(); + $response->assertViewIs( + config('unit-tests.view.prefix') . + 'pages.subranges.' . + config('unit-tests.view.resources-index') + ); + } + + /** @return void */ + public function testUserConceptorCanAccessSubrangesReadView(): void + { + $authModel = AuthModel::factory()->createOneQuietly(); + $authModel->update(['role' => RoleEnum::conceptor]); + $model = Subrange::factory()->createOneQuietly(); + $response = $this->actingAs($authModel, 'backend')->get( + route(config('unit-tests.route.prefix') . 'subranges.' . config('unit-tests.view.resources-read'), $model) + ); + $response->assertSuccessful(); + $response->assertViewIs( + config('unit-tests.view.prefix') . + 'pages.subranges.' . + config('unit-tests.view.resources-read') + ); + } + + /** @return void */ + public function testUserConceptorCanAccessSubrangesCreateView(): void + { + $authModel = AuthModel::factory()->createOneQuietly(); + $authModel->update(['role' => RoleEnum::conceptor]); + $response = $this->actingAs($authModel, 'backend')->get( + route(config('unit-tests.route.prefix') . 'subranges.' . config('unit-tests.view.resources-create')) + ); + $response->assertSuccessful(); + $response->assertViewIs( + config('unit-tests.view.prefix') . + 'pages.subranges.' . + config('unit-tests.view.resources-create') + ); + } + + /** @return void */ + public function testUserConceptorCanAccessSubrangesUpdateView(): void + { + $authModel = AuthModel::factory()->createOneQuietly(); + $authModel->update(['role' => RoleEnum::conceptor]); + $model = Subrange::factory()->createOneQuietly(); + $response = $this->actingAs($authModel, 'backend')->get( + route(config('unit-tests.route.prefix') . 'subranges.' . config('unit-tests.view.resources-update'), $model) + ); + $response->assertSuccessful(); + $response->assertViewIs( + config('unit-tests.view.prefix') . + 'pages.subranges.' . + config('unit-tests.view.resources-update') + ); + } + + /** + * TESTS CAN ACTIONS ON MODEL. + */ + + /** @return void */ + public function testCanCreateSubrange(): void + { + $model = Subrange::factory()->createOneQuietly(); + $this->assertModelExists($model); + } + + /** @return void */ + public function testCanUpdateSubrange(): void + { + $model = Subrange::factory()->createOneQuietly(); + + $fieldTest = ""; + foreach (config('unit-tests.list-fields') as $field) { + if (Schema::hasColumn($model->getTable(), $field)) { + $model->update([$field => "test"]); + $fieldTest = $field; + break; + } + } + + $this->assertTrue($model->wasChanged()); + $this->assertTrue(array_key_exists($fieldTest, $model->getChanges())); + $this->assertModelExists($model); + } + + /** @return void */ + public function testCanDeleteSubrange(): void + { + $model = Subrange::factory()->createOneQuietly(); + $model->delete(); + $this->assertModelMissing($model); + } +} diff --git a/tests/Back/SurveysAnswerTest.php b/tests/Back/SurveysAnswerTest.php new file mode 100644 index 00000000..50e95b51 --- /dev/null +++ b/tests/Back/SurveysAnswerTest.php @@ -0,0 +1,218 @@ +get(route( + config('unit-tests.route.prefix') . + 'surveys_answers.' . + config('unit-tests.view.resources-index') + )); + $response->assertRedirect(route(config('unit-tests.route.prefix') . 'login')); + } + + /** @return void */ + public function testGuestCannotAccessSurveysAnswersReadView(): void + { + $model = SurveysAnswer::factory()->createOneQuietly(); + $response = $this->get(route( + config('unit-tests.route.prefix') . + 'surveys_answers.' . + config('unit-tests.view.resources-read'), + $model->getKey() + )); + $response->assertRedirect(route(config('unit-tests.route.prefix') . 'login')); + } + + /** @return void */ + public function testGuestCannotAccessSurveysAnswersCreateView(): void + { + $response = $this->get(route( + config('unit-tests.route.prefix') . + 'surveys_answers.' . + config('unit-tests.view.resources-create') + )); + $response->assertRedirect(route(config('unit-tests.route.prefix') . 'login')); + } + + /** @return void */ + public function testGuestCannotAccessSurveysAnswersUpdateView(): void + { + $model = SurveysAnswer::factory()->createOneQuietly(); + $response = $this->get(route( + config('unit-tests.route.prefix') . + 'surveys_answers.' . + config('unit-tests.view.resources-update'), + $model->getKey() + )); + $response->assertRedirect(route(config('unit-tests.route.prefix') . 'login')); + } + + /** + * TESTS GUEST CANNOT POST MODEL. + */ + + /** @return void */ + public function testGuestCannotCreateSurveysAnswer(): void + { + $model = SurveysAnswer::factory()->createOneQuietly(); + $response = $this->post( + route( + config('unit-tests.route.prefix') . 'surveys_answers.' . config('unit-tests.route.action-create'), + $model->getKey() + ), + $model->toArray() + ); + $response->assertRedirect(route(config('unit-tests.route.prefix') . 'login')); + } + + /** @return void */ + public function testGuestCannotUpdateSurveysAnswer(): void + { + $model = SurveysAnswer::factory()->createOneQuietly(); + $response = $this->patch( + route( + config('unit-tests.route.prefix') . 'surveys_answers.' . config('unit-tests.route.action-update'), + $model->getKey() + ), + $model->toArray() + ); + $response->assertRedirect(route(config('unit-tests.route.prefix') . 'login')); + } + + /** @return void */ + public function testGuestCannotDeleteSurveysAnswer(): void + { + $model = SurveysAnswer::factory()->createOneQuietly(); + $response = $this->delete( + route( + config('unit-tests.route.prefix') . 'surveys_answers.' . config('unit-tests.route.action-delete'), + $model->getKey() + ), + $model->toArray() + ); + $response->assertRedirect(route(config('unit-tests.route.prefix') . 'login')); + } + + /** + * TESTS USER CONCEPTOR ACCESS VIEWS. + */ + + /** @return void */ + public function testUserConceptorCanAccessSurveysAnswersIndexView(): void + { + $authModel = AuthModel::factory()->createOneQuietly(); + $authModel->update(['role' => RoleEnum::conceptor]); + $response = $this->actingAs($authModel, 'backend')->get( + route(config('unit-tests.route.prefix') . 'surveys_answers.' . config('unit-tests.view.resources-index')) + ); + $response->assertSuccessful(); + $response->assertViewIs( + config('unit-tests.view.prefix') . + 'pages.surveys_answers.' . + config('unit-tests.view.resources-index') + ); + } + + /** @return void */ + public function testUserConceptorCanAccessSurveysAnswersReadView(): void + { + $authModel = AuthModel::factory()->createOneQuietly(); + $authModel->update(['role' => RoleEnum::conceptor]); + $model = SurveysAnswer::factory()->createOneQuietly(); + $response = $this->actingAs($authModel, 'backend')->get( + route(config('unit-tests.route.prefix') . 'surveys_answers.' . config('unit-tests.view.resources-read'), $model) + ); + $response->assertSuccessful(); + $response->assertViewIs( + config('unit-tests.view.prefix') . + 'pages.surveys_answers.' . + config('unit-tests.view.resources-read') + ); + } + + /** @return void */ + public function testUserConceptorCanAccessSurveysAnswersCreateView(): void + { + $authModel = AuthModel::factory()->createOneQuietly(); + $authModel->update(['role' => RoleEnum::conceptor]); + $response = $this->actingAs($authModel, 'backend')->get( + route(config('unit-tests.route.prefix') . 'surveys_answers.' . config('unit-tests.view.resources-create')) + ); + $response->assertSuccessful(); + $response->assertViewIs( + config('unit-tests.view.prefix') . + 'pages.surveys_answers.' . + config('unit-tests.view.resources-create') + ); + } + + /** @return void */ + public function testUserConceptorCanAccessSurveysAnswersUpdateView(): void + { + $authModel = AuthModel::factory()->createOneQuietly(); + $authModel->update(['role' => RoleEnum::conceptor]); + $model = SurveysAnswer::factory()->createOneQuietly(); + $response = $this->actingAs($authModel, 'backend')->get( + route(config('unit-tests.route.prefix') . 'surveys_answers.' . config('unit-tests.view.resources-update'), $model) + ); + $response->assertSuccessful(); + $response->assertViewIs( + config('unit-tests.view.prefix') . + 'pages.surveys_answers.' . + config('unit-tests.view.resources-update') + ); + } + + /** + * TESTS CAN ACTIONS ON MODEL. + */ + + /** @return void */ + public function testCanCreateSurveysAnswer(): void + { + $model = SurveysAnswer::factory()->createOneQuietly(); + $this->assertModelExists($model); + } + + /** @return void */ + public function testCanUpdateSurveysAnswer(): void + { + $model = SurveysAnswer::factory()->createOneQuietly(); + + $fieldTest = ""; + foreach (config('unit-tests.list-fields') as $field) { + if (Schema::hasColumn($model->getTable(), $field)) { + $model->update([$field => "test"]); + $fieldTest = $field; + break; + } + } + + $this->assertTrue($model->wasChanged()); + $this->assertTrue(array_key_exists($fieldTest, $model->getChanges())); + $this->assertModelExists($model); + } + + /** @return void */ + public function testCanDeleteSurveysAnswer(): void + { + $model = SurveysAnswer::factory()->createOneQuietly(); + $model->delete(); + $this->assertModelMissing($model); + } +} diff --git a/tests/Back/TestimonialTest.php b/tests/Back/TestimonialTest.php new file mode 100644 index 00000000..04cbaf13 --- /dev/null +++ b/tests/Back/TestimonialTest.php @@ -0,0 +1,218 @@ +get(route( + config('unit-tests.route.prefix') . + 'testimonials.' . + config('unit-tests.view.resources-index') + )); + $response->assertRedirect(route(config('unit-tests.route.prefix') . 'login')); + } + + /** @return void */ + public function testGuestCannotAccessTestimonialsReadView(): void + { + $model = Testimonial::factory()->createOneQuietly(); + $response = $this->get(route( + config('unit-tests.route.prefix') . + 'testimonials.' . + config('unit-tests.view.resources-read'), + $model->getKey() + )); + $response->assertRedirect(route(config('unit-tests.route.prefix') . 'login')); + } + + /** @return void */ + public function testGuestCannotAccessTestimonialsCreateView(): void + { + $response = $this->get(route( + config('unit-tests.route.prefix') . + 'testimonials.' . + config('unit-tests.view.resources-create') + )); + $response->assertRedirect(route(config('unit-tests.route.prefix') . 'login')); + } + + /** @return void */ + public function testGuestCannotAccessTestimonialsUpdateView(): void + { + $model = Testimonial::factory()->createOneQuietly(); + $response = $this->get(route( + config('unit-tests.route.prefix') . + 'testimonials.' . + config('unit-tests.view.resources-update'), + $model->getKey() + )); + $response->assertRedirect(route(config('unit-tests.route.prefix') . 'login')); + } + + /** + * TESTS GUEST CANNOT POST MODEL. + */ + + /** @return void */ + public function testGuestCannotCreateTestimonial(): void + { + $model = Testimonial::factory()->createOneQuietly(); + $response = $this->post( + route( + config('unit-tests.route.prefix') . 'testimonials.' . config('unit-tests.route.action-create'), + $model->getKey() + ), + $model->toArray() + ); + $response->assertRedirect(route(config('unit-tests.route.prefix') . 'login')); + } + + /** @return void */ + public function testGuestCannotUpdateTestimonial(): void + { + $model = Testimonial::factory()->createOneQuietly(); + $response = $this->patch( + route( + config('unit-tests.route.prefix') . 'testimonials.' . config('unit-tests.route.action-update'), + $model->getKey() + ), + $model->toArray() + ); + $response->assertRedirect(route(config('unit-tests.route.prefix') . 'login')); + } + + /** @return void */ + public function testGuestCannotDeleteTestimonial(): void + { + $model = Testimonial::factory()->createOneQuietly(); + $response = $this->delete( + route( + config('unit-tests.route.prefix') . 'testimonials.' . config('unit-tests.route.action-delete'), + $model->getKey() + ), + $model->toArray() + ); + $response->assertRedirect(route(config('unit-tests.route.prefix') . 'login')); + } + + /** + * TESTS USER CONCEPTOR ACCESS VIEWS. + */ + + /** @return void */ + public function testUserConceptorCanAccessTestimonialsIndexView(): void + { + $authModel = AuthModel::factory()->createOneQuietly(); + $authModel->update(['role' => RoleEnum::conceptor]); + $response = $this->actingAs($authModel, 'backend')->get( + route(config('unit-tests.route.prefix') . 'testimonials.' . config('unit-tests.view.resources-index')) + ); + $response->assertSuccessful(); + $response->assertViewIs( + config('unit-tests.view.prefix') . + 'pages.testimonials.' . + config('unit-tests.view.resources-index') + ); + } + + /** @return void */ + public function testUserConceptorCanAccessTestimonialsReadView(): void + { + $authModel = AuthModel::factory()->createOneQuietly(); + $authModel->update(['role' => RoleEnum::conceptor]); + $model = Testimonial::factory()->createOneQuietly(); + $response = $this->actingAs($authModel, 'backend')->get( + route(config('unit-tests.route.prefix') . 'testimonials.' . config('unit-tests.view.resources-read'), $model) + ); + $response->assertSuccessful(); + $response->assertViewIs( + config('unit-tests.view.prefix') . + 'pages.testimonials.' . + config('unit-tests.view.resources-read') + ); + } + + /** @return void */ + public function testUserConceptorCanAccessTestimonialsCreateView(): void + { + $authModel = AuthModel::factory()->createOneQuietly(); + $authModel->update(['role' => RoleEnum::conceptor]); + $response = $this->actingAs($authModel, 'backend')->get( + route(config('unit-tests.route.prefix') . 'testimonials.' . config('unit-tests.view.resources-create')) + ); + $response->assertSuccessful(); + $response->assertViewIs( + config('unit-tests.view.prefix') . + 'pages.testimonials.' . + config('unit-tests.view.resources-create') + ); + } + + /** @return void */ + public function testUserConceptorCanAccessTestimonialsUpdateView(): void + { + $authModel = AuthModel::factory()->createOneQuietly(); + $authModel->update(['role' => RoleEnum::conceptor]); + $model = Testimonial::factory()->createOneQuietly(); + $response = $this->actingAs($authModel, 'backend')->get( + route(config('unit-tests.route.prefix') . 'testimonials.' . config('unit-tests.view.resources-update'), $model) + ); + $response->assertSuccessful(); + $response->assertViewIs( + config('unit-tests.view.prefix') . + 'pages.testimonials.' . + config('unit-tests.view.resources-update') + ); + } + + /** + * TESTS CAN ACTIONS ON MODEL. + */ + + /** @return void */ + public function testCanCreateTestimonial(): void + { + $model = Testimonial::factory()->createOneQuietly(); + $this->assertModelExists($model); + } + + /** @return void */ + public function testCanUpdateTestimonial(): void + { + $model = Testimonial::factory()->createOneQuietly(); + + $fieldTest = ""; + foreach (config('unit-tests.list-fields') as $field) { + if (Schema::hasColumn($model->getTable(), $field)) { + $model->update([$field => "test"]); + $fieldTest = $field; + break; + } + } + + $this->assertTrue($model->wasChanged()); + $this->assertTrue(array_key_exists($fieldTest, $model->getChanges())); + $this->assertModelExists($model); + } + + /** @return void */ + public function testCanDeleteTestimonial(): void + { + $model = Testimonial::factory()->createOneQuietly(); + $model->delete(); + $this->assertModelMissing($model); + } +} diff --git a/tests/Back/VideoTest.php b/tests/Back/VideoTest.php new file mode 100644 index 00000000..8f94239c --- /dev/null +++ b/tests/Back/VideoTest.php @@ -0,0 +1,218 @@ +get(route( + config('unit-tests.route.prefix') . + 'videos.' . + config('unit-tests.view.resources-index') + )); + $response->assertRedirect(route(config('unit-tests.route.prefix') . 'login')); + } + + /** @return void */ + public function testGuestCannotAccessVideosReadView(): void + { + $model = Video::factory()->createOneQuietly(); + $response = $this->get(route( + config('unit-tests.route.prefix') . + 'videos.' . + config('unit-tests.view.resources-read'), + $model->getKey() + )); + $response->assertRedirect(route(config('unit-tests.route.prefix') . 'login')); + } + + /** @return void */ + public function testGuestCannotAccessVideosCreateView(): void + { + $response = $this->get(route( + config('unit-tests.route.prefix') . + 'videos.' . + config('unit-tests.view.resources-create') + )); + $response->assertRedirect(route(config('unit-tests.route.prefix') . 'login')); + } + + /** @return void */ + public function testGuestCannotAccessVideosUpdateView(): void + { + $model = Video::factory()->createOneQuietly(); + $response = $this->get(route( + config('unit-tests.route.prefix') . + 'videos.' . + config('unit-tests.view.resources-update'), + $model->getKey() + )); + $response->assertRedirect(route(config('unit-tests.route.prefix') . 'login')); + } + + /** + * TESTS GUEST CANNOT POST MODEL. + */ + + /** @return void */ + public function testGuestCannotCreateVideo(): void + { + $model = Video::factory()->createOneQuietly(); + $response = $this->post( + route( + config('unit-tests.route.prefix') . 'videos.' . config('unit-tests.route.action-create'), + $model->getKey() + ), + $model->toArray() + ); + $response->assertRedirect(route(config('unit-tests.route.prefix') . 'login')); + } + + /** @return void */ + public function testGuestCannotUpdateVideo(): void + { + $model = Video::factory()->createOneQuietly(); + $response = $this->patch( + route( + config('unit-tests.route.prefix') . 'videos.' . config('unit-tests.route.action-update'), + $model->getKey() + ), + $model->toArray() + ); + $response->assertRedirect(route(config('unit-tests.route.prefix') . 'login')); + } + + /** @return void */ + public function testGuestCannotDeleteVideo(): void + { + $model = Video::factory()->createOneQuietly(); + $response = $this->delete( + route( + config('unit-tests.route.prefix') . 'videos.' . config('unit-tests.route.action-delete'), + $model->getKey() + ), + $model->toArray() + ); + $response->assertRedirect(route(config('unit-tests.route.prefix') . 'login')); + } + + /** + * TESTS USER CONCEPTOR ACCESS VIEWS. + */ + + /** @return void */ + public function testUserConceptorCanAccessVideosIndexView(): void + { + $authModel = AuthModel::factory()->createOneQuietly(); + $authModel->update(['role' => RoleEnum::conceptor]); + $response = $this->actingAs($authModel, 'backend')->get( + route(config('unit-tests.route.prefix') . 'videos.' . config('unit-tests.view.resources-index')) + ); + $response->assertSuccessful(); + $response->assertViewIs( + config('unit-tests.view.prefix') . + 'pages.videos.' . + config('unit-tests.view.resources-index') + ); + } + + /** @return void */ + public function testUserConceptorCanAccessVideosReadView(): void + { + $authModel = AuthModel::factory()->createOneQuietly(); + $authModel->update(['role' => RoleEnum::conceptor]); + $model = Video::factory()->createOneQuietly(); + $response = $this->actingAs($authModel, 'backend')->get( + route(config('unit-tests.route.prefix') . 'videos.' . config('unit-tests.view.resources-read'), $model) + ); + $response->assertSuccessful(); + $response->assertViewIs( + config('unit-tests.view.prefix') . + 'pages.videos.' . + config('unit-tests.view.resources-read') + ); + } + + /** @return void */ + public function testUserConceptorCanAccessVideosCreateView(): void + { + $authModel = AuthModel::factory()->createOneQuietly(); + $authModel->update(['role' => RoleEnum::conceptor]); + $response = $this->actingAs($authModel, 'backend')->get( + route(config('unit-tests.route.prefix') . 'videos.' . config('unit-tests.view.resources-create')) + ); + $response->assertSuccessful(); + $response->assertViewIs( + config('unit-tests.view.prefix') . + 'pages.videos.' . + config('unit-tests.view.resources-create') + ); + } + + /** @return void */ + public function testUserConceptorCanAccessVideosUpdateView(): void + { + $authModel = AuthModel::factory()->createOneQuietly(); + $authModel->update(['role' => RoleEnum::conceptor]); + $model = Video::factory()->createOneQuietly(); + $response = $this->actingAs($authModel, 'backend')->get( + route(config('unit-tests.route.prefix') . 'videos.' . config('unit-tests.view.resources-update'), $model) + ); + $response->assertSuccessful(); + $response->assertViewIs( + config('unit-tests.view.prefix') . + 'pages.videos.' . + config('unit-tests.view.resources-update') + ); + } + + /** + * TESTS CAN ACTIONS ON MODEL. + */ + + /** @return void */ + public function testCanCreateVideo(): void + { + $model = Video::factory()->createOneQuietly(); + $this->assertModelExists($model); + } + + /** @return void */ + public function testCanUpdateVideo(): void + { + $model = Video::factory()->createOneQuietly(); + + $fieldTest = ""; + foreach (config('unit-tests.list-fields') as $field) { + if (Schema::hasColumn($model->getTable(), $field)) { + $model->update([$field => "test"]); + $fieldTest = $field; + break; + } + } + + $this->assertTrue($model->wasChanged()); + $this->assertTrue(array_key_exists($fieldTest, $model->getChanges())); + $this->assertModelExists($model); + } + + /** @return void */ + public function testCanDeleteVideo(): void + { + $model = Video::factory()->createOneQuietly(); + $model->delete(); + $this->assertModelMissing($model); + } +} diff --git a/tests/CreatesApplication.php b/tests/CreatesApplication.php index cc683011..aa065842 100644 --- a/tests/CreatesApplication.php +++ b/tests/CreatesApplication.php @@ -3,19 +3,18 @@ namespace Tests; use Illuminate\Contracts\Console\Kernel; -use Illuminate\Foundation\Application; trait CreatesApplication { /** * Creates the application. + * + * @return \Illuminate\Foundation\Application */ - public function createApplication(): Application + public function createApplication(): \Illuminate\Foundation\Application { - $app = require __DIR__.'/../bootstrap/app.php'; - + $app = require __DIR__ . '/../bootstrap/app.php'; $app->make(Kernel::class)->bootstrap(); - return $app; } } diff --git a/tests/Feature/ExampleTest.php b/tests/Feature/ExampleTest.php deleted file mode 100644 index 8364a84e..00000000 --- a/tests/Feature/ExampleTest.php +++ /dev/null @@ -1,19 +0,0 @@ -get('/'); - - $response->assertStatus(200); - } -} diff --git a/tests/TestCase.php b/tests/TestCase.php index 2932d4a6..c58ad548 100644 --- a/tests/TestCase.php +++ b/tests/TestCase.php @@ -2,9 +2,11 @@ namespace Tests; +use Illuminate\Foundation\Testing\DatabaseTransactions; use Illuminate\Foundation\Testing\TestCase as BaseTestCase; abstract class TestCase extends BaseTestCase { use CreatesApplication; + use DatabaseTransactions; } diff --git a/tests/Unit/ExampleTest.php b/tests/Unit/ExampleTest.php deleted file mode 100644 index 5773b0ce..00000000 --- a/tests/Unit/ExampleTest.php +++ /dev/null @@ -1,16 +0,0 @@ -assertTrue(true); - } -} From e01bf29ce7ab1597cc3e478a09dba758d63201de Mon Sep 17 00:00:00 2001 From: Alexis Gousseau Date: Thu, 24 Oct 2024 09:03:17 +0000 Subject: [PATCH 2/8] feat: :children_crossing: matches telescope theme with backend theme --- .env.example | 3 + app/Http/Controllers/Controller.php | 2 +- app/Providers/AppServiceProvider.php | 4 +- app/Providers/TelescopeServiceProvider.php | 39 ++++-- config/telescope.php | 132 ++++++++++----------- 5 files changed, 100 insertions(+), 80 deletions(-) diff --git a/.env.example b/.env.example index 1f2e6613..a6b0a5bb 100644 --- a/.env.example +++ b/.env.example @@ -81,3 +81,6 @@ GOOGLE_RECAPTCHA_VERSION= MERCANET_SECRET= MERCANET_MERCHAND_ID= MERCANET_ENV= + +## TELESCOPE +TELESCOPE_ENABLED= diff --git a/app/Http/Controllers/Controller.php b/app/Http/Controllers/Controller.php index 24d8bf99..4090c329 100644 --- a/app/Http/Controllers/Controller.php +++ b/app/Http/Controllers/Controller.php @@ -315,7 +315,7 @@ class Controller extends BaseController string|null $search = null ): \Illuminate\Pagination\LengthAwarePaginator { $modelsTitles = []; - $searchLower = Str::lower($search); + $searchLower = Str::lower($search); $query->when(!is_null($search), function (Builder $q) use ($searchLower, $searchField) { $q->where($searchField, 'like', "%{$searchLower}%"); }) diff --git a/app/Providers/AppServiceProvider.php b/app/Providers/AppServiceProvider.php index f6c8cbd9..b9d862ec 100644 --- a/app/Providers/AppServiceProvider.php +++ b/app/Providers/AppServiceProvider.php @@ -5,12 +5,14 @@ namespace App\Providers; use App\Enums\Settings\SettingsType; use App\Models\GeneralSetting; use App\Models\MenuNodeData; +use App\Providers\TelescopeServiceProvider as CustomTelescopeServiceProvider; use Illuminate\Support\Carbon; use Illuminate\Support\Facades\App; use Illuminate\Support\Facades\URL; use Illuminate\Support\ServiceProvider; use Illuminate\Database\Eloquent\Model; use Illuminate\Support\Facades\Blade; +use Laravel\Telescope\TelescopeServiceProvider; use Money\Currencies\ISOCurrencies; use Money\Currency; use Money\Formatter\IntlMoneyFormatter; @@ -71,8 +73,8 @@ class AppServiceProvider extends ServiceProvider public function register(): void { if ($this->app->environment('local')) { - $this->app->register(\Laravel\Telescope\TelescopeServiceProvider::class); $this->app->register(TelescopeServiceProvider::class); + $this->app->register(CustomTelescopeServiceProvider::class); } } diff --git a/app/Providers/TelescopeServiceProvider.php b/app/Providers/TelescopeServiceProvider.php index 470ef171..3978449d 100644 --- a/app/Providers/TelescopeServiceProvider.php +++ b/app/Providers/TelescopeServiceProvider.php @@ -2,36 +2,54 @@ namespace App\Providers; +use App\Enums\Theme\BootstrapThemeEnum; use Illuminate\Support\Facades\Gate; use Laravel\Telescope\IncomingEntry; use Laravel\Telescope\Telescope; use Laravel\Telescope\TelescopeApplicationServiceProvider; +use Illuminate\Support\Facades\Cache; class TelescopeServiceProvider extends TelescopeApplicationServiceProvider { + /** + * Bootstrap any application services. + * + * @return void + */ + public function boot(): void + { + // Matches Telescope theme with back-end theme. + if (Cache::get('theme', BootstrapThemeEnum::light->value()) === BootstrapThemeEnum::dark->value()) { + Telescope::night(); + } + $this->authorization(); + } + /** * Register any application services. + * + * @return void */ public function register(): void { - // Telescope::night(); - $this->hideSensitiveRequestDetails(); $isLocal = $this->app->environment('local'); Telescope::filter(function (IncomingEntry $entry) use ($isLocal) { return $isLocal || - $entry->isReportableException() || - $entry->isFailedRequest() || - $entry->isFailedJob() || - $entry->isScheduledTask() || - $entry->hasMonitoredTag(); + $entry->isReportableException() || + $entry->isFailedRequest() || + $entry->isFailedJob() || + $entry->isScheduledTask() || + $entry->hasMonitoredTag(); }); } /** * Prevent sensitive request details from being logged by Telescope. + * + * @return void */ protected function hideSensitiveRequestDetails(): void { @@ -50,15 +68,14 @@ class TelescopeServiceProvider extends TelescopeApplicationServiceProvider /** * Register the Telescope gate. - * * This gate determines who can access Telescope in non-local environments. + * + * @return void */ protected function gate(): void { Gate::define('viewTelescope', function ($user) { - return in_array($user->email, [ - // - ]); + return in_array($user->email, []); }); } } diff --git a/config/telescope.php b/config/telescope.php index 4418e692..fa9fbad4 100644 --- a/config/telescope.php +++ b/config/telescope.php @@ -6,53 +6,53 @@ use Laravel\Telescope\Watchers; return [ /* - |-------------------------------------------------------------------------- - | Telescope Master Switch - |-------------------------------------------------------------------------- - | - | This option may be used to disable all Telescope watchers regardless - | of their individual configuration, which simply provides a single - | and convenient way to enable or disable Telescope data storage. - | + |-------------------------------------------------------------------------- + | Telescope Master Switch + |-------------------------------------------------------------------------- + | + | This option may be used to disable all Telescope watchers regardless + | of their individual configuration, which simply provides a single + | and convenient way to enable or disable Telescope data storage. + | */ 'enabled' => env('TELESCOPE_ENABLED', false), /* - |-------------------------------------------------------------------------- - | Telescope Domain - |-------------------------------------------------------------------------- - | - | This is the subdomain where Telescope will be accessible from. If the - | setting is null, Telescope will reside under the same domain as the - | application. Otherwise, this value will be used as the subdomain. - | + |-------------------------------------------------------------------------- + | Telescope Domain + |-------------------------------------------------------------------------- + | + | This is the subdomain where Telescope will be accessible from. If the + | setting is null, Telescope will reside under the same domain as the + | application. Otherwise, this value will be used as the subdomain. + | */ 'domain' => env('TELESCOPE_DOMAIN'), /* - |-------------------------------------------------------------------------- - | Telescope Path - |-------------------------------------------------------------------------- - | - | This is the URI path where Telescope will be accessible from. Feel free - | to change this path to anything you like. Note that the URI will not - | affect the paths of its internal API that aren't exposed to users. - | + |-------------------------------------------------------------------------- + | Telescope Path + |-------------------------------------------------------------------------- + | + | This is the URI path where Telescope will be accessible from. Feel free + | to change this path to anything you like. Note that the URI will not + | affect the paths of its internal API that aren't exposed to users. + | */ 'path' => env('TELESCOPE_PATH', 'telescope'), /* - |-------------------------------------------------------------------------- - | Telescope Storage Driver - |-------------------------------------------------------------------------- - | - | This configuration options determines the storage driver that will - | be used to store Telescope's data. In addition, you may set any - | custom options as needed by the particular driver you choose. - | + |-------------------------------------------------------------------------- + | Telescope Storage Driver + |-------------------------------------------------------------------------- + | + | This configuration options determines the storage driver that will + | be used to store Telescope's data. In addition, you may set any + | custom options as needed by the particular driver you choose. + | */ 'driver' => env('TELESCOPE_DRIVER', 'database'), @@ -65,14 +65,14 @@ return [ ], /* - |-------------------------------------------------------------------------- - | Telescope Queue - |-------------------------------------------------------------------------- - | - | This configuration options determines the queue connection and queue - | which will be used to process ProcessPendingUpdate jobs. This can - | be changed if you would prefer to use a non-default connection. - | + |-------------------------------------------------------------------------- + | Telescope Queue + |-------------------------------------------------------------------------- + | + | This configuration options determines the queue connection and queue + | which will be used to process ProcessPendingUpdate jobs. This can + | be changed if you would prefer to use a non-default connection. + | */ 'queue' => [ @@ -81,14 +81,14 @@ return [ ], /* - |-------------------------------------------------------------------------- - | Telescope Route Middleware - |-------------------------------------------------------------------------- - | - | These middleware will be assigned to every Telescope route, giving you - | the chance to add your own middleware to this list or change any of - | the existing middleware. Or, you can simply stick with this list. - | + |-------------------------------------------------------------------------- + | Telescope Route Middleware + |-------------------------------------------------------------------------- + | + | These middleware will be assigned to every Telescope route, giving you + | the chance to add your own middleware to this list or change any of + | the existing middleware. Or, you can simply stick with this list. + | */ 'middleware' => [ @@ -97,14 +97,14 @@ return [ ], /* - |-------------------------------------------------------------------------- - | Allowed / Ignored Paths & Commands - |-------------------------------------------------------------------------- - | - | The following array lists the URI paths and Artisan commands that will - | not be watched by Telescope. In addition to this list, some Laravel - | commands, like migrations and queue commands, are always ignored. - | + |-------------------------------------------------------------------------- + | Allowed / Ignored Paths & Commands + |-------------------------------------------------------------------------- + | + | The following array lists the URI paths and Artisan commands that will + | not be watched by Telescope. In addition to this list, some Laravel + | commands, like migrations and queue commands, are always ignored. + | */ 'only_paths' => [ @@ -117,19 +117,17 @@ return [ 'pulse*', ], - 'ignore_commands' => [ - // - ], + 'ignore_commands' => [], /* - |-------------------------------------------------------------------------- - | Telescope Watchers - |-------------------------------------------------------------------------- - | - | The following array lists the "watchers" that will be registered with - | Telescope. The watchers gather the application's profile data when - | a request or task is executed. Feel free to customize this list. - | + |-------------------------------------------------------------------------- + | Telescope Watchers + |-------------------------------------------------------------------------- + | + | The following array lists the "watchers" that will be registered with + | Telescope. The watchers gather the application's profile data when + | a request or task is executed. Feel free to customize this list. + | */ 'watchers' => [ From c994b49361776ab33163c15b9351242fdb8bc3d8 Mon Sep 17 00:00:00 2001 From: Vincent BRIDIER Date: Thu, 24 Oct 2024 11:36:55 +0200 Subject: [PATCH 3/8] fix: Fix Dockerfile --- .dockerignore | 14 ++++++++++++++ Dockerfile | 2 -- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/.dockerignore b/.dockerignore index fac5ce78..2d1dc134 100644 --- a/.dockerignore +++ b/.dockerignore @@ -1,2 +1,16 @@ .git *.md +node_modules/ +npm-debug.log +.npmrc +tests/ +Dockerfile* +.dockerignore +.git +.gitignore +README.md +LICENSE +.vscode +vendor/ +public/build/ +auth.json diff --git a/Dockerfile b/Dockerfile index 0817e48b..7a41290a 100644 --- a/Dockerfile +++ b/Dockerfile @@ -15,8 +15,6 @@ RUN composer install \ --no-plugins \ --no-scripts \ --no-dev \ - --optimize-autoloader \ - --classmap-authoritative \ --prefer-dist FROM node:20.18 AS frontend From 2314b29763ca5ce09f126db652f9f3d1193189ee Mon Sep 17 00:00:00 2001 From: "nicolas.demangeat" Date: Thu, 24 Oct 2024 09:42:37 +0000 Subject: [PATCH 4/8] chore :package: add uwil/sitemap-generator --- app/Models/News.php | 19 +- app/Models/Product.php | 19 +- app/Models/Recipe.php | 18 +- composer.json | 1 + composer.lock | 931 +++++++++++++++++++++++++++++------ config/sitemap-generator.php | 97 ++++ 6 files changed, 927 insertions(+), 158 deletions(-) create mode 100644 config/sitemap-generator.php diff --git a/app/Models/News.php b/app/Models/News.php index e31adb44..8db3932d 100644 --- a/app/Models/News.php +++ b/app/Models/News.php @@ -12,6 +12,10 @@ use Illuminate\Database\Eloquent\Model; use Illuminate\Support\Facades\Cache; use Illuminate\Support\Facades\Session; use Illuminate\Support\Str; +use Spatie\Sitemap\Contracts\Sitemapable; +use Spatie\Sitemap\Tags\Url; +use Uwil\SitemapGenerator\Lib\SitemapHelper; + /** * @property string $seo_title The seo title of the news. @@ -34,7 +38,7 @@ use Illuminate\Support\Str; * @property-read \Illuminate\Support\Carbon $created_at Created date. * @property-read \Illuminate\Support\Carbon $updated_at Updated date. */ -class News extends Model +class News extends Model implements Sitemapable { use ActivityLog; use HasFactory; @@ -298,6 +302,19 @@ class News extends Model }); } + /** + * toSitemapTag method + * + * @return Url|string|array + */ + public function toSitemapTag(): Url | string | array + { + $model = $this; + $route = 'fo.news.show'; + $params = ['slug' => $model->slug]; + return SitemapHelper::generateUrl($route, $params, $model); + } + // * RELATIONS /** diff --git a/app/Models/Product.php b/app/Models/Product.php index ad857595..6e15901b 100644 --- a/app/Models/Product.php +++ b/app/Models/Product.php @@ -13,6 +13,10 @@ use Illuminate\Support\Facades\Cache; use Uwil\Seo\Laravel\Interfaces\SeoInterface; use Uwil\Seo\Laravel\Traits\SeoTrait; use Uwil\Seo\Laravel\Objects\SeoItem; +use Spatie\Sitemap\Contracts\Sitemapable; +use Spatie\Sitemap\Tags\Url; +use Uwil\SitemapGenerator\Lib\SitemapHelper; + /** * @property string $seo_title Product seo title. @@ -43,7 +47,7 @@ use Uwil\Seo\Laravel\Objects\SeoItem; * @property-read \Carbon\Carbon $created_at Created date. * @property-read \Carbon\Carbon $updated_at Updated date. */ -class Product extends Model implements SeoInterface +class Product extends Model implements SeoInterface, Sitemapable { use ActivityLog; use HasFactory; @@ -225,6 +229,19 @@ class Product extends Model implements SeoInterface }); } + /** + * toSitemapTag method + * + * @return Url|string|array + */ + public function toSitemapTag(): Url | string | array + { + $model = $this; + $route = 'fo.product.show'; + $params = ['slug' => $model->slug]; + return SitemapHelper::generateUrl($route, $params, $model); + } + // * RELATIONSHIPS /** diff --git a/app/Models/Recipe.php b/app/Models/Recipe.php index 14578672..9455a494 100644 --- a/app/Models/Recipe.php +++ b/app/Models/Recipe.php @@ -13,6 +13,9 @@ use Illuminate\Support\Str; use Uwil\Seo\Laravel\Interfaces\SeoInterface; use Uwil\Seo\Laravel\Traits\SeoTrait; use Uwil\Seo\Laravel\Objects\SeoItem; +use Spatie\Sitemap\Contracts\Sitemapable; +use Spatie\Sitemap\Tags\Url; +use Uwil\SitemapGenerator\Lib\SitemapHelper; /** * @property string $slug Recipe slug. @@ -36,7 +39,7 @@ use Uwil\Seo\Laravel\Objects\SeoItem; * @property-read \Illuminate\Support\Carbon $created_at Created date. * @property-read \Illuminate\Support\Carbon $updated_at Updated date. */ -class Recipe extends Model implements SeoInterface +class Recipe extends Model implements SeoInterface, Sitemapable { use ActivityLog; use HasFactory; @@ -233,6 +236,19 @@ class Recipe extends Model implements SeoInterface }); } + /** + * toSitemapTag method + * + * @return Url|string|array + */ + public function toSitemapTag(): Url | string | array + { + $model = $this; + $route = 'fo.recipes.show'; + $params = ['slug' => $model->slug]; + return SitemapHelper::generateUrl($route, $params, $model); + } + // * RELATIONSHIPS /** diff --git a/composer.json b/composer.json index 8ca30ad9..a48ef3cd 100644 --- a/composer.json +++ b/composer.json @@ -35,6 +35,7 @@ "uwil/k8s-laravel": "^1.4", "uwil/laravel-common": "^2.1", "uwil/seo-laravel": "^3.0", + "uwil/sitemap-generator": "^3.0", "uwil/unit-tests-laravel": "^1.0", "verschuur/laravel-robotstxt": "^5.1" }, diff --git a/composer.lock b/composer.lock index 27edb303..61b8e234 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "e2e7d8fb63efe18287324559a12425ea", + "content-hash": "8200119db8e1281e6cbc8c702e98a5f7", "packages": [ { "name": "24slides/laravel-saml2", @@ -648,16 +648,16 @@ }, { "name": "dragonmantank/cron-expression", - "version": "v3.3.3", + "version": "v3.4.0", "source": { "type": "git", "url": "https://github.com/dragonmantank/cron-expression.git", - "reference": "adfb1f505deb6384dc8b39804c5065dd3c8c8c0a" + "reference": "8c784d071debd117328803d86b2097615b457500" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/dragonmantank/cron-expression/zipball/adfb1f505deb6384dc8b39804c5065dd3c8c8c0a", - "reference": "adfb1f505deb6384dc8b39804c5065dd3c8c8c0a", + "url": "https://api.github.com/repos/dragonmantank/cron-expression/zipball/8c784d071debd117328803d86b2097615b457500", + "reference": "8c784d071debd117328803d86b2097615b457500", "shasum": "" }, "require": { @@ -670,10 +670,14 @@ "require-dev": { "phpstan/extension-installer": "^1.0", "phpstan/phpstan": "^1.0", - "phpstan/phpstan-webmozart-assert": "^1.0", "phpunit/phpunit": "^7.0|^8.0|^9.0" }, "type": "library", + "extra": { + "branch-alias": { + "dev-master": "3.x-dev" + } + }, "autoload": { "psr-4": { "Cron\\": "src/Cron/" @@ -697,7 +701,7 @@ ], "support": { "issues": "https://github.com/dragonmantank/cron-expression/issues", - "source": "https://github.com/dragonmantank/cron-expression/tree/v3.3.3" + "source": "https://github.com/dragonmantank/cron-expression/tree/v3.4.0" }, "funding": [ { @@ -705,7 +709,7 @@ "type": "github" } ], - "time": "2023-08-10T19:36:49+00:00" + "time": "2024-10-09T13:47:03+00:00" }, { "name": "dxw/cidr", @@ -1057,16 +1061,16 @@ }, { "name": "giggsey/libphonenumber-for-php-lite", - "version": "8.13.47", + "version": "8.13.48", "source": { "type": "git", "url": "https://github.com/giggsey/libphonenumber-for-php-lite.git", - "reference": "4c8616d0f358ed5722883761180eccaa2ff5f768" + "reference": "76a4df0f53684fa4175d15aee1cee5f1047a17f7" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/giggsey/libphonenumber-for-php-lite/zipball/4c8616d0f358ed5722883761180eccaa2ff5f768", - "reference": "4c8616d0f358ed5722883761180eccaa2ff5f768", + "url": "https://api.github.com/repos/giggsey/libphonenumber-for-php-lite/zipball/76a4df0f53684fa4175d15aee1cee5f1047a17f7", + "reference": "76a4df0f53684fa4175d15aee1cee5f1047a17f7", "shasum": "" }, "require": { @@ -1136,7 +1140,7 @@ "issues": "https://github.com/giggsey/libphonenumber-for-php-lite/issues", "source": "https://github.com/giggsey/libphonenumber-for-php-lite" }, - "time": "2024-10-08T08:31:05+00:00" + "time": "2024-10-22T09:03:14+00:00" }, { "name": "graham-campbell/result-type", @@ -1328,16 +1332,16 @@ }, { "name": "guzzlehttp/promises", - "version": "2.0.3", + "version": "2.0.4", "source": { "type": "git", "url": "https://github.com/guzzle/promises.git", - "reference": "6ea8dd08867a2a42619d65c3deb2c0fcbf81c8f8" + "reference": "f9c436286ab2892c7db7be8c8da4ef61ccf7b455" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/guzzle/promises/zipball/6ea8dd08867a2a42619d65c3deb2c0fcbf81c8f8", - "reference": "6ea8dd08867a2a42619d65c3deb2c0fcbf81c8f8", + "url": "https://api.github.com/repos/guzzle/promises/zipball/f9c436286ab2892c7db7be8c8da4ef61ccf7b455", + "reference": "f9c436286ab2892c7db7be8c8da4ef61ccf7b455", "shasum": "" }, "require": { @@ -1391,7 +1395,7 @@ ], "support": { "issues": "https://github.com/guzzle/promises/issues", - "source": "https://github.com/guzzle/promises/tree/2.0.3" + "source": "https://github.com/guzzle/promises/tree/2.0.4" }, "funding": [ { @@ -1407,7 +1411,7 @@ "type": "tidelift" } ], - "time": "2024-07-18T10:29:17+00:00" + "time": "2024-10-17T10:06:22+00:00" }, { "name": "guzzlehttp/psr7", @@ -1681,21 +1685,21 @@ }, { "name": "intervention/image", - "version": "3.8.0", + "version": "3.9.0", "source": { "type": "git", "url": "https://github.com/Intervention/image.git", - "reference": "1786ad5e1789050939d73cd195de4b8eaeeb34ed" + "reference": "1e0a2b6d767ef22a095924c6bcb2981da6de6f1e" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/Intervention/image/zipball/1786ad5e1789050939d73cd195de4b8eaeeb34ed", - "reference": "1786ad5e1789050939d73cd195de4b8eaeeb34ed", + "url": "https://api.github.com/repos/Intervention/image/zipball/1e0a2b6d767ef22a095924c6bcb2981da6de6f1e", + "reference": "1e0a2b6d767ef22a095924c6bcb2981da6de6f1e", "shasum": "" }, "require": { "ext-mbstring": "*", - "intervention/gif": "^4.1", + "intervention/gif": "^4.2", "php": "^8.1" }, "require-dev": { @@ -1737,7 +1741,7 @@ ], "support": { "issues": "https://github.com/Intervention/image/issues", - "source": "https://github.com/Intervention/image/tree/3.8.0" + "source": "https://github.com/Intervention/image/tree/3.9.0" }, "funding": [ { @@ -1753,7 +1757,7 @@ "type": "ko_fi" } ], - "time": "2024-08-16T14:57:26+00:00" + "time": "2024-10-06T15:37:56+00:00" }, { "name": "jean85/pretty-package-versions", @@ -1878,23 +1882,26 @@ }, { "name": "laminas/laminas-diactoros", - "version": "3.4.0", + "version": "3.5.0", "source": { "type": "git", "url": "https://github.com/laminas/laminas-diactoros.git", - "reference": "2cce7e77ca4c6c4183e9e8d4edeba483afc14487" + "reference": "143a16306602ce56b8b092a7914fef03c37f9ed2" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/laminas/laminas-diactoros/zipball/2cce7e77ca4c6c4183e9e8d4edeba483afc14487", - "reference": "2cce7e77ca4c6c4183e9e8d4edeba483afc14487", + "url": "https://api.github.com/repos/laminas/laminas-diactoros/zipball/143a16306602ce56b8b092a7914fef03c37f9ed2", + "reference": "143a16306602ce56b8b092a7914fef03c37f9ed2", "shasum": "" }, "require": { - "php": "~8.1.0 || ~8.2.0 || ~8.3.0", - "psr/http-factory": "^1.0.2", + "php": "~8.1.0 || ~8.2.0 || ~8.3.0 || ~8.4.0", + "psr/http-factory": "^1.1", "psr/http-message": "^1.1 || ^2.0" }, + "conflict": { + "amphp/amp": "<2.6.4" + }, "provide": { "psr/http-factory-implementation": "^1.0", "psr/http-message-implementation": "^1.1 || ^2.0" @@ -1907,9 +1914,9 @@ "http-interop/http-factory-tests": "^2.2.0", "laminas/laminas-coding-standard": "~2.5.0", "php-http/psr7-integration-tests": "^1.4.0", - "phpunit/phpunit": "^10.5.31", + "phpunit/phpunit": "^10.5.36", "psalm/plugin-phpunit": "^0.19.0", - "vimeo/psalm": "^5.25.0" + "vimeo/psalm": "^5.26.1" }, "type": "library", "extra": { @@ -1959,20 +1966,20 @@ "type": "community_bridge" } ], - "time": "2024-09-11T00:55:07+00:00" + "time": "2024-10-14T11:59:49+00:00" }, { "name": "laravel/framework", - "version": "v11.26.0", + "version": "v11.29.0", "source": { "type": "git", "url": "https://github.com/laravel/framework.git", - "reference": "b8cb8998701d5b3cfe68539d3c3da1fc59ddd82b" + "reference": "425054512c362835ba9c0307561973c8eeac7385" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/laravel/framework/zipball/b8cb8998701d5b3cfe68539d3c3da1fc59ddd82b", - "reference": "b8cb8998701d5b3cfe68539d3c3da1fc59ddd82b", + "url": "https://api.github.com/repos/laravel/framework/zipball/425054512c362835ba9c0307561973c8eeac7385", + "reference": "425054512c362835ba9c0307561973c8eeac7385", "shasum": "" }, "require": { @@ -2168,20 +2175,20 @@ "issues": "https://github.com/laravel/framework/issues", "source": "https://github.com/laravel/framework" }, - "time": "2024-10-01T14:29:34+00:00" + "time": "2024-10-22T14:13:31+00:00" }, { "name": "laravel/octane", - "version": "v2.5.8", + "version": "v2.5.9", "source": { "type": "git", "url": "https://github.com/laravel/octane.git", - "reference": "ce37959546cf5e04df02aa41960f3ee816670b9b" + "reference": "d8d432eb1e51a8ab2575854963d94e70d4592e15" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/laravel/octane/zipball/ce37959546cf5e04df02aa41960f3ee816670b9b", - "reference": "ce37959546cf5e04df02aa41960f3ee816670b9b", + "url": "https://api.github.com/repos/laravel/octane/zipball/d8d432eb1e51a8ab2575854963d94e70d4592e15", + "reference": "d8d432eb1e51a8ab2575854963d94e70d4592e15", "shasum": "" }, "require": { @@ -2258,20 +2265,20 @@ "issues": "https://github.com/laravel/octane/issues", "source": "https://github.com/laravel/octane" }, - "time": "2024-10-01T21:03:50+00:00" + "time": "2024-10-06T21:09:20+00:00" }, { "name": "laravel/prompts", - "version": "v0.3.0", + "version": "v0.3.1", "source": { "type": "git", "url": "https://github.com/laravel/prompts.git", - "reference": "ea57a2261093986721d4a5f4f9524d76f21f9fa0" + "reference": "0f3848a445562dac376b27968f753c65e7e1036e" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/laravel/prompts/zipball/ea57a2261093986721d4a5f4f9524d76f21f9fa0", - "reference": "ea57a2261093986721d4a5f4f9524d76f21f9fa0", + "url": "https://api.github.com/repos/laravel/prompts/zipball/0f3848a445562dac376b27968f753c65e7e1036e", + "reference": "0f3848a445562dac376b27968f753c65e7e1036e", "shasum": "" }, "require": { @@ -2315,9 +2322,9 @@ "description": "Add beautiful and user-friendly forms to your command-line applications.", "support": { "issues": "https://github.com/laravel/prompts/issues", - "source": "https://github.com/laravel/prompts/tree/v0.3.0" + "source": "https://github.com/laravel/prompts/tree/v0.3.1" }, - "time": "2024-09-30T14:27:51+00:00" + "time": "2024-10-09T19:42:26+00:00" }, { "name": "laravel/serializable-closure", @@ -2756,16 +2763,16 @@ }, { "name": "league/csv", - "version": "9.16.0", + "version": "9.18.0", "source": { "type": "git", "url": "https://github.com/thephpleague/csv.git", - "reference": "998280c6c34bd67d8125fdc8b45bae28d761b440" + "reference": "b02d010e4055ae992247f6ffd1e7b103ef2a0790" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/thephpleague/csv/zipball/998280c6c34bd67d8125fdc8b45bae28d761b440", - "reference": "998280c6c34bd67d8125fdc8b45bae28d761b440", + "url": "https://api.github.com/repos/thephpleague/csv/zipball/b02d010e4055ae992247f6ffd1e7b103ef2a0790", + "reference": "b02d010e4055ae992247f6ffd1e7b103ef2a0790", "shasum": "" }, "require": { @@ -2773,17 +2780,16 @@ "php": "^8.1.2" }, "require-dev": { - "doctrine/collections": "^2.2.2", "ext-dom": "*", "ext-xdebug": "*", - "friendsofphp/php-cs-fixer": "^3.57.1", - "phpbench/phpbench": "^1.2.15", - "phpstan/phpstan": "^1.11.1", - "phpstan/phpstan-deprecation-rules": "^1.2.0", + "friendsofphp/php-cs-fixer": "^3.64.0", + "phpbench/phpbench": "^1.3.1", + "phpstan/phpstan": "^1.12.6", + "phpstan/phpstan-deprecation-rules": "^1.2.1", "phpstan/phpstan-phpunit": "^1.4.0", - "phpstan/phpstan-strict-rules": "^1.6.0", - "phpunit/phpunit": "^10.5.16 || ^11.1.3", - "symfony/var-dumper": "^6.4.6 || ^7.0.7" + "phpstan/phpstan-strict-rules": "^1.6.1", + "phpunit/phpunit": "^10.5.16 || ^11.4.1", + "symfony/var-dumper": "^6.4.8 || ^7.1.5" }, "suggest": { "ext-dom": "Required to use the XMLConverter and the HTMLConverter classes", @@ -2801,7 +2807,7 @@ "src/functions_include.php" ], "psr-4": { - "League\\Csv\\": "src" + "League\\Csv\\": "src/" } }, "notification-url": "https://packagist.org/downloads/", @@ -2840,7 +2846,7 @@ "type": "github" } ], - "time": "2024-05-24T11:04:54+00:00" + "time": "2024-10-18T08:14:48+00:00" }, { "name": "league/flysystem", @@ -3030,6 +3036,73 @@ ], "time": "2024-09-21T08:32:55+00:00" }, + { + "name": "masterminds/html5", + "version": "2.9.0", + "source": { + "type": "git", + "url": "https://github.com/Masterminds/html5-php.git", + "reference": "f5ac2c0b0a2eefca70b2ce32a5809992227e75a6" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/Masterminds/html5-php/zipball/f5ac2c0b0a2eefca70b2ce32a5809992227e75a6", + "reference": "f5ac2c0b0a2eefca70b2ce32a5809992227e75a6", + "shasum": "" + }, + "require": { + "ext-dom": "*", + "php": ">=5.3.0" + }, + "require-dev": { + "phpunit/phpunit": "^4.8.35 || ^5.7.21 || ^6 || ^7 || ^8 || ^9" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.7-dev" + } + }, + "autoload": { + "psr-4": { + "Masterminds\\": "src" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Matt Butcher", + "email": "technosophos@gmail.com" + }, + { + "name": "Matt Farina", + "email": "matt@mattfarina.com" + }, + { + "name": "Asmir Mustafic", + "email": "goetas@gmail.com" + } + ], + "description": "An HTML5 parser and serializer.", + "homepage": "http://masterminds.github.io/html5-php", + "keywords": [ + "HTML5", + "dom", + "html", + "parser", + "querypath", + "serializer", + "xml" + ], + "support": { + "issues": "https://github.com/Masterminds/html5-php/issues", + "source": "https://github.com/Masterminds/html5-php/tree/2.9.0" + }, + "time": "2024-03-31T07:05:07+00:00" + }, { "name": "mews/purifier", "version": "3.4.2", @@ -3849,17 +3922,71 @@ "time": "2024-08-07T15:39:19+00:00" }, { - "name": "nikic/php-parser", - "version": "v5.3.0", + "name": "nicmart/tree", + "version": "0.8.0", "source": { "type": "git", - "url": "https://github.com/nikic/PHP-Parser.git", - "reference": "3abf7425cd284141dc5d8d14a9ee444de3345d1a" + "url": "https://github.com/nicmart/Tree.git", + "reference": "8d02952acc9779a2c14f7a9c4ac1650c3dacb545" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/nikic/PHP-Parser/zipball/3abf7425cd284141dc5d8d14a9ee444de3345d1a", - "reference": "3abf7425cd284141dc5d8d14a9ee444de3345d1a", + "url": "https://api.github.com/repos/nicmart/Tree/zipball/8d02952acc9779a2c14f7a9c4ac1650c3dacb545", + "reference": "8d02952acc9779a2c14f7a9c4ac1650c3dacb545", + "shasum": "" + }, + "require": { + "php": "~8.0.0 || ~8.1.0 || ~8.2.0 || ~8.3.0" + }, + "require-dev": { + "ergebnis/composer-normalize": "^2.31.0", + "ergebnis/license": "^2.4.0", + "ergebnis/php-cs-fixer-config": "^6.13.0", + "fakerphp/faker": "^1.23.0", + "infection/infection": "~0.26.19", + "phpunit/phpunit": "^9.6.14", + "psalm/plugin-phpunit": "~0.18.4", + "vimeo/psalm": "^5.16.0" + }, + "type": "library", + "autoload": { + "psr-4": { + "Tree\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Nicolò Martini", + "email": "nicmartnic@gmail.com" + }, + { + "name": "Andreas Möller", + "email": "am@localheinz.com" + } + ], + "description": "A basic but flexible php tree data structure and a fluent tree builder implementation.", + "support": { + "issues": "https://github.com/nicmart/Tree/issues", + "source": "https://github.com/nicmart/Tree/tree/0.8.0" + }, + "time": "2023-12-02T13:24:56+00:00" + }, + { + "name": "nikic/php-parser", + "version": "v5.3.1", + "source": { + "type": "git", + "url": "https://github.com/nikic/PHP-Parser.git", + "reference": "8eea230464783aa9671db8eea6f8c6ac5285794b" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/nikic/PHP-Parser/zipball/8eea230464783aa9671db8eea6f8c6ac5285794b", + "reference": "8eea230464783aa9671db8eea6f8c6ac5285794b", "shasum": "" }, "require": { @@ -3902,38 +4029,37 @@ ], "support": { "issues": "https://github.com/nikic/PHP-Parser/issues", - "source": "https://github.com/nikic/PHP-Parser/tree/v5.3.0" + "source": "https://github.com/nikic/PHP-Parser/tree/v5.3.1" }, - "time": "2024-09-29T13:56:26+00:00" + "time": "2024-10-08T18:51:32+00:00" }, { "name": "nunomaduro/termwind", - "version": "v2.1.0", + "version": "v2.2.0", "source": { "type": "git", "url": "https://github.com/nunomaduro/termwind.git", - "reference": "e5f21eade88689536c0cdad4c3cd75f3ed26e01a" + "reference": "42c84e4e8090766bbd6445d06cd6e57650626ea3" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/nunomaduro/termwind/zipball/e5f21eade88689536c0cdad4c3cd75f3ed26e01a", - "reference": "e5f21eade88689536c0cdad4c3cd75f3ed26e01a", + "url": "https://api.github.com/repos/nunomaduro/termwind/zipball/42c84e4e8090766bbd6445d06cd6e57650626ea3", + "reference": "42c84e4e8090766bbd6445d06cd6e57650626ea3", "shasum": "" }, "require": { "ext-mbstring": "*", "php": "^8.2", - "symfony/console": "^7.0.4" + "symfony/console": "^7.1.5" }, "require-dev": { - "ergebnis/phpstan-rules": "^2.2.0", - "illuminate/console": "^11.1.1", - "laravel/pint": "^1.15.0", - "mockery/mockery": "^1.6.11", - "pestphp/pest": "^2.34.6", - "phpstan/phpstan": "^1.10.66", - "phpstan/phpstan-strict-rules": "^1.5.2", - "symfony/var-dumper": "^7.0.4", + "illuminate/console": "^11.28.0", + "laravel/pint": "^1.18.1", + "mockery/mockery": "^1.6.12", + "pestphp/pest": "^2.36.0", + "phpstan/phpstan": "^1.12.6", + "phpstan/phpstan-strict-rules": "^1.6.1", + "symfony/var-dumper": "^7.1.5", "thecodingmachine/phpstan-strict-rules": "^1.0.0" }, "type": "library", @@ -3976,7 +4102,7 @@ ], "support": { "issues": "https://github.com/nunomaduro/termwind/issues", - "source": "https://github.com/nunomaduro/termwind/tree/v2.1.0" + "source": "https://github.com/nunomaduro/termwind/tree/v2.2.0" }, "funding": [ { @@ -3992,7 +4118,7 @@ "type": "github" } ], - "time": "2024-09-05T15:25:50+00:00" + "time": "2024-10-15T16:15:16+00:00" }, { "name": "nyholm/psr7", @@ -5625,6 +5751,396 @@ }, "time": "2018-08-30T22:45:56+00:00" }, + { + "name": "spatie/browsershot", + "version": "4.3.0", + "source": { + "type": "git", + "url": "https://github.com/spatie/browsershot.git", + "reference": "601f2758191d8c46b2ea587eea935a87da4f39e8" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/spatie/browsershot/zipball/601f2758191d8c46b2ea587eea935a87da4f39e8", + "reference": "601f2758191d8c46b2ea587eea935a87da4f39e8", + "shasum": "" + }, + "require": { + "ext-fileinfo": "*", + "ext-json": "*", + "php": "^8.2", + "spatie/temporary-directory": "^2.0", + "symfony/process": "^6.0|^7.0" + }, + "require-dev": { + "pestphp/pest": "^1.20", + "spatie/image": "^3.6", + "spatie/pdf-to-text": "^1.52", + "spatie/phpunit-snapshot-assertions": "^4.2.3" + }, + "type": "library", + "autoload": { + "psr-4": { + "Spatie\\Browsershot\\": "src" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Freek Van der Herten", + "email": "freek@spatie.be", + "homepage": "https://github.com/freekmurze", + "role": "Developer" + } + ], + "description": "Convert a webpage to an image or pdf using headless Chrome", + "homepage": "https://github.com/spatie/browsershot", + "keywords": [ + "chrome", + "convert", + "headless", + "image", + "pdf", + "puppeteer", + "screenshot", + "webpage" + ], + "support": { + "source": "https://github.com/spatie/browsershot/tree/4.3.0" + }, + "funding": [ + { + "url": "https://github.com/spatie", + "type": "github" + } + ], + "time": "2024-08-22T09:14:07+00:00" + }, + { + "name": "spatie/crawler", + "version": "8.2.3", + "source": { + "type": "git", + "url": "https://github.com/spatie/crawler.git", + "reference": "c659f2fe4954249755990e42394a14d6d847a0a7" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/spatie/crawler/zipball/c659f2fe4954249755990e42394a14d6d847a0a7", + "reference": "c659f2fe4954249755990e42394a14d6d847a0a7", + "shasum": "" + }, + "require": { + "guzzlehttp/guzzle": "^7.3", + "guzzlehttp/psr7": "^2.0", + "illuminate/collections": "^10.0|^11.0", + "nicmart/tree": "^0.8.0", + "php": "^8.1", + "spatie/browsershot": "^3.45|^4.0", + "spatie/robots-txt": "^2.0", + "symfony/dom-crawler": "^6.0|^7.0" + }, + "require-dev": { + "pestphp/pest": "^2.0", + "spatie/ray": "^1.37" + }, + "type": "library", + "autoload": { + "psr-4": { + "Spatie\\Crawler\\": "src" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Freek Van der Herten", + "email": "freek@spatie.be" + } + ], + "description": "Crawl all internal links found on a website", + "homepage": "https://github.com/spatie/crawler", + "keywords": [ + "crawler", + "link", + "spatie", + "website" + ], + "support": { + "issues": "https://github.com/spatie/crawler/issues", + "source": "https://github.com/spatie/crawler/tree/8.2.3" + }, + "funding": [ + { + "url": "https://spatie.be/open-source/support-us", + "type": "custom" + }, + { + "url": "https://github.com/spatie", + "type": "github" + } + ], + "time": "2024-07-31T10:46:19+00:00" + }, + { + "name": "spatie/laravel-package-tools", + "version": "1.16.5", + "source": { + "type": "git", + "url": "https://github.com/spatie/laravel-package-tools.git", + "reference": "c7413972cf22ffdff97b68499c22baa04eddb6a2" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/spatie/laravel-package-tools/zipball/c7413972cf22ffdff97b68499c22baa04eddb6a2", + "reference": "c7413972cf22ffdff97b68499c22baa04eddb6a2", + "shasum": "" + }, + "require": { + "illuminate/contracts": "^9.28|^10.0|^11.0", + "php": "^8.0" + }, + "require-dev": { + "mockery/mockery": "^1.5", + "orchestra/testbench": "^7.7|^8.0", + "pestphp/pest": "^1.22", + "phpunit/phpunit": "^9.5.24", + "spatie/pest-plugin-test-time": "^1.1" + }, + "type": "library", + "autoload": { + "psr-4": { + "Spatie\\LaravelPackageTools\\": "src" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Freek Van der Herten", + "email": "freek@spatie.be", + "role": "Developer" + } + ], + "description": "Tools for creating Laravel packages", + "homepage": "https://github.com/spatie/laravel-package-tools", + "keywords": [ + "laravel-package-tools", + "spatie" + ], + "support": { + "issues": "https://github.com/spatie/laravel-package-tools/issues", + "source": "https://github.com/spatie/laravel-package-tools/tree/1.16.5" + }, + "funding": [ + { + "url": "https://github.com/spatie", + "type": "github" + } + ], + "time": "2024-08-27T18:56:10+00:00" + }, + { + "name": "spatie/laravel-sitemap", + "version": "7.2.1", + "source": { + "type": "git", + "url": "https://github.com/spatie/laravel-sitemap.git", + "reference": "6d3d7637690a9710456a01bacabf5088f93ffe11" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/spatie/laravel-sitemap/zipball/6d3d7637690a9710456a01bacabf5088f93ffe11", + "reference": "6d3d7637690a9710456a01bacabf5088f93ffe11", + "shasum": "" + }, + "require": { + "guzzlehttp/guzzle": "^7.8", + "illuminate/support": "^10.0|^11.0", + "nesbot/carbon": "^2.71|^3.0", + "php": "^8.2", + "spatie/crawler": "^8.0.1", + "spatie/laravel-package-tools": "^1.16.1", + "symfony/dom-crawler": "^6.3.4|^7.0" + }, + "require-dev": { + "mockery/mockery": "^1.6.6", + "orchestra/testbench": "^8.14|^9.0", + "pestphp/pest": "^2.24", + "spatie/pest-plugin-snapshots": "^2.1", + "spatie/phpunit-snapshot-assertions": "^5.1.2", + "spatie/temporary-directory": "^2.2" + }, + "type": "library", + "extra": { + "laravel": { + "providers": [ + "Spatie\\Sitemap\\SitemapServiceProvider" + ] + } + }, + "autoload": { + "psr-4": { + "Spatie\\Sitemap\\": "src" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Freek Van der Herten", + "email": "freek@spatie.be", + "homepage": "https://spatie.be", + "role": "Developer" + } + ], + "description": "Create and generate sitemaps with ease", + "homepage": "https://github.com/spatie/laravel-sitemap", + "keywords": [ + "laravel-sitemap", + "spatie" + ], + "support": { + "source": "https://github.com/spatie/laravel-sitemap/tree/7.2.1" + }, + "funding": [ + { + "url": "https://spatie.be/open-source/support-us", + "type": "custom" + } + ], + "time": "2024-05-21T12:31:34+00:00" + }, + { + "name": "spatie/robots-txt", + "version": "2.2.3", + "source": { + "type": "git", + "url": "https://github.com/spatie/robots-txt.git", + "reference": "31763e5ca23fb0efa6dc6b700beb5ebfeab89432" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/spatie/robots-txt/zipball/31763e5ca23fb0efa6dc6b700beb5ebfeab89432", + "reference": "31763e5ca23fb0efa6dc6b700beb5ebfeab89432", + "shasum": "" + }, + "require": { + "php": "^8.1" + }, + "require-dev": { + "phpunit/phpunit": "^9.0|^10.0" + }, + "type": "library", + "autoload": { + "psr-4": { + "Spatie\\Robots\\": "src" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Brent Roose", + "email": "brent@spatie.be", + "homepage": "https://spatie.be", + "role": "Developer" + } + ], + "description": "Determine if a page may be crawled from robots.txt and robots meta tags", + "homepage": "https://github.com/spatie/robots-txt", + "keywords": [ + "robots-txt", + "spatie" + ], + "support": { + "issues": "https://github.com/spatie/robots-txt/issues", + "source": "https://github.com/spatie/robots-txt/tree/2.2.3" + }, + "funding": [ + { + "url": "https://spatie.be/open-source/support-us", + "type": "custom" + }, + { + "url": "https://github.com/spatie", + "type": "github" + } + ], + "time": "2024-10-22T08:17:03+00:00" + }, + { + "name": "spatie/temporary-directory", + "version": "2.2.1", + "source": { + "type": "git", + "url": "https://github.com/spatie/temporary-directory.git", + "reference": "76949fa18f8e1a7f663fd2eaa1d00e0bcea0752a" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/spatie/temporary-directory/zipball/76949fa18f8e1a7f663fd2eaa1d00e0bcea0752a", + "reference": "76949fa18f8e1a7f663fd2eaa1d00e0bcea0752a", + "shasum": "" + }, + "require": { + "php": "^8.0" + }, + "require-dev": { + "phpunit/phpunit": "^9.5" + }, + "type": "library", + "autoload": { + "psr-4": { + "Spatie\\TemporaryDirectory\\": "src" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Alex Vanderbist", + "email": "alex@spatie.be", + "homepage": "https://spatie.be", + "role": "Developer" + } + ], + "description": "Easily create, use and destroy temporary directories", + "homepage": "https://github.com/spatie/temporary-directory", + "keywords": [ + "php", + "spatie", + "temporary-directory" + ], + "support": { + "issues": "https://github.com/spatie/temporary-directory/issues", + "source": "https://github.com/spatie/temporary-directory/tree/2.2.1" + }, + "funding": [ + { + "url": "https://spatie.be/open-source/support-us", + "type": "custom" + }, + { + "url": "https://github.com/spatie", + "type": "github" + } + ], + "time": "2023-12-25T11:46:58+00:00" + }, { "name": "symfony/clock", "version": "v7.1.1", @@ -5924,6 +6440,73 @@ ], "time": "2024-04-18T09:32:20+00:00" }, + { + "name": "symfony/dom-crawler", + "version": "v7.1.5", + "source": { + "type": "git", + "url": "https://github.com/symfony/dom-crawler.git", + "reference": "b92af238457a7cdd2738f941cd525d76313e8283" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/dom-crawler/zipball/b92af238457a7cdd2738f941cd525d76313e8283", + "reference": "b92af238457a7cdd2738f941cd525d76313e8283", + "shasum": "" + }, + "require": { + "masterminds/html5": "^2.6", + "php": ">=8.2", + "symfony/polyfill-ctype": "~1.8", + "symfony/polyfill-mbstring": "~1.0" + }, + "require-dev": { + "symfony/css-selector": "^6.4|^7.0" + }, + "type": "library", + "autoload": { + "psr-4": { + "Symfony\\Component\\DomCrawler\\": "" + }, + "exclude-from-classmap": [ + "/Tests/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Fabien Potencier", + "email": "fabien@symfony.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Eases DOM navigation for HTML and XML documents", + "homepage": "https://symfony.com", + "support": { + "source": "https://github.com/symfony/dom-crawler/tree/v7.1.5" + }, + "funding": [ + { + "url": "https://symfony.com/sponsor", + "type": "custom" + }, + { + "url": "https://github.com/fabpot", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", + "type": "tidelift" + } + ], + "time": "2024-09-15T06:48:17+00:00" + }, { "name": "symfony/error-handler", "version": "v7.1.3", @@ -8300,6 +8883,43 @@ "issues": "https://lab.s-web.fr/ldc-web/projets/seo-laravel/-/issues" } }, + { + "name": "uwil/sitemap-generator", + "version": "3.0.0", + "source": { + "type": "git", + "url": "git@lab.s-web.fr:ldc-web/projets/sitemap-generator.git", + "reference": "17c4446133a274f64104e06d5184d9d0bca8be32" + }, + "dist": { + "type": "zip", + "url": "https://lab.s-web.fr/api/v4/projects/108/packages/composer/archives/uwil/sitemap-generator.zip?sha=17c4446133a274f64104e06d5184d9d0bca8be32", + "reference": "17c4446133a274f64104e06d5184d9d0bca8be32", + "shasum": "" + }, + "require": { + "illuminate/support": "~11", + "laravel/framework": "~11", + "spatie/laravel-sitemap": "^7.0" + }, + "require-dev": { + "slevomat/coding-standard": "^8.15" + }, + "type": "library", + "extra": { + "laravel": { + "providers": [ + "Uwil\\SitemapGenerator\\SitemapGeneratorServiceProvider" + ] + } + }, + "autoload": { + "psr-4": { + "Uwil\\SitemapGenerator\\": "src/" + } + }, + "description": "Create sitemap.xml" + }, { "name": "uwil/unit-tests-laravel", "version": "1.0.0", @@ -9340,36 +9960,37 @@ }, { "name": "larastan/larastan", - "version": "v2.9.8", + "version": "v2.9.9", "source": { "type": "git", "url": "https://github.com/larastan/larastan.git", - "reference": "340badd89b0eb5bddbc503a4829c08cf9a2819d7" + "reference": "148faa138f0d8acb7d85f4a55693d3e13b6048d2" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/larastan/larastan/zipball/340badd89b0eb5bddbc503a4829c08cf9a2819d7", - "reference": "340badd89b0eb5bddbc503a4829c08cf9a2819d7", + "url": "https://api.github.com/repos/larastan/larastan/zipball/148faa138f0d8acb7d85f4a55693d3e13b6048d2", + "reference": "148faa138f0d8acb7d85f4a55693d3e13b6048d2", "shasum": "" }, "require": { "ext-json": "*", - "illuminate/console": "^9.52.16 || ^10.28.0 || ^11.0", - "illuminate/container": "^9.52.16 || ^10.28.0 || ^11.0", - "illuminate/contracts": "^9.52.16 || ^10.28.0 || ^11.0", - "illuminate/database": "^9.52.16 || ^10.28.0 || ^11.0", - "illuminate/http": "^9.52.16 || ^10.28.0 || ^11.0", - "illuminate/pipeline": "^9.52.16 || ^10.28.0 || ^11.0", - "illuminate/support": "^9.52.16 || ^10.28.0 || ^11.0", + "illuminate/console": "^9.52.16 || ^10.28.0 || ^11.16", + "illuminate/container": "^9.52.16 || ^10.28.0 || ^11.16", + "illuminate/contracts": "^9.52.16 || ^10.28.0 || ^11.16", + "illuminate/database": "^9.52.16 || ^10.28.0 || ^11.16", + "illuminate/http": "^9.52.16 || ^10.28.0 || ^11.16", + "illuminate/pipeline": "^9.52.16 || ^10.28.0 || ^11.16", + "illuminate/support": "^9.52.16 || ^10.28.0 || ^11.16", "php": "^8.0.2", "phpmyadmin/sql-parser": "^5.9.0", - "phpstan/phpstan": "^1.11.2" + "phpstan/phpstan": "^1.12.5" }, "require-dev": { "doctrine/coding-standard": "^12.0", "nikic/php-parser": "^4.19.1", "orchestra/canvas": "^7.11.1 || ^8.11.0 || ^9.0.2", "orchestra/testbench": "^7.33.0 || ^8.13.0 || ^9.0.3", + "phpstan/phpstan-deprecation-rules": "^1.2", "phpunit/phpunit": "^9.6.13 || ^10.5.16" }, "suggest": { @@ -9418,7 +10039,7 @@ ], "support": { "issues": "https://github.com/larastan/larastan/issues", - "source": "https://github.com/larastan/larastan/tree/v2.9.8" + "source": "https://github.com/larastan/larastan/tree/v2.9.9" }, "funding": [ { @@ -9438,7 +10059,7 @@ "type": "patreon" } ], - "time": "2024-07-06T17:46:02+00:00" + "time": "2024-10-15T19:41:22+00:00" }, { "name": "laravel-lang/attributes", @@ -9592,16 +10213,16 @@ }, { "name": "laravel-lang/http-statuses", - "version": "3.8.4", + "version": "3.8.5", "source": { "type": "git", "url": "https://github.com/Laravel-Lang/http-statuses.git", - "reference": "0e8b1af2835f951f5587f6c635ea6b929f275415" + "reference": "d5ddb3c6cfafadb3a2e9d2d5d96d8d11a9130544" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/Laravel-Lang/http-statuses/zipball/0e8b1af2835f951f5587f6c635ea6b929f275415", - "reference": "0e8b1af2835f951f5587f6c635ea6b929f275415", + "url": "https://api.github.com/repos/Laravel-Lang/http-statuses/zipball/d5ddb3c6cfafadb3a2e9d2d5d96d8d11a9130544", + "reference": "d5ddb3c6cfafadb3a2e9d2d5d96d8d11a9130544", "shasum": "" }, "require": { @@ -9653,9 +10274,9 @@ ], "support": { "issues": "https://github.com/Laravel-Lang/http-statuses/issues", - "source": "https://github.com/Laravel-Lang/http-statuses/tree/3.8.4" + "source": "https://github.com/Laravel-Lang/http-statuses/tree/3.8.5" }, - "time": "2024-07-20T18:15:58+00:00" + "time": "2024-09-30T19:56:37+00:00" }, { "name": "laravel-lang/lang", @@ -9892,16 +10513,16 @@ }, { "name": "laravel/sail", - "version": "v1.34.0", + "version": "v1.37.0", "source": { "type": "git", "url": "https://github.com/laravel/sail.git", - "reference": "511e9c95b0f3ee778dc9e11e242bcd2af8e002cd" + "reference": "5d385f2e698f0f774cdead82aff5d989fb95309b" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/laravel/sail/zipball/511e9c95b0f3ee778dc9e11e242bcd2af8e002cd", - "reference": "511e9c95b0f3ee778dc9e11e242bcd2af8e002cd", + "url": "https://api.github.com/repos/laravel/sail/zipball/5d385f2e698f0f774cdead82aff5d989fb95309b", + "reference": "5d385f2e698f0f774cdead82aff5d989fb95309b", "shasum": "" }, "require": { @@ -9951,7 +10572,7 @@ "issues": "https://github.com/laravel/sail/issues", "source": "https://github.com/laravel/sail" }, - "time": "2024-09-27T14:58:09+00:00" + "time": "2024-10-21T17:13:38+00:00" }, { "name": "laravel/telescope", @@ -10107,23 +10728,23 @@ }, { "name": "nunomaduro/collision", - "version": "v8.4.0", + "version": "v8.5.0", "source": { "type": "git", "url": "https://github.com/nunomaduro/collision.git", - "reference": "e7d1aa8ed753f63fa816932bbc89678238843b4a" + "reference": "f5c101b929c958e849a633283adff296ed5f38f5" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/nunomaduro/collision/zipball/e7d1aa8ed753f63fa816932bbc89678238843b4a", - "reference": "e7d1aa8ed753f63fa816932bbc89678238843b4a", + "url": "https://api.github.com/repos/nunomaduro/collision/zipball/f5c101b929c958e849a633283adff296ed5f38f5", + "reference": "f5c101b929c958e849a633283adff296ed5f38f5", "shasum": "" }, "require": { - "filp/whoops": "^2.15.4", - "nunomaduro/termwind": "^2.0.1", + "filp/whoops": "^2.16.0", + "nunomaduro/termwind": "^2.1.0", "php": "^8.2.0", - "symfony/console": "^7.1.3" + "symfony/console": "^7.1.5" }, "conflict": { "laravel/framework": "<11.0.0 || >=12.0.0", @@ -10131,14 +10752,14 @@ }, "require-dev": { "larastan/larastan": "^2.9.8", - "laravel/framework": "^11.19.0", - "laravel/pint": "^1.17.1", - "laravel/sail": "^1.31.0", - "laravel/sanctum": "^4.0.2", - "laravel/tinker": "^2.9.0", - "orchestra/testbench-core": "^9.2.3", - "pestphp/pest": "^2.35.0 || ^3.0.0", - "sebastian/environment": "^6.1.0 || ^7.0.0" + "laravel/framework": "^11.28.0", + "laravel/pint": "^1.18.1", + "laravel/sail": "^1.36.0", + "laravel/sanctum": "^4.0.3", + "laravel/tinker": "^2.10.0", + "orchestra/testbench-core": "^9.5.3", + "pestphp/pest": "^2.36.0 || ^3.4.0", + "sebastian/environment": "^6.1.0 || ^7.2.0" }, "type": "library", "extra": { @@ -10200,7 +10821,7 @@ "type": "patreon" } ], - "time": "2024-08-03T15:32:23+00:00" + "time": "2024-10-15T16:06:32+00:00" }, { "name": "phar-io/manifest", @@ -10409,16 +11030,16 @@ }, { "name": "phpstan/phpdoc-parser", - "version": "1.32.0", + "version": "1.33.0", "source": { "type": "git", "url": "https://github.com/phpstan/phpdoc-parser.git", - "reference": "6ca22b154efdd9e3c68c56f5d94670920a1c19a4" + "reference": "82a311fd3690fb2bf7b64d5c98f912b3dd746140" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phpstan/phpdoc-parser/zipball/6ca22b154efdd9e3c68c56f5d94670920a1c19a4", - "reference": "6ca22b154efdd9e3c68c56f5d94670920a1c19a4", + "url": "https://api.github.com/repos/phpstan/phpdoc-parser/zipball/82a311fd3690fb2bf7b64d5c98f912b3dd746140", + "reference": "82a311fd3690fb2bf7b64d5c98f912b3dd746140", "shasum": "" }, "require": { @@ -10450,22 +11071,22 @@ "description": "PHPDoc parser with support for nullable, intersection and generic types", "support": { "issues": "https://github.com/phpstan/phpdoc-parser/issues", - "source": "https://github.com/phpstan/phpdoc-parser/tree/1.32.0" + "source": "https://github.com/phpstan/phpdoc-parser/tree/1.33.0" }, - "time": "2024-09-26T07:23:32+00:00" + "time": "2024-10-13T11:25:22+00:00" }, { "name": "phpstan/phpstan", - "version": "1.12.6", + "version": "1.12.7", "source": { "type": "git", "url": "https://github.com/phpstan/phpstan.git", - "reference": "dc4d2f145a88ea7141ae698effd64d9df46527ae" + "reference": "dc2b9976bd8b0f84ec9b0e50cc35378551de7af0" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phpstan/phpstan/zipball/dc4d2f145a88ea7141ae698effd64d9df46527ae", - "reference": "dc4d2f145a88ea7141ae698effd64d9df46527ae", + "url": "https://api.github.com/repos/phpstan/phpstan/zipball/dc2b9976bd8b0f84ec9b0e50cc35378551de7af0", + "reference": "dc2b9976bd8b0f84ec9b0e50cc35378551de7af0", "shasum": "" }, "require": { @@ -10510,7 +11131,7 @@ "type": "github" } ], - "time": "2024-10-06T15:03:59+00:00" + "time": "2024-10-18T11:12:07+00:00" }, { "name": "phpunit/php-code-coverage", @@ -10835,16 +11456,16 @@ }, { "name": "phpunit/phpunit", - "version": "10.5.35", + "version": "10.5.37", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/phpunit.git", - "reference": "7ac8b4e63f456046dcb4c9787da9382831a1874b" + "reference": "c7cffa0efa2b70c22366523e6d804c9419eb2400" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/7ac8b4e63f456046dcb4c9787da9382831a1874b", - "reference": "7ac8b4e63f456046dcb4c9787da9382831a1874b", + "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/c7cffa0efa2b70c22366523e6d804c9419eb2400", + "reference": "c7cffa0efa2b70c22366523e6d804c9419eb2400", "shasum": "" }, "require": { @@ -10865,7 +11486,7 @@ "phpunit/php-timer": "^6.0.0", "sebastian/cli-parser": "^2.0.1", "sebastian/code-unit": "^2.0.0", - "sebastian/comparator": "^5.0.2", + "sebastian/comparator": "^5.0.3", "sebastian/diff": "^5.1.1", "sebastian/environment": "^6.1.0", "sebastian/exporter": "^5.1.2", @@ -10916,7 +11537,7 @@ "support": { "issues": "https://github.com/sebastianbergmann/phpunit/issues", "security": "https://github.com/sebastianbergmann/phpunit/security/policy", - "source": "https://github.com/sebastianbergmann/phpunit/tree/10.5.35" + "source": "https://github.com/sebastianbergmann/phpunit/tree/10.5.37" }, "funding": [ { @@ -10932,7 +11553,7 @@ "type": "tidelift" } ], - "time": "2024-09-19T10:52:21+00:00" + "time": "2024-10-19T13:03:41+00:00" }, { "name": "sebastian/cli-parser", @@ -11104,16 +11725,16 @@ }, { "name": "sebastian/comparator", - "version": "5.0.2", + "version": "5.0.3", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/comparator.git", - "reference": "2d3e04c3b4c1e84a5e7382221ad8883c8fbc4f53" + "reference": "a18251eb0b7a2dcd2f7aa3d6078b18545ef0558e" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/comparator/zipball/2d3e04c3b4c1e84a5e7382221ad8883c8fbc4f53", - "reference": "2d3e04c3b4c1e84a5e7382221ad8883c8fbc4f53", + "url": "https://api.github.com/repos/sebastianbergmann/comparator/zipball/a18251eb0b7a2dcd2f7aa3d6078b18545ef0558e", + "reference": "a18251eb0b7a2dcd2f7aa3d6078b18545ef0558e", "shasum": "" }, "require": { @@ -11124,7 +11745,7 @@ "sebastian/exporter": "^5.0" }, "require-dev": { - "phpunit/phpunit": "^10.4" + "phpunit/phpunit": "^10.5" }, "type": "library", "extra": { @@ -11169,7 +11790,7 @@ "support": { "issues": "https://github.com/sebastianbergmann/comparator/issues", "security": "https://github.com/sebastianbergmann/comparator/security/policy", - "source": "https://github.com/sebastianbergmann/comparator/tree/5.0.2" + "source": "https://github.com/sebastianbergmann/comparator/tree/5.0.3" }, "funding": [ { @@ -11177,7 +11798,7 @@ "type": "github" } ], - "time": "2024-08-12T06:03:08+00:00" + "time": "2024-10-18T14:56:07+00:00" }, { "name": "sebastian/complexity", @@ -12644,5 +13265,5 @@ "ext-bcmath": "*" }, "platform-dev": [], - "plugin-api-version": "2.6.0" + "plugin-api-version": "2.3.0" } diff --git a/config/sitemap-generator.php b/config/sitemap-generator.php new file mode 100644 index 00000000..53aa4c1f --- /dev/null +++ b/config/sitemap-generator.php @@ -0,0 +1,97 @@ + [ + * 'homepage', + * ], + */ + 'singlePages' => [ + 'fo.home.show', + 'fo.recruitment.show', + 'fo.legals.show', + 'fo.policies.show', + 'fo.conditions.show', + 'fo.accessibility.show', + 'fo.contact.show', + 'fo.brand.story', + 'fo.brand.saga', + 'fo.news.index', + 'fo.products.index', + 'fo.recipes.index', + 'fo.commitments.index', + 'fo.commitments.brand', + 'fo.commitments.raise', + 'fo.commitments.eat', + 'fo.commitments.life', + 'fo.commitments.respect', + 'fo.breeding.index', + 'fo.breeding.oui-c-est-bon', + 'fo.breeding.sortant-a-l-exterieur', + 'fo.breeders.get-geojson', + 'fo.breeders.get-count-per-department', + 'fo.breeders.get-manageable-text-component', + ], + + /** + * Model namespaces with filters + * + * Ex: + * 'cruds' => [ + * [ + * 'model' => 'App\Models\Product', + * 'filters' => [ + * ['published', '=', true] + * ] + * ], + * [ + * 'model' => 'App\Models\Article', + * 'filters' => [] + * ] + * ], + */ + 'cruds' => [ + [ + 'model' => 'App\Models\Product', + 'filters' => [ + ['published', '=', true] + ], + ], + [ + 'model' => 'App\Models\Recipe', + 'filters' => [ + ['published', '=', true] + ], + ], + [ + 'model' => 'App\Models\News', + 'filters' => [ + ['published', '=', true] + ], + ] + ], + + /** + * Enable or disable schedule for the job + * If set to true the sitemap generator will be run + * using the 'cron' instruction + */ + 'schedule' => true, + + /** + * If you want to set specific + * instruction for when to schedule job + * you can set this with a cron instruction + * You can generate one using https://crontab.guru/ + * + * schedule must be set to true + * + * Default is every day at 15:45 + */ + 'cron' => '45 15 * * *', +]; From bf84a1d7a8dfba352cbffe7137b2cde7ef450b92 Mon Sep 17 00:00:00 2001 From: Alexis Gousseau Date: Thu, 24 Oct 2024 09:46:41 +0000 Subject: [PATCH 5/8] fix: :bug: resolve delete postal code field data when password is updated #199 --- app/Models/Customer.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/app/Models/Customer.php b/app/Models/Customer.php index 5d5e5c7c..5727c483 100644 --- a/app/Models/Customer.php +++ b/app/Models/Customer.php @@ -334,7 +334,9 @@ class Customer extends Authenticatable implements MustVerifyEmail if (!$crmCustomer) { throw new CrmException('CRM get Customer returned null'); } - $data['postcode'] = Arr::get($data, 'postal_code'); + if (isset($data["postal_code"])) { + $data['postcode'] = Arr::get($data, 'postal_code'); + } unset( $data["username"], $data["question_id"], From 51a2bf49b37a07c06ef37ef7a7eb0d9b83786a7d Mon Sep 17 00:00:00 2001 From: Vincent BRIDIER Date: Thu, 24 Oct 2024 11:47:28 +0200 Subject: [PATCH 6/8] feat: Add concurrencyPolicy: Forbid on CronJob in manifest.yaml --- manifest.yaml | 103 +++++++++++++++++++++++++------------------------- 1 file changed, 52 insertions(+), 51 deletions(-) diff --git a/manifest.yaml b/manifest.yaml index da9f175b..1ca0b777 100644 --- a/manifest.yaml +++ b/manifest.yaml @@ -51,7 +51,7 @@ metadata: spec: storageClassName: "csi-cinder-classic" accessModes: - - ReadWriteOnce + - ReadWriteOnce resources: requests: storage: $APP_PVC_SIZE @@ -72,25 +72,25 @@ spec: app: ${CI_PROJECT_PATH_SLUG}-app spec: containers: - - name: ${CI_PROJECT_PATH_SLUG}-container - image: $IMAGE_TAG - envFrom: - - configMapRef: - name: ${CI_PROJECT_PATH_SLUG}-config-map - volumeMounts: - - name: storage - mountPath: /app/srcs/storage + - name: ${CI_PROJECT_PATH_SLUG}-container + image: $IMAGE_TAG + envFrom: + - configMapRef: + name: ${CI_PROJECT_PATH_SLUG}-config-map + volumeMounts: + - name: storage + mountPath: /app/srcs/storage imagePullSecrets: - - name: docker-registry-credentials + - name: docker-registry-credentials securityContext: runAsUser: 33 runAsGroup: 33 fsGroup: 33 fsGroupChangePolicy: "OnRootMismatch" volumes: - - name: storage - persistentVolumeClaim: - claimName: ${CI_PROJECT_PATH_SLUG}-pvc-storage + - name: storage + persistentVolumeClaim: + claimName: ${CI_PROJECT_PATH_SLUG}-pvc-storage --- apiVersion: v1 @@ -101,8 +101,8 @@ spec: selector: app: ${CI_PROJECT_PATH_SLUG}-app ports: - - port: 80 - targetPort: 443 + - port: 80 + targetPort: 443 --- apiVersion: traefik.io/v1alpha1 @@ -111,16 +111,16 @@ metadata: name: ${CI_PROJECT_PATH_SLUG}-ingress-route spec: entryPoints: - - web - - websecure + - web + - websecure routes: - - match: Host(`${APP_DOMAIN}`) || Host(`www.${APP_DOMAIN}`) - kind: Rule - services: - - name: ${CI_PROJECT_PATH_SLUG}-service - port: 80 - middlewares: - - name: redirect-no-www-to-www + - match: Host(`${APP_DOMAIN}`) || Host(`www.${APP_DOMAIN}`) + kind: Rule + services: + - name: ${CI_PROJECT_PATH_SLUG}-service + port: 80 + middlewares: + - name: redirect-no-www-to-www tls: secretName: ${CRT_TLS_NAME} @@ -131,6 +131,7 @@ metadata: name: ${CI_PROJECT_PATH_SLUG}-cronjob spec: schedule: "* * * * *" + concurrencyPolicy: Forbid jobTemplate: spec: template: @@ -138,35 +139,35 @@ spec: affinity: podAffinity: requiredDuringSchedulingIgnoredDuringExecution: - - labelSelector: - matchExpressions: - - key: app - operator: In - values: - - ${CI_PROJECT_PATH_SLUG}-app - topologyKey: "kubernetes.io/hostname" - namespaces: [$KUBE_NAMESPACE] + - labelSelector: + matchExpressions: + - key: app + operator: In + values: + - ${CI_PROJECT_PATH_SLUG}-app + topologyKey: "kubernetes.io/hostname" + namespaces: [$KUBE_NAMESPACE] containers: - - name: ${CI_PROJECT_PATH_SLUG}-scheduled - image: $IMAGE_TAG - imagePullPolicy: IfNotPresent - command: - - "php" - args: - - "artisan" - - "schedule:run" - envFrom: - - configMapRef: - name: ${CI_PROJECT_PATH_SLUG}-config-map - volumeMounts: - - name: storage - mountPath: /app/srcs/storage - imagePullSecrets: - - name: docker-registry-credentials - volumes: + - name: ${CI_PROJECT_PATH_SLUG}-scheduled + image: $IMAGE_TAG + imagePullPolicy: IfNotPresent + command: + - "php" + args: + - "artisan" + - "schedule:run" + envFrom: + - configMapRef: + name: ${CI_PROJECT_PATH_SLUG}-config-map + volumeMounts: - name: storage - persistentVolumeClaim: - claimName: ${CI_PROJECT_PATH_SLUG}-pvc-storage + mountPath: /app/srcs/storage + imagePullSecrets: + - name: docker-registry-credentials + volumes: + - name: storage + persistentVolumeClaim: + claimName: ${CI_PROJECT_PATH_SLUG}-pvc-storage securityContext: runAsUser: 33 runAsGroup: 33 From 1d8aa48d6d67019e0211414ad8f0161c7f48e47c Mon Sep 17 00:00:00 2001 From: Noah Lancien Date: Thu, 24 Oct 2024 10:06:00 +0000 Subject: [PATCH 7/8] fix: Sitemap was broken due to wrong route name for fo.products.show --- app/Models/Product.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/Models/Product.php b/app/Models/Product.php index 6e15901b..0c413f05 100644 --- a/app/Models/Product.php +++ b/app/Models/Product.php @@ -237,7 +237,7 @@ class Product extends Model implements SeoInterface, Sitemapable public function toSitemapTag(): Url | string | array { $model = $this; - $route = 'fo.product.show'; + $route = 'fo.products.show'; $params = ['slug' => $model->slug]; return SitemapHelper::generateUrl($route, $params, $model); } From f0c2949808c88f2aab8413aec969597f61f6f792 Mon Sep 17 00:00:00 2001 From: Alexis Gousseau Date: Thu, 24 Oct 2024 10:06:25 +0000 Subject: [PATCH 8/8] fix: :bug: update optin customer field checked attribute #198 --- .../club/pages/customers/partials/customer-info-form.blade.php | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/resources/views/club/pages/customers/partials/customer-info-form.blade.php b/resources/views/club/pages/customers/partials/customer-info-form.blade.php index 078acd11..7d15cc56 100644 --- a/resources/views/club/pages/customers/partials/customer-info-form.blade.php +++ b/resources/views/club/pages/customers/partials/customer-info-form.blade.php @@ -109,8 +109,7 @@
    opt_in)> + type="checkbox" @checked(old('opt_in', $crmCustomer->opt_in ?? false))>