From 63f8d4ee0d55a3c36f37373036b8632243f3195b Mon Sep 17 00:00:00 2001 From: enricodelazzari Date: Wed, 2 Oct 2024 16:09:24 +0200 Subject: [PATCH 1/9] wip --- .phpunit.cache/test-results | 1 + composer.json | 25 ++++++------- phpunit.xml.dist | 58 +++++++++++------------------ tests/Datasets/MassPrunableUser.php | 10 +++++ tests/MassPrunableFieldsTest.php | 2 +- 5 files changed, 44 insertions(+), 52 deletions(-) create mode 100644 .phpunit.cache/test-results diff --git a/.phpunit.cache/test-results b/.phpunit.cache/test-results new file mode 100644 index 0000000..271f299 --- /dev/null +++ b/.phpunit.cache/test-results @@ -0,0 +1 @@ +{"version":"pest_2.35.1","defects":{"P\\Tests\\MassPrunableFieldsTest::__pest_evaluable_should_update_mass_prunable_models#(Closure) \/ (Closure)":8,"P\\Tests\\MassPrunableFieldsTest::__pest_evaluable_should_update_mass_prunable_models#('user_with_mass_prunable_fields') #2":8,"P\\Tests\\MassPrunableFieldsTest::__pest_evaluable_should_update_mass_prunable_models#('user_with_mass_prunable_fields') #1":8,"P\\Tests\\MassPrunableFieldsTest::__pest_evaluable_should_update_mass_prunable_models#('user_with_mass_prunable_fields')":8,"P\\Tests\\MassPrunableFieldsTest::__pest_evaluable_should_update_mass_prunable_models#('user_without_mass_prunable_fields')":8},"times":{"P\\Tests\\PrunableFieldsTest::__pest_evaluable_should_fire_model_updated_events#(Closure)":0.01,"P\\Tests\\PrunableFieldsTest::__pest_evaluable_should_not_update_non_prunable_models#(Closure)":0.002,"P\\Tests\\PrunableFieldsTest::__pest_evaluable_should_update_prunable_models#(Closure)":0.005,"P\\Tests\\PrunableFieldsTest::__pest_evaluable_should_fire_ModelsFieldsPruned_event_with_prunable_model#(Closure)":0.01,"P\\Tests\\PrunableFieldsTest::__pest_evaluable_should_allow_the_prunable_models_to_be_overridden_at_runtime#(Closure)":0.025,"P\\Tests\\PrunableFieldsTest::__pest_evaluable_should_call_the_pruningFields_method#(Closure)":0.01,"P\\Tests\\PruneFieldsCommandTest::__pest_evaluable_should_print_the_amount_of_pruned_records#(Closure)":0.012,"P\\Tests\\PruneFieldsCommandTest::__pest_evaluable_should_print_no_records_have_been_pruned#(Closure)":0.001,"P\\Tests\\PruneFieldsCommandTest::__pest_evaluable_should_print_the_amount_of_prunable_records#(Closure)":0.003,"P\\Tests\\PruneFieldsCommandTest::__pest_evaluable_should_print_no_models_found_with_empty_list":0.001,"P\\Tests\\MassPrunableFieldsTest::__pest_evaluable_should_update_mass_prunable_models#(Closure) \/ (Closure)":0.009,"P\\Tests\\MassPrunableFieldsTest::__pest_evaluable_should_fire_ModelsFieldsPruned_event_with_mass_prunable_model#(Closure)":0.021,"P\\Tests\\MassPrunableFieldsTest::__pest_evaluable_should_not_fire_model_updated_events#(Closure)":0.002,"P\\Tests\\MassPrunableFieldsTest::__pest_evaluable_should_not_update_non_prunable_models#(Closure)":0.16,"P\\Tests\\MassPrunableFieldsTest::__pest_evaluable_should_update_mass_prunable_models#(Closure)":0.002,"P\\Tests\\MassPrunableFieldsTest::__pest_evaluable_should_update_mass_prunable_models#('user_with_mass_prunable_fields') #2":0.005,"P\\Tests\\MassPrunableFieldsTest::__pest_evaluable_should_update_mass_prunable_models#('user_with_mass_prunable_fields') #1":0.001,"P\\Tests\\MassPrunableFieldsTest::__pest_evaluable_should_update_mass_prunable_models#('user_with_mass_prunable_fields')":0.006,"P\\Tests\\MassPrunableFieldsTest::__pest_evaluable_should_update_mass_prunable_models#('user_without_mass_prunable_fields')":0,"P\\Tests\\MassPrunableFieldsTest::__pest_evaluable_should_update_mass_prunable_models#(Closure) #2":0.002,"P\\Tests\\MassPrunableFieldsTest::__pest_evaluable_should_update_mass_prunable_models#(Closure) #1":0.001}} \ No newline at end of file diff --git a/composer.json b/composer.json index 66fab0f..cb06613 100644 --- a/composer.json +++ b/composer.json @@ -18,23 +18,20 @@ ], "require": { "php": "^8.0", - "illuminate/console": "^9.0|^10.0", - "illuminate/database": "^9.0|^10.0", - "illuminate/events": "^9.0|^10.0", - "illuminate/support": "^9.0|^10.0", + "illuminate/console": "^9.0|^10.0|^11.0", + "illuminate/database": "^9.0|^10.0|^11.0", + "illuminate/events": "^9.0|^10.0|^11.0", + "illuminate/support": "^9.0|^10.0|^11.0", "spatie/laravel-package-tools": "^1.14.1" }, "require-dev": { - "friendsofphp/php-cs-fixer": "^3.8", - "nunomaduro/collision": "^6.0", - "nunomaduro/larastan": "^2.0.1", - "orchestra/testbench": "^7.0|^8.0", - "pestphp/pest": "^1.21", - "pestphp/pest-plugin-laravel": "^1.1", - "phpstan/extension-installer": "^1.1", - "phpstan/phpstan-deprecation-rules": "^1.0", - "phpstan/phpstan-phpunit": "^1.0", - "phpunit/phpunit": "^9.5" + "nunomaduro/collision": "^6.0|^7.8|^8.1", + "larastan/larastan": "^2.0.1", + "orchestra/testbench": "^7.0|^8.0|^9.0", + "pestphp/pest": "^1.21|^2.34", + "pestphp/pest-plugin-laravel": "^1.1|^2.3", + "phpstan/extension-installer": "^1.3", + "phpstan/phpstan-phpunit": "^1.3" }, "autoload": { "psr-4": { diff --git a/phpunit.xml.dist b/phpunit.xml.dist index 290f954..10a8150 100644 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -1,39 +1,23 @@ - - - - tests - - - - - ./src - - - - - - - - - - + + + + tests + + + + + + + + + + + + + + + ./src + + diff --git a/tests/Datasets/MassPrunableUser.php b/tests/Datasets/MassPrunableUser.php index febdf9e..39c970a 100644 --- a/tests/Datasets/MassPrunableUser.php +++ b/tests/Datasets/MassPrunableUser.php @@ -8,6 +8,16 @@ ]); }); +dataset('users_with_mass_prunable_fields', function () { + yield fn () => MassPrunableUser::factory()->create([ + 'created_at' => now()->subMonth(), + ]); + + yield fn () => MassPrunableUser::factory()->create([ + 'created_at' => now()->subMonth(), + ]); +}); + dataset('user_without_mass_prunable_fields', function () { yield fn () => MassPrunableUser::factory()->create(); }); diff --git a/tests/MassPrunableFieldsTest.php b/tests/MassPrunableFieldsTest.php index 0f99d86..ccb10f2 100644 --- a/tests/MassPrunableFieldsTest.php +++ b/tests/MassPrunableFieldsTest.php @@ -16,7 +16,7 @@ 'last_name' => null, 'email' => $model->email, ]); -})->with('user_with_mass_prunable_fields', 'user_with_mass_prunable_fields'); +})->with('users_with_mass_prunable_fields'); test('should not update non prunable models', function (MassPrunableUser $model) { pruneFields([ From 4f9e46f76f2ebd739c789e9ed652fdbe3fe860c2 Mon Sep 17 00:00:00 2001 From: enricodelazzari Date: Wed, 2 Oct 2024 16:11:34 +0200 Subject: [PATCH 2/9] wip --- .phpunit.cache/test-results | 1 - 1 file changed, 1 deletion(-) delete mode 100644 .phpunit.cache/test-results diff --git a/.phpunit.cache/test-results b/.phpunit.cache/test-results deleted file mode 100644 index 271f299..0000000 --- a/.phpunit.cache/test-results +++ /dev/null @@ -1 +0,0 @@ -{"version":"pest_2.35.1","defects":{"P\\Tests\\MassPrunableFieldsTest::__pest_evaluable_should_update_mass_prunable_models#(Closure) \/ (Closure)":8,"P\\Tests\\MassPrunableFieldsTest::__pest_evaluable_should_update_mass_prunable_models#('user_with_mass_prunable_fields') #2":8,"P\\Tests\\MassPrunableFieldsTest::__pest_evaluable_should_update_mass_prunable_models#('user_with_mass_prunable_fields') #1":8,"P\\Tests\\MassPrunableFieldsTest::__pest_evaluable_should_update_mass_prunable_models#('user_with_mass_prunable_fields')":8,"P\\Tests\\MassPrunableFieldsTest::__pest_evaluable_should_update_mass_prunable_models#('user_without_mass_prunable_fields')":8},"times":{"P\\Tests\\PrunableFieldsTest::__pest_evaluable_should_fire_model_updated_events#(Closure)":0.01,"P\\Tests\\PrunableFieldsTest::__pest_evaluable_should_not_update_non_prunable_models#(Closure)":0.002,"P\\Tests\\PrunableFieldsTest::__pest_evaluable_should_update_prunable_models#(Closure)":0.005,"P\\Tests\\PrunableFieldsTest::__pest_evaluable_should_fire_ModelsFieldsPruned_event_with_prunable_model#(Closure)":0.01,"P\\Tests\\PrunableFieldsTest::__pest_evaluable_should_allow_the_prunable_models_to_be_overridden_at_runtime#(Closure)":0.025,"P\\Tests\\PrunableFieldsTest::__pest_evaluable_should_call_the_pruningFields_method#(Closure)":0.01,"P\\Tests\\PruneFieldsCommandTest::__pest_evaluable_should_print_the_amount_of_pruned_records#(Closure)":0.012,"P\\Tests\\PruneFieldsCommandTest::__pest_evaluable_should_print_no_records_have_been_pruned#(Closure)":0.001,"P\\Tests\\PruneFieldsCommandTest::__pest_evaluable_should_print_the_amount_of_prunable_records#(Closure)":0.003,"P\\Tests\\PruneFieldsCommandTest::__pest_evaluable_should_print_no_models_found_with_empty_list":0.001,"P\\Tests\\MassPrunableFieldsTest::__pest_evaluable_should_update_mass_prunable_models#(Closure) \/ (Closure)":0.009,"P\\Tests\\MassPrunableFieldsTest::__pest_evaluable_should_fire_ModelsFieldsPruned_event_with_mass_prunable_model#(Closure)":0.021,"P\\Tests\\MassPrunableFieldsTest::__pest_evaluable_should_not_fire_model_updated_events#(Closure)":0.002,"P\\Tests\\MassPrunableFieldsTest::__pest_evaluable_should_not_update_non_prunable_models#(Closure)":0.16,"P\\Tests\\MassPrunableFieldsTest::__pest_evaluable_should_update_mass_prunable_models#(Closure)":0.002,"P\\Tests\\MassPrunableFieldsTest::__pest_evaluable_should_update_mass_prunable_models#('user_with_mass_prunable_fields') #2":0.005,"P\\Tests\\MassPrunableFieldsTest::__pest_evaluable_should_update_mass_prunable_models#('user_with_mass_prunable_fields') #1":0.001,"P\\Tests\\MassPrunableFieldsTest::__pest_evaluable_should_update_mass_prunable_models#('user_with_mass_prunable_fields')":0.006,"P\\Tests\\MassPrunableFieldsTest::__pest_evaluable_should_update_mass_prunable_models#('user_without_mass_prunable_fields')":0,"P\\Tests\\MassPrunableFieldsTest::__pest_evaluable_should_update_mass_prunable_models#(Closure) #2":0.002,"P\\Tests\\MassPrunableFieldsTest::__pest_evaluable_should_update_mass_prunable_models#(Closure) #1":0.001}} \ No newline at end of file From 04d05913b982a4ce70c6be32c79855224bbfbddd Mon Sep 17 00:00:00 2001 From: enricodelazzari Date: Wed, 2 Oct 2024 16:12:06 +0200 Subject: [PATCH 3/9] wip --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index 9a43686..52f505a 100644 --- a/.gitignore +++ b/.gitignore @@ -12,3 +12,4 @@ testbench.yaml vendor node_modules .php-cs-fixer.cache +.phpunit.cache From e28fc229e42cac28d164f4ce844d225c34ad34a5 Mon Sep 17 00:00:00 2001 From: enricodelazzari Date: Wed, 2 Oct 2024 16:13:04 +0200 Subject: [PATCH 4/9] wip --- .github/workflows/run-tests.yml | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/.github/workflows/run-tests.yml b/.github/workflows/run-tests.yml index 59d59f1..4ee19c7 100644 --- a/.github/workflows/run-tests.yml +++ b/.github/workflows/run-tests.yml @@ -14,9 +14,11 @@ jobs: matrix: os: [ubuntu-latest, windows-latest] php: [8.3, 8.2, 8.1, 8.0] - laravel: [10.*, 9.*] + laravel: [11.*, 10.*, 9.*] stability: [prefer-lowest, prefer-stable] include: + - laravel: 11.* + testbench: 9.* - laravel: 10.* testbench: 8.* carbon: ^2.63 @@ -24,6 +26,10 @@ jobs: testbench: 7.* carbon: ^2.63 exclude: + - laravel: 11.* + php: 8.1 + - laravel: 11.* + php: 8.0 - laravel: 10.* php: 8.0 From a5d8327e56285182af1a6a41371145fa778957f9 Mon Sep 17 00:00:00 2001 From: enricodelazzari Date: Wed, 2 Oct 2024 16:13:39 +0200 Subject: [PATCH 5/9] wip --- .github/workflows/run-tests.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/run-tests.yml b/.github/workflows/run-tests.yml index 4ee19c7..255dac2 100644 --- a/.github/workflows/run-tests.yml +++ b/.github/workflows/run-tests.yml @@ -19,6 +19,7 @@ jobs: include: - laravel: 11.* testbench: 9.* + carbon: ^2.63 - laravel: 10.* testbench: 8.* carbon: ^2.63 From 8863e2b14903e960e0bea6cac0d1d3a5f60cb4ff Mon Sep 17 00:00:00 2001 From: enricodelazzari Date: Wed, 2 Oct 2024 16:17:12 +0200 Subject: [PATCH 6/9] wip --- .github/workflows/run-tests.yml | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/.github/workflows/run-tests.yml b/.github/workflows/run-tests.yml index 255dac2..87da2ac 100644 --- a/.github/workflows/run-tests.yml +++ b/.github/workflows/run-tests.yml @@ -19,13 +19,10 @@ jobs: include: - laravel: 11.* testbench: 9.* - carbon: ^2.63 - laravel: 10.* testbench: 8.* - carbon: ^2.63 - laravel: 9.* testbench: 7.* - carbon: ^2.63 exclude: - laravel: 11.* php: 8.1 @@ -54,7 +51,7 @@ jobs: - name: Install dependencies run: | - composer require "laravel/framework:${{ matrix.laravel }}" "orchestra/testbench:${{ matrix.testbench }}" "nesbot/carbon:${{ matrix.carbon }}" --no-interaction --no-update + composer require "laravel/framework:${{ matrix.laravel }}" "orchestra/testbench:${{ matrix.testbench }}" --no-interaction --no-update composer update --${{ matrix.stability }} --prefer-dist --no-interaction - name: Execute tests From dff6150a85527357dc3812377249a04025691628 Mon Sep 17 00:00:00 2001 From: enricodelazzari Date: Wed, 2 Oct 2024 16:19:37 +0200 Subject: [PATCH 7/9] wip --- .github/workflows/run-tests.yml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/.github/workflows/run-tests.yml b/.github/workflows/run-tests.yml index 87da2ac..8d2a7dd 100644 --- a/.github/workflows/run-tests.yml +++ b/.github/workflows/run-tests.yml @@ -19,10 +19,13 @@ jobs: include: - laravel: 11.* testbench: 9.* + carbon: ^3.* - laravel: 10.* testbench: 8.* + carbon: ^2.63 - laravel: 9.* testbench: 7.* + carbon: ^2.63 exclude: - laravel: 11.* php: 8.1 @@ -51,7 +54,7 @@ jobs: - name: Install dependencies run: | - composer require "laravel/framework:${{ matrix.laravel }}" "orchestra/testbench:${{ matrix.testbench }}" --no-interaction --no-update + composer require "laravel/framework:${{ matrix.laravel }}" "orchestra/testbench:${{ matrix.testbench }}" "nesbot/carbon:${{ matrix.carbon }}" --no-interaction --no-update composer update --${{ matrix.stability }} --prefer-dist --no-interaction - name: Execute tests From 08c84e0b61beb271ac5abebc65ef1ea226396bc8 Mon Sep 17 00:00:00 2001 From: enricodelazzari Date: Wed, 2 Oct 2024 16:20:57 +0200 Subject: [PATCH 8/9] wip --- .github/workflows/run-tests.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/run-tests.yml b/.github/workflows/run-tests.yml index 8d2a7dd..78a6c65 100644 --- a/.github/workflows/run-tests.yml +++ b/.github/workflows/run-tests.yml @@ -19,7 +19,7 @@ jobs: include: - laravel: 11.* testbench: 9.* - carbon: ^3.* + carbon: ^3.0 - laravel: 10.* testbench: 8.* carbon: ^2.63 From b534b1d64fae3e53b7611153ad99c59958b548dd Mon Sep 17 00:00:00 2001 From: enricodelazzari Date: Wed, 2 Oct 2024 16:44:17 +0200 Subject: [PATCH 9/9] wip --- .gitignore | 3 +-- LICENSE.md | 2 +- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/.gitignore b/.gitignore index 52f505a..6127d06 100644 --- a/.gitignore +++ b/.gitignore @@ -1,7 +1,7 @@ .idea .php_cs .php_cs.cache -.phpunit.result.cache +.phpunit.cache build composer.lock coverage @@ -12,4 +12,3 @@ testbench.yaml vendor node_modules .php-cs-fixer.cache -.phpunit.cache diff --git a/LICENSE.md b/LICENSE.md index 43c44ab..3b09b56 100644 --- a/LICENSE.md +++ b/LICENSE.md @@ -1,6 +1,6 @@ The MIT License (MIT) -Copyright (c) 2023 MAIZE SRL +Copyright (c) 2024 MAIZE SRL Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal