Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug]: Datasets with Enum doesn't work #1288

Open
deleugpn opened this issue Oct 4, 2024 · 1 comment
Open

[Bug]: Datasets with Enum doesn't work #1288

deleugpn opened this issue Oct 4, 2024 · 1 comment
Labels

Comments

@deleugpn
Copy link

deleugpn commented Oct 4, 2024

What Happened

When I use a dataset with Enum, Pest interprets it as if no dataset has been provided.

ERROR A test with the description 'pest datasets break with Enum → it should work with enums' has 1 argument(s) ([PhpVersion $phpVersion]) and no dataset(s) provided in MyTest.php

How to Reproduce

describe('pest datasets break with Enum', function () {
    it('should work with enums', function (PhpVersion $phpVersion) {
        expect($phpVersion)->toBe(PhpVersion::PHP_80);
    })->with([
        PhpVersion::PHP_80,
        PhpVersion::PHP_81,
        PhpVersion::PHP_82,
        PhpVersion::PHP_83,
        PhpVersion::PHP_84,
    ]);
});

enum  PhpVersion: string
{
    case PHP_80 = '8.0';
    case PHP_81 = '8.1';
    case PHP_82 = '8.2';
    case PHP_83 = '8.3';
    case PHP_84 = '8.4';
}

Sample Repository

No response

Pest Version

2.35.1

PHP Version

8.3.12

Operation System

macOS

Notes

No response

@deleugpn deleugpn added the bug label Oct 4, 2024
@nuernbergerA
Copy link
Contributor

The documentation do not mention that enums are supported

to make your example work you can use Bound Datasets

describe('pest datasets break with Enum', function () {
    it('should work with enums', function (PhpVersion $phpVersion) {
        expect($phpVersion)->toBe(PhpVersion::PHP_80);
    })->with([
        fn() => PhpVersion::PHP_80,
        fn() => PhpVersion::PHP_81,
        fn() => PhpVersion::PHP_82,
        fn() => PhpVersion::PHP_83,
        fn() => PhpVersion::PHP_84,
    ]);
});

enum PhpVersion: string
{
    case PHP_80 = '8.0';
    case PHP_81 = '8.1';
    case PHP_82 = '8.2';
    case PHP_83 = '8.3';
    case PHP_84 = '8.4';
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants