Skip to content

Multiple conditions #807

Answered by owenvoke
DKhalil asked this question in Q&A
Discussion options

You must be logged in to vote

I don't think this is something we natively have on Pest, however a suggestion is you could use the ->toMatchConstraint() method with PHPUnit's LogicalOr constraint.

use PHPUnit\Framework\Constraint;

it('can check with logical or', function () {
    expect('abc')->toMatchConstraint(
        Constraint\LogicalOr::fromConstraints(
            new Constraint\IsEqual('abc'),
            new Constraint\IsNull(),
        )
    );
});

It would be kind of nice to add this functionality in future though. 👀

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by DKhalil
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants