1
0
Fork 0
mirror of https://github.com/archtechx/tenancy.git synced 2026-02-05 18:34:04 +00:00

update test to use min & max

This commit is contained in:
Samuel Štancl 2025-01-21 16:00:31 +01:00
parent 8f7b8e971a
commit 760db83f92

View file

@ -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 () {