Skip to content

Commit

Permalink
Merge pull request #214 from leMaur/feat/string-case-expectations
Browse files Browse the repository at this point in the history
docs: add "string case" and "array key case" expectations
  • Loading branch information
nunomaduro authored Aug 21, 2023
2 parents 9666ae5 + 757ad12 commit 5d86199
Showing 1 changed file with 80 additions and 0 deletions.
80 changes: 80 additions & 0 deletions expectations.md
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,14 @@ With the Pest expectation API, you have access to an extensive collection of ind
- [`toBeLowercase`](#expect-toBeLowercase)
- [`toBeAlpha`](#expect-toBeAlpha)
- [`toBeAlphaNumeric`](#expect-toBeAlphaNumeric)
- [`toBeSnakeCase`](#expect-toBeSnakeCase)
- [`toBeKebabCase`](#expect-toBeKebabCase)
- [`toBeCamelCase`](#expect-toBeCamelCase)
- [`toBeStudlyCase`](#expect-toBeStudlyCase)
- [`toHaveSnakeCaseKeys`](#expect-toHaveSnakeCaseKeys)
- [`toHaveKebabCaseKeys`](#expect-toHaveKebabCaseKeys)
- [`toHaveCamelCaseKeys`](#expect-toHaveCamelCaseKeys)
- [`toHaveStudlyCaseKeys`](#expect-toHaveStudlyCaseKeys)

</div>

Expand Down Expand Up @@ -717,6 +725,78 @@ This expectation ensures that `$value` only contains alphanumeric characters.
expect('pestPHP123')->toBeAlphaNumeric();
```

<a name="expect-toBeSnakeCase"></a>
### `toBeSnakeCase()`

This expectation ensures that `$value` only contains string in snake_case format.

```php
expect('snake_case')->toBeSnakeCase();
```

<a name="expect-toBeKebabCase"></a>
### `toBeKebabCase()`

This expectation ensures that `$value` only contains string in kebab-case format.

```php
expect('kebab-case')->toBeKebabCase();
```

<a name="expect-toBeCamelCase"></a>
### `toBeCamelCase()`

This expectation ensures that `$value` only contains string in camelCase format.

```php
expect('camelCase')->toBeCamelCase();
```

<a name="expect-toBeStudlyCase"></a>
### `toBeStudlyCase()`

This expectation ensures that `$value` only contains string in StudlyCase format.

```php
expect('StudlyCase')->toBeStudlyCase();
```

<a name="expect-toHaveSnakeCaseKeys"></a>
### `toHaveSnakeCaseKeys()`

This expectation ensures that `$value` only contains an array with keys in snake_case format.

```php
expect(['snake_case' => 'abc123'])->toHaveSnakeCaseKeys();
```

<a name="expect-toHaveKebabCaseKeys"></a>
### `toHaveKebabCaseKeys()`

This expectation ensures that `$value` only contains an array with keys in kebab-case format.

```php
expect(['kebab-case' => 'abc123'])->toHaveKebabCaseKeys();
```

<a name="expect-toHaveCamelCaseKeys"></a>
### `toHaveCamelCaseKeys()`

This expectation ensures that `$value` only contains an array with keys in camelCase format.

```php
expect(['camelCase' => 'abc123'])->toHaveCamelCaseKeys();
```

<a name="expect-toHaveStudlyCaseKeys"></a>
### `toHaveStudlyCaseKeys()`

This expectation ensures that `$value` only contains an array with keys in StudlyCase format.

```php
expect(['StudlyCase' => 'abc123'])->toHaveStudlyCaseKeys();
```

---

<a name="expect-and"></a>
Expand Down

0 comments on commit 5d86199

Please sign in to comment.