Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
61 changes: 52 additions & 9 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,13 @@ name: Tests

on:
push:
branches: [main]
branches: [ master ]
pull_request:
branches: [main]
branches: [ master ]

Comment thread
yoerriwalstra marked this conversation as resolved.
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true

jobs:
test:
Expand All @@ -14,14 +18,48 @@ jobs:
strategy:
fail-fast: false
matrix:
php: ["8.2", "8.3"]
laravel: ["9.*", "10.*", "11.*", "12.*"]
exclude:
# Laravel 11+ requires PHP 8.2+, already satisfied here.
# Laravel 9 and 10 are compatible with PHP 8.2 and 8.3.
# No exclusions needed, but keep this block for clarity.
include:
# Laravel 8 — testbench ^6.0 supports PHP 7.3–8.1
- php: "8.1"
laravel: "8.*"
testbench: "^6.0"
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
testbench: "^6.0"
testbench: "^6.0"
allow_insecure: true

Maybe something like this for every insecure version in this matrix and then a conditional step that runs composer config audit.block-insecure false if allow_insecure is true. Or always run it and use the value matrix.allow_insecure. Not sure if the last one is possible though.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oh wait this is exactly what you said.

allow_insecure: true
# Laravel 9 — testbench ^7.0 supports PHP 8.0–8.1
- php: "8.1"
laravel: "9.*"
testbench: "^7.0"
allow_insecure: true
# Laravel 10 — testbench ^8.0 supports PHP 8.1–8.3
- php: "8.1"
laravel: "10.*"
testbench: "^8.0"
allow_insecure: false
- php: "8.2"
laravel: "10.*"
testbench: "^8.0"
allow_insecure: false
- php: "8.3"
laravel: "10.*"
testbench: "^8.0"
allow_insecure: false
# Laravel 11 — testbench ^9.0 supports PHP 8.2–8.3
- php: "8.2"
laravel: "9.*" # Laravel 9 supports PHP 8.0+, valid combo
laravel: "11.*"
testbench: "^9.0"
allow_insecure: false
- php: "8.3"
laravel: "11.*"
testbench: "^9.0"
allow_insecure: false
# Laravel 12 — testbench ^10.0 supports PHP 8.2–8.3
- php: "8.2"
laravel: "12.*"
testbench: "^10.0"
allow_insecure: false
- php: "8.3"
laravel: "12.*"
testbench: "^10.0"
allow_insecure: false

steps:
- name: Checkout
Expand All @@ -34,11 +72,16 @@ jobs:
extensions: mbstring, pdo, pdo_sqlite, sqlite3
coverage: none

- name: Allow insecure packages
if: ${{ matrix.allow_insecure == true }}
run: composer config audit.block-insecure false

- name: Install dependencies
run: |
composer require "illuminate/support:${{ matrix.laravel }}" \
"illuminate/database:${{ matrix.laravel }}" \
"illuminate/console:${{ matrix.laravel }}" \
"orchestra/testbench:${{ matrix.testbench }}" \
--no-update

composer update --prefer-stable --prefer-dist --no-interaction
Expand Down
21 changes: 21 additions & 0 deletions LICENSE.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2026-present Yoeri Walstra & collaborators

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
10 changes: 5 additions & 5 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,13 @@
}
],
"require": {
"php": "^8.2",
"illuminate/console": "^9.0|^10.0|^11.0|^12.0",
"illuminate/database": "^9.0|^10.0|^11.0|^12.0",
"illuminate/support": "^9.0|^10.0|^11.0|^12.0"
"php": "^8.1",
"illuminate/console": "^8.0|^9.0|^10.0|^11.0|^12.0",
"illuminate/database": "^8.0|^9.0|^10.0|^11.0|^12.0",
"illuminate/support": "^8.0|^9.0|^10.0|^11.0|^12.0"
},
"require-dev": {
"orchestra/testbench": "^7.0|^8.0|^9.0|^10.0",
"orchestra/testbench": "^6.0|^7.0|^8.0|^9.0|^10.0",
"phpunit/phpunit": "^9.0|^10.0|^11.0"
},
"autoload": {
Expand Down
4 changes: 2 additions & 2 deletions src/Console/Commands/ResourceCleanupCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ public function handle(): int
if ($this->option('dry-run')) {
$count = $query->count();

$this->line(sprintf(' [dry-run] %s: %d record(s) would be deleted.', $modelClass, $count));
$this->line(sprintf('[dry-run] %s: %d record(s) would be deleted.', $modelClass, $count));

$totalDeleted += $count;

Expand All @@ -61,7 +61,7 @@ public function handle(): int
}
});

$this->line(sprintf(' %s: %d record(s) deleted.', $modelClass, $deleted));
$this->line(sprintf('%s: %d record(s) deleted.', $modelClass, $deleted));

$totalDeleted += $deleted;
}
Expand Down
11 changes: 6 additions & 5 deletions tests/Feature/ResourceCleanupCommandTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public function test_dry_run(): void
TestResource::create(['name' => 'recent']);

$this->artisan('resource-cleanup:run --dry-run')
->expectsOutputToContain('3 record(s) would be deleted')
->expectsOutput('[dry-run] ' . TestResource::class . ': 3 record(s) would be deleted.')
->assertSuccessful();

// No records should have been deleted
Expand All @@ -40,7 +40,8 @@ public function test_resource_cleanup_all_configured_models(): void
TestResource::create(['name' => 'recent']);

$this->artisan('resource-cleanup:run')
->expectsOutputToContain('3 record(s) deleted')
->expectsOutput(TestResource::class . ': 3 record(s) deleted.')
->expectsOutput('Done. Total: 3 record(s) deleted.')
->assertSuccessful();

$this->assertSame(0, TestResource::withTrashed()->where('name', 'like', 'old-%')->count());
Expand All @@ -58,7 +59,7 @@ public function test_resource_cleanup_valid_model_options(): void
TestResource::create(['name' => 'old', 'created_at' => $old])->delete();

$this->artisan('resource-cleanup:run', ['--model' => [TestResource::class]])
->expectsOutputToContain(TestResource::class)
->expectsOutput(TestResource::class . ': 1 record(s) deleted.')
->assertSuccessful();
}

Expand Down Expand Up @@ -105,7 +106,7 @@ public function test_resource_cleanup_fails_without_configured_models(): void
$this->app['config']->set('resource-cleanup.models', []);

$this->artisan('resource-cleanup:run')
->expectsOutputToContain('No cleanable models defined')
->expectsOutput('No cleanable models defined. Add class-strings to resource-cleanup.models in your config, e.g. App\\Models\\YourModel.')
->assertFailed();
}

Expand All @@ -114,7 +115,7 @@ public function test_resource_cleanup_fails_with_invalid_model_options(): void
$this->app['config']->set('resource-cleanup.models', [TestResource::class]);

$this->artisan('resource-cleanup:run', ['--model' => ['App\\Models\\NonExistent']])
->expectsOutputToContain('Invalid model options specified')
->expectsOutput("Invalid model options specified. Valid models are: \n" . TestResource::class)
->assertFailed();
}
}
Loading