mirror of
https://github.com/pestphp/pest.git
synced 2026-12-03 22:45:06 +01:00
fix: not->toHaveKeys() with nested keys (#2094)
This commit is contained in:
@@ -48,12 +48,14 @@ final readonly class OppositeExpectation
|
||||
public function toHaveKeys(array $keys): Expectation
|
||||
{
|
||||
foreach ($keys as $k => $key) {
|
||||
if (is_array($key)) {
|
||||
$this->toHaveKeys(array_keys(Arr::dot($key, $k.'.')));
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
try {
|
||||
if (is_array($key)) {
|
||||
$this->toHaveKeys(array_keys(Arr::dot($key, $k.'.')));
|
||||
} else {
|
||||
$this->original->toHaveKey($key);
|
||||
}
|
||||
$this->original->toHaveKey($key);
|
||||
} catch (ExpectationFailedException) {
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -1021,6 +1021,8 @@
|
||||
✓ failures with multi-dimensional arrays and custom message
|
||||
✓ not failures
|
||||
✓ not failures with multi-dimensional arrays
|
||||
✓ not pass with multi-dimensional arrays
|
||||
✓ not failures with only multi-dimensional arrays
|
||||
|
||||
PASS Tests\Features\Expect\toHaveLength
|
||||
✓ it passes with ('Fortaleza')
|
||||
@@ -2845,4 +2847,4 @@
|
||||
✓ pass with dataset with ('my-datas-set-value')
|
||||
✓ within describe → pass with dataset with ('my-datas-set-value')
|
||||
|
||||
Tests: 2 deprecated, 4 warnings, 5 incomplete, 2 notices, 40 todos, 44 skipped, 2111 passed (4652 assertions)
|
||||
Tests: 2 deprecated, 4 warnings, 5 incomplete, 2 notices, 40 todos, 44 skipped, 2113 passed (4657 assertions)
|
||||
|
||||
@@ -33,3 +33,11 @@ test('not failures', function (): void {
|
||||
test('not failures with multi-dimensional arrays', function (): void {
|
||||
expect(['a' => 1, 'b', 'c' => 'world', 'foo' => ['bar' => ['bir' => 'biz']]])->not->toHaveKeys(['foo' => ['bar' => 'bir'], 'c', 'z']);
|
||||
})->throws(ExpectationFailedException::class);
|
||||
|
||||
test('not pass with multi-dimensional arrays', function (): void {
|
||||
expect(['a' => 1, 'b', 'c' => 'world', 'foo' => ['bar' => ['bir' => 'biz']]])->not->toHaveKeys(['foo' => ['bar' => ['baz']], 'z']);
|
||||
});
|
||||
|
||||
test('not failures with only multi-dimensional arrays', function (): void {
|
||||
expect(['a' => 1, 'b', 'c' => 'world', 'foo' => ['bar' => ['bir' => 'biz']]])->not->toHaveKeys(['foo' => ['bar' => ['bir']]]);
|
||||
})->throws(ExpectationFailedException::class);
|
||||
|
||||
@@ -21,7 +21,7 @@ test('parallel', function () use ($run): void {
|
||||
$output = implode("\n", array_slice(explode("\n", (string) $output), -10));
|
||||
$profileOutput = $run('tests/Fixtures/Suites/SuccessOnly.php', '--profile');
|
||||
|
||||
$expected = '2 deprecated, 4 warnings, 5 incomplete, 3 notices, 40 todos, 36 skipped, 1980 passed (4122 assertions)';
|
||||
$expected = '2 deprecated, 4 warnings, 5 incomplete, 3 notices, 40 todos, 36 skipped, 1982 passed (4127 assertions)';
|
||||
|
||||
expect($output)
|
||||
->toContain("Tests: {$expected}")
|
||||
|
||||
Reference in New Issue
Block a user