diff --git a/src/Checks/Checks/BackupsCheck.php b/src/Checks/Checks/BackupsCheck.php index 01b63785..04e363fc 100644 --- a/src/Checks/Checks/BackupsCheck.php +++ b/src/Checks/Checks/BackupsCheck.php @@ -20,8 +20,8 @@ class BackupsCheck extends Check protected int $minimumSizeInMegabytes = 0; protected ?int $minimumNumberOfBackups = null; - protected ?int $maximumNumberOfBackups = null; + protected ?int $maximumNumberOfBackups = null; public function locatedAt(string $globPath): self { @@ -51,7 +51,7 @@ public function atLeastSizeInMb(int $minimumSizeInMegabytes): self return $this; } - public function numberOfBackups(int $min = null, int $max = null): self + public function numberOfBackups(?int $min = null, ?int $max = null): self { $this->minimumNumberOfBackups = $min; $this->maximumNumberOfBackups = $max; diff --git a/tests/Checks/BackupsCheckTest.php b/tests/Checks/BackupsCheckTest.php index fdd3a329..16192dfa 100644 --- a/tests/Checks/BackupsCheckTest.php +++ b/tests/Checks/BackupsCheckTest.php @@ -4,9 +4,10 @@ use Spatie\Health\Enums\Status; use Spatie\Health\Facades\Health; use Spatie\TemporaryDirectory\TemporaryDirectory; + use function Spatie\PestPluginTestTime\testTime; -beforeEach(function() { +beforeEach(function () { $this->backupsCheck = BackupsCheck::new(); Health::checks([ @@ -19,7 +20,7 @@ }); -it('it will succeed if a file with the given glob exist', function() { +it('it will succeed if a file with the given glob exist', function () { addTestFile($this->temporaryDirectory->path('hey.zip')); $result = $this->backupsCheck @@ -29,7 +30,7 @@ expect($result)->status->toBe(Status::ok()); }); -it('it will fail if a file with the given glob does not exist', function() { +it('it will fail if a file with the given glob does not exist', function () { addTestFile($this->temporaryDirectory->path('hey.other')); $result = $this->backupsCheck @@ -39,7 +40,7 @@ expect($result)->status->toBe(Status::failed()); }); -it('will fail if the given directory does not exist', function() { +it('will fail if the given directory does not exist', function () { $result = $this->backupsCheck ->locatedAt('non-existing-directory') ->run(); @@ -47,7 +48,7 @@ expect($result)->status->toBe(Status::failed()); }); -it('will fail if the backup is smaller than the given size', function() { +it('will fail if the backup is smaller than the given size', function () { addTestFile($this->temporaryDirectory->path('hey.zip'), sizeInMb: 4); $result = $this->backupsCheck @@ -58,7 +59,7 @@ expect($result)->status->toBe(Status::failed()); }); -it('will pass if the backup is at least than the given size', function(int $sizeInMb) { +it('will pass if the backup is at least than the given size', function (int $sizeInMb) { addTestFile($this->temporaryDirectory->path('hey.zip'), sizeInMb: $sizeInMb); $result = $this->backupsCheck @@ -72,7 +73,7 @@ [6], ]); -it('can check if the youngest backup is recent enough', function() { +it('can check if the youngest backup is recent enough', function () { addTestFile($this->temporaryDirectory->path('hey.zip')); testTime()->addMinutes(4); @@ -92,7 +93,7 @@ expect($result)->status->toBe(Status::failed()); }); -it('can check if the oldest backup is old enough', function() { +it('can check if the oldest backup is old enough', function () { addTestFile($this->temporaryDirectory->path('hey.zip'), date: now()->startOfMinute()); testTime()->addMinutes(4); @@ -113,7 +114,7 @@ expect($result)->status->toBe(Status::failed()); }); -it('can check that there are enough backups', function() { +it('can check that there are enough backups', function () { addTestFile($this->temporaryDirectory->path('first.zip')); $result = $this->backupsCheck @@ -131,8 +132,7 @@ expect($result)->status->toBe(Status::ok()); }); - -it('can make sure that there are not too much backups', function() { +it('can make sure that there are not too much backups', function () { addTestFile($this->temporaryDirectory->path('first.zip')); addTestFile($this->temporaryDirectory->path('second.zip'));