@@ -24,6 +24,12 @@ public function testItDoesNotThrowWhenExpectationIsMet($expectation): void
2424 $ this ->addToAssertionCount (1 ); // No exception thrown
2525 }
2626
27+ public function testItDoesNotThrowWhenExpectationIsMetAndACustomMatcherIsUsed (): void
28+ {
29+ expect (1 )->toHaveFoo (1 );
30+ $ this ->addToAssertionCount (1 ); // No exception thrown
31+ }
32+
2733 /**
2834 * @dataProvider incorrectExpectations
2935 */
@@ -58,7 +64,7 @@ public function testItCanBeDeactivated(): void
5864 /**
5965 * Cases that should evaluate without an exception
6066 */
61- public function correctExpectations (): array
67+ public static function correctExpectations (): array
6268 {
6369 return [
6470 [ function () { expect (5 )->toBe (5 ); } ],
@@ -80,16 +86,13 @@ public function correctExpectations(): array
8086 [ function () { expect ((new Foo ()))->toTrigger (E_USER_DEPRECATED )->duringTriggerError (); } ],
8187 [ function () { expect (1.444447777 )->toBeApproximately (1.444447777 , 1.0e-9 ); } ],
8288 [ function () { expect ((new Foo ())->getIterator ())->toIterateAs (new \ArrayIterator (['Foo ' , 'Bar ' ])); } ],
83- // Custom matchers
84- [ function () { expect (['foo ' => 'bar ' ])->toHaveKey ('foo ' ); } ],
85- [ function () { expect (1 )->toHaveFoo (1 ); } ],
8689 ];
8790 }
8891
8992 /**
9093 * Cases that should throw an exception when evaluated
9194 */
92- public function incorrectExpectations (): array
95+ public static function incorrectExpectations (): array
9396 {
9497 return [
9598 [ function () { expect (6 )->toBe (5 ); } ],
@@ -121,7 +124,6 @@ public function incorrectExpectations(): array
121124 public function getMatchers (): array
122125 {
123126 return [
124- 'haveKey ' => function ($ subject , $ key ) { return array_key_exists ($ key , $ subject ); },
125127 'haveFoo ' => new FooMatcher (),
126128 'haveBar ' => $ this ->addInvalidMatcher ? new \stdClass () : new FooMatcher (),
127129 ];
0 commit comments