From 03201cb8b7e8243d4b216c46e4a3b986662892d3 Mon Sep 17 00:00:00 2001 From: ceceppa Date: Thu, 16 Jul 2020 07:57:05 +0100 Subject: [PATCH] feat(expect): add more methods --- tests/Expect/toEqualCanonicalizing.php | 16 ++++++++++++++++ tests/Expect/toHaveKey.php | 15 +++++++++++++++ 2 files changed, 31 insertions(+) create mode 100644 tests/Expect/toEqualCanonicalizing.php create mode 100644 tests/Expect/toHaveKey.php diff --git a/tests/Expect/toEqualCanonicalizing.php b/tests/Expect/toEqualCanonicalizing.php new file mode 100644 index 00000000..5e1178b9 --- /dev/null +++ b/tests/Expect/toEqualCanonicalizing.php @@ -0,0 +1,16 @@ +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); diff --git a/tests/Expect/toHaveKey.php b/tests/Expect/toHaveKey.php new file mode 100644 index 00000000..1695688b --- /dev/null +++ b/tests/Expect/toHaveKey.php @@ -0,0 +1,15 @@ + 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);