Skip to content

Commit f143163

Browse files
Upgrade laravel backup 9 + laravel 12
1 parent 17f6523 commit f143163

File tree

8 files changed

+42
-36
lines changed

8 files changed

+42
-36
lines changed

.claude/settings.local.json

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{
2+
"permissions": {
3+
"allow": [
4+
"Bash(./vendor/bin/phpunit --migrate-configuration)",
5+
"Bash(./vendor/bin/phpunit --display-all-issues)"
6+
]
7+
},
8+
"enableAllProjectMcpServers": false
9+
}

.github/workflows/test.yml

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,14 @@ name: Run tests
22

33
on:
44
push:
5-
schedule:
6-
- cron: '0 0 * * *'
75

86
jobs:
97
test:
108
runs-on: ubuntu-latest
119

1210
services:
1311
mysql:
14-
image: mysql:5.7
12+
image: mysql:8.0
1513
env:
1614
MYSQL_DATABASE: laravel_backup_sql_check
1715
MYSQL_ROOT_PASSWORD: root
@@ -22,15 +20,15 @@ jobs:
2220
strategy:
2321
fail-fast: false
2422
matrix:
25-
php: [8.0,8.1]
26-
laravel: [8.*,9.*]
27-
dependency-version: [prefer-lowest,prefer-stable]
23+
php: [8.2, 8.3, 8.4]
24+
laravel: [10.*, 11.*, 12.*]
25+
dependency-version: [prefer-lowest, prefer-stable]
2826

2927
name: P${{ matrix.php }} - L${{ matrix.laravel }} - ${{ matrix.dependency-version }}
3028

3129
steps:
3230
- name: Checkout code
33-
uses: actions/checkout@v1
31+
uses: actions/checkout@v4
3432

3533
- name: Setup PHP
3634
uses: shivammathur/setup-php@v2

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,5 @@ composer.phar
33
composer.lock
44
vendor
55
.env
6-
.phpunit.result.cache
6+
.phpunit.result.cache
7+
.phpunit.cache

composer.json

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,15 @@
22
"name": "makeabledk/laravel-backup-sql-check",
33
"license": "CC-BY-SA-4.0",
44
"require": {
5-
"php": "^8.0",
6-
"symfony/process": "^5.0|^6.0"
5+
"php": "^8.2",
6+
"symfony/process": "^6.0|^7.0"
77
},
88
"require-dev": {
9-
"spatie/laravel-backup": "^7.0|^8.0",
10-
"laravel/laravel": "^8.6.10|^9.0",
11-
"phpunit/phpunit": "^9.0",
12-
"orchestra/testbench": "^6.0",
13-
"mockery/mockery": "^1.5"
9+
"spatie/laravel-backup": "^9.0",
10+
"laravel/laravel": "^10.0|^11.0|^12.0",
11+
"phpunit/phpunit": "^10.0|^11.0",
12+
"orchestra/testbench": "^8.0|^9.0|^10.0",
13+
"mockery/mockery": "^1.6"
1414
},
1515
"autoload": {
1616
"psr-4": {

phpunit.xml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,5 @@
11
<?xml version="1.0" encoding="UTF-8"?>
2-
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" backupGlobals="false" backupStaticAttributes="false" bootstrap="vendor/autoload.php" colors="true" convertErrorsToExceptions="true" convertNoticesToExceptions="true" convertWarningsToExceptions="true" processIsolation="false" stopOnFailure="false" xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.3/phpunit.xsd">
3-
<coverage>
4-
<include>
5-
<directory suffix=".php">src/</directory>
6-
</include>
7-
</coverage>
2+
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" backupGlobals="false" bootstrap="vendor/autoload.php" colors="true" processIsolation="false" stopOnFailure="false" xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/11.5/phpunit.xsd" cacheDirectory=".phpunit.cache" backupStaticProperties="false">
83
<testsuites>
94
<testsuite name="Package Test Suite">
105
<directory suffix="Test.php">./tests/</directory>
@@ -13,4 +8,9 @@
138
<php>
149
<ini name="display_errors" value="1"/>
1510
</php>
11+
<source>
12+
<include>
13+
<directory suffix=".php">src/</directory>
14+
</include>
15+
</source>
1616
</phpunit>

src/HealthySqlDump.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ public function __construct(float $timeout = 60)
3636
* @throws \Spatie\Backup\Exceptions\InvalidHealthCheck
3737
* @throws \Throwable
3838
*/
39-
public function checkHealth(BackupDestination $backupDestination)
39+
public function checkHealth(BackupDestination $backupDestination): void
4040
{
4141
$this->failsOnEmpty($newestBackup = $backupDestination->backups()->newest());
4242

tests/Feature/HealthySqlDumpTest.php

Lines changed: 10 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
use Makeable\SqlCheck\DiskSpace;
1010
use Makeable\SqlCheck\HealthySqlDump;
1111
use Makeable\SqlCheck\Tests\TestCase;
12+
use PHPUnit\Framework\Attributes\Test;
1213
use Spatie\Backup\Events\HealthyBackupWasFound;
1314
use Spatie\Backup\Events\UnhealthyBackupWasFound;
1415

@@ -29,51 +30,47 @@ public function setUp(): void
2930
]);
3031
}
3132

32-
/** @test */
33+
#[Test]
3334
public function it_succeeds_when_file_is_healthy()
3435
{
3536
Event::fake(HealthyBackupWasFound::class);
3637
Event::listen(UnhealthyBackupWasFound::class, function ($event) {
3738
throw $event->backupDestinationStatus->getHealthCheckFailure()->exception();
3839
});
3940

40-
$this->artisan('backup:monitor')->assertExitCode(0);
41-
41+
$exitCode = Artisan::call('backup:monitor');
42+
$this->assertEquals(0, $exitCode);
4243
Event::assertDispatched(HealthyBackupWasFound::class);
4344
}
4445

45-
/** @test */
46+
#[Test]
4647
public function it_fails_when_backup_is_corrupt()
4748
{
4849
config()->set('backup.monitor_backups.0.name', 'unhealthy');
4950

5051
Event::fake();
5152

5253
Artisan::call('backup:monitor');
53-
54+
$this->assertStringContainsString('are considered unhealthy!', Artisan::output());
5455
Event::assertDispatched(UnhealthyBackupWasFound::class);
55-
56-
$this->assertStringContainsString('unhealthy!', Artisan::output());
5756
}
5857

59-
/** @test */
58+
#[Test]
6059
public function it_fails_when_sql_process_exceed_the_timeout_limit()
6160
{
6261
config()->set('backup.monitor_backups.0.health_checks', [HealthySqlDump::class => 0.01]);
6362

6463
Event::fake(UnhealthyBackupWasFound::class);
6564

6665
Artisan::call('backup:monitor');
67-
66+
$this->assertStringContainsString('are considered unhealthy!', Artisan::output());
6867
Event::assertDispatched(UnhealthyBackupWasFound::class);
6968

70-
$this->assertStringContainsString('unhealthy!', Artisan::output());
71-
7269
// Manually remove database, because error exited code before deleting it
73-
DB::select('DROP DATABASE `healthy-sql-dump--backup--mysite-2019-09-16-08-00-07`');
70+
DB::statement('DROP DATABASE `healthy-sql-dump--backup--mysite-2019-09-16-08-00-07`');
7471
}
7572

76-
/** @test */
73+
#[Test]
7774
public function it_fails_on_insufficient_disk_space()
7875
{
7976
app()->bind(DiskSpace::class, function () {

tests/TestCase.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
class TestCase extends Orchestra
1010
{
1111
/**
12-
* @param \Illuminate\Foundation\Application $app
12+
* @param \Illuminate\Foundation\Application $app
1313
* @return array
1414
*/
1515
protected function getPackageProviders($app)
@@ -25,6 +25,7 @@ protected function getEnvironmentSetUp($app)
2525
$app->useEnvironmentPath(__DIR__.'/..');
2626
$app->bootstrapWith([LoadEnvironmentVariables::class]);
2727

28+
config()->set('database.default', 'mysql');
2829
config()->set('database.connections.mysql.host', env('DB_HOST'));
2930
config()->set('database.connections.mysql.username', env('DB_USERNAME'));
3031
config()->set('database.connections.mysql.password', env('DB_PASSWORD'));

0 commit comments

Comments
 (0)