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

add expectations for uppercase, lowercase, alpha and alphanumeric #906

Merged
merged 2 commits into from
Aug 13, 2023
Merged

add expectations for uppercase, lowercase, alpha and alphanumeric #906

merged 2 commits into from
Aug 13, 2023

Conversation

JonPurvis
Copy link
Contributor

@JonPurvis JonPurvis commented Aug 12, 2023

Q A
Bug fix? yes/no
New feature? yes/no
Fixed tickets N/A

Introduction

This PR adds a few more Expectations that would be useful in some projects I work with Pest on, hopefully other people will find them useful too. We have:

  • toBeUppercase()
  • toBeLowercase()
  • toBeAlphaNumeric()
  • toBeAlpha()

Usage

it('succeeds if uppercase', function () {
    expect('UPPERCASE')->toBeUppercase();
});

it('succeeds if lowercase', function () {
    expect('lowercase')->toBeLowercase();
});

it('succeeds if alpha', function () {
    expect('abc')->toBeAlpha();
});

it('succeeds if alphanumeric', function () {
    expect('abc123')->toBeAlphaNumeric();
});

it('succeeds if not uppercase', function () {
    expect('lowercase')->not->toBeUppercase();
});

it('succeeds if not lowercase', function () {
    expect('UPPERCASE')->not->toBeLowercase();
});

it('succeeds if not alpha', function () {
    expect('123')->not->toBeAlpha();
});

it('succeeds if not alphanumeric', function () {
    expect('-')->not->toBeAlphaNumeric();
});

@faissaloux
Copy link
Contributor

@JonPurvis thanks for your contribution.

Can you add toBeNumeric() using ctype_digit.

Thanks.

@JonPurvis
Copy link
Contributor Author

Thanks @faissaloux!

toBeNumeric() already exists in that class and uses assertIsNumeric().

@JonPurvis
Copy link
Contributor Author

@fabio-ivona Would you mind approving again please? I pushed a change to fix some complains with one of the tests

Thanks! :)

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

Successfully merging this pull request may close these issues.

4 participants