mirror of
https://github.com/archtechx/enums.git
synced 2025-12-12 20:44:03 +00:00
test: comparable enum
This commit is contained in:
parent
b9f33f36a3
commit
161f04b719
2 changed files with 54 additions and 3 deletions
51
tests/Pest/ComparableTest.php
Normal file
51
tests/Pest/ComparableTest.php
Normal file
|
|
@ -0,0 +1,51 @@
|
|||
<?php
|
||||
|
||||
it('compare equal enum', function () {
|
||||
expect(Status::PENDING->is(Status::PENDING))
|
||||
->toBeTrue()
|
||||
->and(Status::PENDING->is(Status::DONE))
|
||||
->toBeFalse()
|
||||
->and(Role::ADMIN->is(Role::ADMIN))
|
||||
->toBeTrue()
|
||||
->and(Role::ADMIN->is(Role::GUEST))
|
||||
->toBeFalse()
|
||||
->and(Role::ADMIN->is('admin'))
|
||||
->toBeFalse();
|
||||
});
|
||||
|
||||
it('compare not equal enum', function () {
|
||||
expect(Status::PENDING->isNot(Status::DONE))
|
||||
->toBeTrue()
|
||||
->and(Status::PENDING->isNot(Status::PENDING))
|
||||
->toBeFalse()
|
||||
->and(Status::PENDING->isNot(Role::ADMIN))
|
||||
->toBeTrue()
|
||||
->and(Role::ADMIN->isNot(Role::GUEST))
|
||||
->toBeTrue()
|
||||
->and(Role::ADMIN->isNot(Role::ADMIN))
|
||||
->toBeFalse()
|
||||
->and(Role::ADMIN->isNot('admin'))
|
||||
->toBeTrue();
|
||||
});
|
||||
|
||||
it('compare in enums', function () {
|
||||
expect(Status::PENDING->in([Status::PENDING, Status::DONE]))
|
||||
->toBeTrue()
|
||||
->and(Status::PENDING->in([Status::DONE]))
|
||||
->toBeFalse()
|
||||
->and(Status::PENDING->in([Role::ADMIN, Role::GUEST]))
|
||||
->toBeFalse()
|
||||
->and(Role::ADMIN->in([Role::ADMIN]))
|
||||
->toBeTrue();
|
||||
});
|
||||
|
||||
it('compare not in enums', function () {
|
||||
expect(Status::PENDING->notIn([Status::DONE]))
|
||||
->toBeTrue()
|
||||
->and(Status::PENDING->notIn([Status::PENDING, Status::DONE]))
|
||||
->toBeFalse()
|
||||
->and(Role::ADMIN->notIn([Role::GUEST]))
|
||||
->toBeTrue()
|
||||
->and(Role::ADMIN->notIn([Role::ADMIN, Role::GUEST]))
|
||||
->toBeFalse();
|
||||
});
|
||||
Loading…
Add table
Add a link
Reference in a new issue