generated from spatie/package-skeleton-laravel
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
ed251f3
commit 1b7b6e2
Showing
3 changed files
with
81 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
<?php | ||
|
||
it('contains only strings in check config', function () { | ||
foreach (config('audit.checks') as $check) { | ||
expect($check)->toBeString(); | ||
} | ||
}); | ||
|
||
it('contains only checks with execute functions', function () { | ||
foreach (config('audit.checks') as $check) { | ||
$instance = app()->make($check); | ||
expect(get_class($instance)) | ||
->toHaveMethod('execute'); | ||
} | ||
}); | ||
|
||
it('contains checks with different names', function () { | ||
foreach (config('audit.checks') as $check) { | ||
$instance = app()->make($check); | ||
expect($instance->execute())->toBeInstanceOf(\Hexafuchs\Audit\Checks\CheckResult::class); | ||
} | ||
}); | ||
|
||
it('contains no null values', function () { | ||
foreach (config('audit.checks') as $check) { | ||
$instance = app()->make($check); | ||
expect($instance->getName())->not->toBeEmpty() | ||
->and($instance->getGroup())->not->toBeEmpty() | ||
->and($instance->getError())->not->toBeEmpty(); | ||
} | ||
}); | ||
|
||
it('contains different names', function () { | ||
$names = []; | ||
foreach (config('audit.checks') as $check) { | ||
$instance = app()->make($check); | ||
$names[] = $instance->getName(); | ||
} | ||
expect(sizeof($names))->toBe(sizeof(array_unique($names))); | ||
}); | ||
|
||
it('contains different errors', function () { | ||
$errors = []; | ||
foreach (config('audit.checks') as $check) { | ||
$instance = app()->make($check); | ||
$errors[] = $instance->getError()->message; | ||
} | ||
|
||
expect(sizeof($errors))->toBe(sizeof(array_unique($errors))); | ||
}); |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
<?php | ||
|
||
use Hexafuchs\Audit\Facades\Audit; | ||
|
||
it('returns check results', function () { | ||
$result = Audit::run(); | ||
|
||
expect($result->doesntContain(fn ($e) => !($e instanceof \Hexafuchs\Audit\Checks\CheckResult)))->toBeTrue(); | ||
}); | ||
|
||
it('contains enough results', function () { | ||
$result = Audit::run(); | ||
|
||
expect($result->count() === sizeof(config('audit.checks')))->toBeTrue(); | ||
}); | ||
|
||
it('contains no null group names', function () { | ||
$result = Audit::run(); | ||
|
||
expect($result->map(fn ($e) => $e->group)->doesntContain(fn ($e) => $e === null))->toBeTrue(); | ||
}); | ||
|
||
|
||
it('contains unique names', function () { | ||
$result = Audit::run(); | ||
$names = $result->map(fn ($e) => $e->name); | ||
|
||
expect($names->count() === $names->unique()->count())->toBeTrue(); | ||
}); | ||
|
||
|