diff --git a/tests/BackedEnum.php b/tests/Enums/BackedEnum.php similarity index 94% rename from tests/BackedEnum.php rename to tests/Enums/BackedEnum.php index b020853..8e06696 100644 --- a/tests/BackedEnum.php +++ b/tests/Enums/BackedEnum.php @@ -1,6 +1,6 @@ BackedEnum::from(4)) - ->throwsIf(version_compare(PHP_VERSION, '8.2') == -1, ValueError::class, '4 is not a valid backing value for enum "Cerbero\Enum\BackedEnum"') - ->throwsIf(version_compare(PHP_VERSION, '8.2') >= 0, ValueError::class, '4 is not a valid backing value for enum Cerbero\Enum\BackedEnum'); + ->throwsIf(version_compare(PHP_VERSION, '8.2') == -1, ValueError::class, '4 is not a valid backing value for enum "Cerbero\Enum\Enums\BackedEnum"') + ->throwsIf(version_compare(PHP_VERSION, '8.2') >= 0, ValueError::class, '4 is not a valid backing value for enum Cerbero\Enum\Enums\BackedEnum'); it('retrieves the case hydrated from a value or returns null') ->expect(fn(int $value, ?BackedEnum $case) => BackedEnum::tryFrom($value) === $case) @@ -323,7 +323,7 @@ ]); it('throws a value error when hydrating backed cases with a missing name', fn() => BackedEnum::fromName('four')) - ->throws(ValueError::class, '"four" is not a valid name for enum "Cerbero\Enum\BackedEnum"'); + ->throws(ValueError::class, '"four" is not a valid name for enum "Cerbero\Enum\Enums\BackedEnum"'); it('retrieves the case hydrated from a name or returns null') ->expect(fn(string $name, ?BackedEnum $case) => BackedEnum::tryFromName($name) === $case) @@ -352,7 +352,7 @@ ->toBe([BackedEnum::two]); it('throws a value error when hydrating cases with an invalid meta', fn() => BackedEnum::fromMeta('color', 'orange')) - ->throws(ValueError::class, 'Invalid value for the meta "color" for enum "Cerbero\Enum\BackedEnum"'); + ->throws(ValueError::class, 'Invalid value for the meta "color" for enum "Cerbero\Enum\Enums\BackedEnum"'); it('retrieves the case hydrated from a meta or returns null') ->expect(fn(string $meta, mixed $value, ?array $cases) => BackedEnum::tryFromMeta($meta, $value)?->all() === $cases) @@ -375,7 +375,7 @@ ->toBe(1); it('fails handling the call to an invalid enum method', fn() => BackedEnum::four()) - ->throws(ValueError::class, '"four" is not a valid name for enum "Cerbero\Enum\BackedEnum"'); + ->throws(ValueError::class, '"four" is not a valid name for enum "Cerbero\Enum\Enums\BackedEnum"'); it('runs custom logic when calling an inaccessible enum method', function() { Enums::onStaticCall(function(string $enum, string $name, array $arguments) { @@ -392,7 +392,7 @@ }); it('handles the call to an inaccessible case method', fn() => BackedEnum::one->unknownMethod()) - ->throws(Error::class, 'The case Cerbero\Enum\BackedEnum::one has no "unknownMethod" meta set'); + ->throws(Error::class, 'The case Cerbero\Enum\Enums\BackedEnum::one has no "unknownMethod" meta set'); it('runs custom logic when calling an inaccessible case method', function() { Enums::onCall(function(object $case, string $name, array $arguments) { @@ -448,7 +448,7 @@ ->toBe('red'); it('throws a value error when attempting to retrieve an invalid item', fn() => BackedEnum::one->resolveItem('invalid')) - ->throws(ValueError::class, 'The case Cerbero\Enum\BackedEnum::one has no "invalid" meta set'); + ->throws(ValueError::class, 'The case Cerbero\Enum\Enums\BackedEnum::one has no "invalid" meta set'); it('retrieves the value of a backed case or the name of a pure case', function() { expect(BackedEnum::one->value())->toBe(1); diff --git a/tests/CasesCollectionTest.php b/tests/Unit/CasesCollectionTest.php similarity index 99% rename from tests/CasesCollectionTest.php rename to tests/Unit/CasesCollectionTest.php index 3c88656..aaa0396 100644 --- a/tests/CasesCollectionTest.php +++ b/tests/Unit/CasesCollectionTest.php @@ -1,8 +1,8 @@ PureEnum::from('1')) - ->throws(ValueError::class, '"1" is not a valid name for enum "Cerbero\Enum\PureEnum"'); + ->throws(ValueError::class, '"1" is not a valid name for enum "Cerbero\Enum\Enums\PureEnum"'); it('retrieves the case hydrated from a value or returns null') ->expect(fn(string $value, ?PureEnum $case) => PureEnum::tryFrom($value) === $case) @@ -332,7 +332,7 @@ ]); it('throws a value error when hydrating cases with an invalid name', fn() => PureEnum::fromName('1')) - ->throws(ValueError::class, '"1" is not a valid name for enum "Cerbero\Enum\PureEnum"'); + ->throws(ValueError::class, '"1" is not a valid name for enum "Cerbero\Enum\Enums\PureEnum"'); it('retrieves the case hydrated from a name or returns null') ->expect(fn(string $name, ?PureEnum $case) => PureEnum::tryFromName($name) === $case) @@ -361,7 +361,7 @@ ->toBe([PureEnum::two]); it('throws a value error when hydrating cases with an invalid meta', fn() => PureEnum::fromMeta('color', 'orange')) - ->throws(ValueError::class, 'Invalid value for the meta "color" for enum "Cerbero\Enum\PureEnum"'); + ->throws(ValueError::class, 'Invalid value for the meta "color" for enum "Cerbero\Enum\Enums\PureEnum"'); it('retrieves the case hydrated from a meta or returns null') ->expect(fn(string $meta, mixed $value, ?array $cases) => PureEnum::tryFromMeta($meta, $value)?->all() === $cases) @@ -384,7 +384,7 @@ ->toBe('one'); it('fails handling the call to an invalid enum method', fn() => PureEnum::four()) - ->throws(ValueError::class, '"four" is not a valid name for enum "Cerbero\Enum\PureEnum"'); + ->throws(ValueError::class, '"four" is not a valid name for enum "Cerbero\Enum\Enums\PureEnum"'); it('runs custom logic when calling an inaccessible enum method', function() { Enums::onStaticCall(function(string $enum, string $name, array $arguments) { @@ -401,7 +401,7 @@ }); it('handles the call to an inaccessible case method', fn() => PureEnum::one->unknownMethod()) - ->throws(Error::class, 'The case Cerbero\Enum\PureEnum::one has no "unknownMethod" meta set'); + ->throws(Error::class, 'The case Cerbero\Enum\Enums\PureEnum::one has no "unknownMethod" meta set'); it('runs custom logic when calling an inaccessible case method', function() { Enums::onCall(function(object $case, string $name, array $arguments) { @@ -456,7 +456,7 @@ ->toBe('red'); it('throws a value error when attempting to retrieve an invalid item', fn() => PureEnum::one->resolveItem('invalid')) - ->throws(ValueError::class, 'The case Cerbero\Enum\PureEnum::one has no "invalid" meta set'); + ->throws(ValueError::class, 'The case Cerbero\Enum\Enums\PureEnum::one has no "invalid" meta set'); it('retrieves the value of a backed case or the name of a pure case', function() { expect(PureEnum::one->value())->toBe('one');