Merge pull request #1006 from JonPurvis/to-be-backed-enum-expectation

[2.x] Add `toBeStringBackedEnum()` and `toBeIntBackedEnum()` Architecture Expectations
This commit is contained in:
Nuno Maduro
2024-01-25 17:09:23 +00:00
committed by GitHub
8 changed files with 150 additions and 0 deletions

View File

@ -0,0 +1,9 @@
<?php
test('enum is backed by int')
->expect('Tests\Fixtures\Arch\ToBeIntBackedEnum\HasIntBacking')
->toBeIntBackedEnum();
test('enum is not backed by int')
->expect('Tests\Fixtures\Arch\ToBeIntBackedEnum\HasStringBacking')
->not->toBeIntBackedEnum();

View File

@ -0,0 +1,9 @@
<?php
test('enum is backed by string')
->expect('Tests\Fixtures\Arch\ToBeStringBackedEnum\HasStringBacking')
->toBeStringBackedEnum();
test('enum is not backed by string')
->expect('Tests\Fixtures\Arch\ToBeStringBackedEnum\HasIntBacking')
->not->toBeStringBackedEnum();

View File

@ -0,0 +1,10 @@
<?php
declare(strict_types=1);
namespace Tests\Fixtures\Arch\ToBeIntBackedEnum\HasIntBacking;
enum HasIntBackingEnum: int
{
case IntBacked = 1;
}

View File

@ -0,0 +1,10 @@
<?php
declare(strict_types=1);
namespace Tests\Fixtures\Arch\ToBeIntBackedEnum\HasStringBacking;
enum HasStringBackingEnum: string
{
case StringBacked = 'Testing';
}

View File

@ -0,0 +1,10 @@
<?php
declare(strict_types=1);
namespace Tests\Fixtures\Arch\ToBeStringBackedEnum\HasIntBacking;
enum HasIntBackingEnum: int
{
case IntBacked = 1;
}

View File

@ -0,0 +1,10 @@
<?php
declare(strict_types=1);
namespace Tests\Fixtures\Arch\ToBeStringBackedEnum\HasStringBacking;
enum HasStringBackingEnum: string
{
case StringBacked = 'Testing';
}