mirror of
https://github.com/archtechx/enums.git
synced 2025-12-12 12:54:04 +00:00
initial
This commit is contained in:
parent
f9fe9e5cab
commit
41b423da38
11 changed files with 146 additions and 91 deletions
|
|
@ -11,7 +11,7 @@
|
|||
|
|
||||
*/
|
||||
|
||||
uses(ArchTech\REPLACE\Tests\TestCase::class)->in('Pest');
|
||||
uses(ArchTech\Enums\Tests\TestCase::class)->in('Pest');
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
|
|||
28
tests/Pest/EnumTest.php
Normal file
28
tests/Pest/EnumTest.php
Normal file
|
|
@ -0,0 +1,28 @@
|
|||
<?php
|
||||
|
||||
use ArchTech\Enums\Exceptions\UndefinedCaseError;
|
||||
use ArchTech\Enums\InvokableCases;
|
||||
|
||||
it('can be used as a static method', function () {
|
||||
expect(Status::PENDING())->toBe(0);
|
||||
expect(Status::DONE())->toBe(1);
|
||||
});
|
||||
|
||||
it('can be invoked as an instance', function () {
|
||||
$status = Status::PENDING;
|
||||
|
||||
expect($status())->toBe(0);
|
||||
expect($status())->toBe($status->value);
|
||||
});
|
||||
|
||||
it('throws an error when a nonexistent case is being used', function () {
|
||||
Status::INVALID();
|
||||
})->expectException(UndefinedCaseError::class);
|
||||
|
||||
enum Status: int
|
||||
{
|
||||
use InvokableCases;
|
||||
|
||||
case PENDING = 0;
|
||||
case DONE = 1;
|
||||
}
|
||||
|
|
@ -1,9 +0,0 @@
|
|||
<?php
|
||||
|
||||
it('succeeds', function () {
|
||||
expect(true)->toBeTrue();
|
||||
});
|
||||
|
||||
it('fails', function () {
|
||||
expect(false)->toBeTrue();
|
||||
});
|
||||
|
|
@ -1,16 +1,10 @@
|
|||
<?php
|
||||
|
||||
namespace ArchTech\REPLACE\Tests;
|
||||
namespace ArchTech\Enums\Tests;
|
||||
|
||||
use Orchestra\Testbench\TestCase as TestbenchTestCase;
|
||||
use ArchTech\REPLACE\REPLACEServiceProvider;
|
||||
|
||||
class TestCase extends TestbenchTestCase
|
||||
{
|
||||
protected function getPackageProviders($app)
|
||||
{
|
||||
return [
|
||||
REPLACEServiceProvider::class,
|
||||
];
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue