mirror of
https://github.com/pestphp/pest.git
synced 2026-03-06 15:57:21 +01:00
feat: add toHaveSnakeCaseKeys
This commit is contained in:
31
tests/Features/Expect/toHaveSnakeCaseKeys.php
Normal file
31
tests/Features/Expect/toHaveSnakeCaseKeys.php
Normal file
@ -0,0 +1,31 @@
|
||||
<?php
|
||||
|
||||
use Pest\Exceptions\InvalidExpectationValue;
|
||||
use PHPUnit\Framework\ExpectationFailedException;
|
||||
|
||||
$array = [
|
||||
'snake' => true,
|
||||
'snake_case' => [
|
||||
'snake' => true,
|
||||
'snake_case' => [
|
||||
'snake' => true,
|
||||
'snake_case' => true,
|
||||
],
|
||||
],
|
||||
];
|
||||
|
||||
test('pass', function () use ($array) {
|
||||
expect($array)->toHaveSnakeCaseKeys();
|
||||
});
|
||||
|
||||
test('failures', function () {
|
||||
expect('not-an-array')->toHaveSnakeCaseKeys();
|
||||
})->throws(InvalidExpectationValue::class);
|
||||
|
||||
test('failures with message', function () use ($array) {
|
||||
expect($array)->not->toHaveSnakeCaseKeys('oh no!');
|
||||
})->throws(ExpectationFailedException::class, 'oh no!');
|
||||
|
||||
test('not failures', function () use ($array) {
|
||||
expect($array)->not->toHaveSnakeCaseKeys();
|
||||
})->throws(ExpectationFailedException::class);
|
||||
Reference in New Issue
Block a user