mirror of
https://github.com/pestphp/pest.git
synced 2026-03-06 07:47:22 +01:00
feat(expect): add more methods
This commit is contained in:
16
tests/Expect/toEqualCanonicalizing.php
Normal file
16
tests/Expect/toEqualCanonicalizing.php
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
use PHPUnit\Framework\ExpectationFailedException;
|
||||||
|
|
||||||
|
test('pass', function () {
|
||||||
|
expect([1, 2, 3])->toEqualCanonicalizing([3, 1, 2]);
|
||||||
|
expect(['g', 'a', 'z'])->not->toEqualCanonicalizing(['a', 'z']);
|
||||||
|
});
|
||||||
|
|
||||||
|
test('failures', function () {
|
||||||
|
expect([3, 2, 1])->toEqualCanonicalizing([1, 2]);
|
||||||
|
})->throws(ExpectationFailedException::class);
|
||||||
|
|
||||||
|
test('not failures', function () {
|
||||||
|
expect(['a', 'b', 'c'])->not->toEqualCanonicalizing(['b', 'a', 'c']);
|
||||||
|
})->throws(ExpectationFailedException::class);
|
||||||
15
tests/Expect/toHaveKey.php
Normal file
15
tests/Expect/toHaveKey.php
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
use PHPUnit\Framework\ExpectationFailedException;
|
||||||
|
|
||||||
|
test('pass', function () {
|
||||||
|
expect(['a' => 1, 'b', 'c' => 'world'])->toHaveKey('c');
|
||||||
|
});
|
||||||
|
|
||||||
|
test('failures', function () {
|
||||||
|
expect(['a' => 1, 'b', 'c' => 'world'])->toHaveKey('hello');
|
||||||
|
})->throws(ExpectationFailedException::class);
|
||||||
|
|
||||||
|
test('not failures', function () {
|
||||||
|
expect(['a' => 1, 'hello' => 'world', 'c'])->not->toHaveKey('hello');
|
||||||
|
})->throws(ExpectationFailedException::class);
|
||||||
Reference in New Issue
Block a user