mirror of
https://github.com/archtechx/tenancy.git
synced 2026-02-05 09:04:03 +00:00
update test to use min & max
This commit is contained in:
parent
8f7b8e971a
commit
760db83f92
1 changed files with 10 additions and 10 deletions
|
|
@ -23,6 +23,11 @@ use Stancl\Tenancy\UniqueIdentifierGenerators\RandomHexGenerator;
|
|||
use Stancl\Tenancy\UniqueIdentifierGenerators\RandomIntGenerator;
|
||||
use Stancl\Tenancy\UniqueIdentifierGenerators\RandomStringGenerator;
|
||||
|
||||
afterEach(function () {
|
||||
RandomIntGenerator::$min = 0;
|
||||
RandomIntGenerator::$max = PHP_INT_MAX;
|
||||
});
|
||||
|
||||
test('created event is dispatched', function () {
|
||||
Event::fake([TenantCreated::class]);
|
||||
|
||||
|
|
@ -90,17 +95,12 @@ test('hex ids are supported', function () {
|
|||
|
||||
test('random ints are supported', function () {
|
||||
app()->bind(UniqueIdentifierGenerator::class, RandomIntGenerator::class);
|
||||
RandomIntGenerator::$min = 200;
|
||||
RandomIntGenerator::$max = 1000;
|
||||
|
||||
// No good way to test this besides asserting that at least one of two ids
|
||||
// should statistically be above 1 billion.
|
||||
try {
|
||||
$tenant1 = Tenant::create();
|
||||
assert((int) $tenant1->id > 10**9);
|
||||
} catch (\AssertionError) {
|
||||
// retry
|
||||
$tenant1 = Tenant::create();
|
||||
assert((int) $tenant1->id > 10**9);
|
||||
}
|
||||
expect($tenant1->id >= 200)->toBeTrue();
|
||||
expect($tenant1->id <= 1000)->toBeTrue();
|
||||
});
|
||||
|
||||
test('random string ids are supported', function () {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue