diff --git a/src/Support/HigherOrderCallables.php b/src/Support/HigherOrderCallables.php index a6ecccf3..8b4dc817 100644 --- a/src/Support/HigherOrderCallables.php +++ b/src/Support/HigherOrderCallables.php @@ -4,6 +4,7 @@ declare(strict_types=1); namespace Pest\Support; +use Closure; use Pest\Expectation; use Pest\PendingObjects\TestCall; use PHPUnit\Framework\TestCase; @@ -34,7 +35,7 @@ final class HigherOrderCallables */ public function expect($value) { - return new Expectation(is_callable($value) ? Reflection::bindCallable($value) : $value); + return new Expectation($value instanceof Closure ? Reflection::bindCallable($value) : $value); } /** diff --git a/tests/Features/HigherOrderTests.php b/tests/Features/HigherOrderTests.php index f871d919..b45568e9 100644 --- a/tests/Features/HigherOrderTests.php +++ b/tests/Features/HigherOrderTests.php @@ -18,6 +18,9 @@ it('resolves expect callables correctly') ->toBeString() ->toBe('bar'); +test('does not treat method names as callables') + ->expect('it')->toBeString(); + it('can tap into the test') ->expect('foo')->toBeString() ->tap(function () { expect($this)->toBeInstanceOf(TestCase::class); })