mirror of
https://github.com/pestphp/pest.git
synced 2026-03-06 07:47:22 +01:00
feat: adds toHaveKeys expectation
This commit is contained in:
@ -180,6 +180,11 @@
|
||||
PASS Tests\Expect\toHaveKey
|
||||
✓ pass
|
||||
✓ failures
|
||||
✓ not failures
|
||||
|
||||
PASS Tests\Expect\toHaveKeys
|
||||
✓ pass
|
||||
✓ failures
|
||||
✓ not failures
|
||||
|
||||
PASS Tests\Expect\toHaveProperty
|
||||
@ -353,5 +358,5 @@
|
||||
✓ depends with defined arguments
|
||||
✓ depends run test only once
|
||||
|
||||
Tests: 6 skipped, 208 passed
|
||||
Tests: 6 skipped, 211 passed
|
||||
|
||||
15
tests/Expect/toHaveKeys.php
Normal file
15
tests/Expect/toHaveKeys.php
Normal file
@ -0,0 +1,15 @@
|
||||
<?php
|
||||
|
||||
use PHPUnit\Framework\ExpectationFailedException;
|
||||
|
||||
test('pass', function () {
|
||||
expect(['a' => 1, 'b', 'c' => 'world'])->toHaveKeys(['a', 'c']);
|
||||
});
|
||||
|
||||
test('failures', function () {
|
||||
expect(['a' => 1, 'b', 'c' => 'world'])->toHaveKeys(['a', 'd']);
|
||||
})->throws(ExpectationFailedException::class);
|
||||
|
||||
test('not failures', function () {
|
||||
expect(['a' => 1, 'hello' => 'world', 'c'])->not->toHaveKeys(['hello', 'c']);
|
||||
})->throws(ExpectationFailedException::class);
|
||||
Reference in New Issue
Block a user