Compare commits

...

6 Commits

Author SHA1 Message Date
eb6de433b7 docs: update changelog 2021-07-11 09:08:31 +01:00
32f72cdf55 Merge pull request #344 from pestphp/callable-expect-fix
Forces higher order test callable expects to be closures
2021-07-11 09:04:59 +01:00
c160d97428 Forces higher order test callable expects to be closures. 2021-07-11 07:56:02 +01:00
5ab3c6e2d7 Merge pull request #340 from pestphp/better-tap-type-hinting
Better tap type hinting
2021-07-09 16:34:18 +01:00
50ece576a7 Improves type-hinting for target in HigherOrderTapProxy 2021-07-09 16:09:53 +01:00
9c202fa2d7 Improves type-hinting for tap method 2021-07-09 16:07:37 +01:00
5 changed files with 17 additions and 10 deletions

View File

@ -4,6 +4,10 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](http://keepachangelog.com/)
and this project adheres to [Semantic Versioning](http://semver.org/).
## [v1.9.1 (2021-07-11)](https://github.com/pestphp/pest/compare/v1.9.0...v1.9.1)
### Fixed
- Callable `expect` values in higher order tests failing if the value was an existing method name ([#334](https://github.com/pestphp/pest/pull/344))
## [v1.9.0 (2021-07-09)](https://github.com/pestphp/pest/compare/v1.8.0...v1.9.0)
### Changed
- You may now pass just an exception message when using the `throws` method ([#339](https://github.com/pestphp/pest/pull/339))

View File

@ -6,7 +6,7 @@ namespace Pest;
function version(): string
{
return '1.9.0';
return '1.9.1';
}
function testDirectory(string $file = ''): string

View File

@ -4,7 +4,10 @@ declare(strict_types=1);
namespace Pest\Support;
use Closure;
use Pest\Expectation;
use Pest\PendingObjects\TestCall;
use PHPUnit\Framework\TestCase;
/**
* @internal
@ -32,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);
}
/**
@ -50,11 +53,9 @@ final class HigherOrderCallables
}
/**
* @template TValue
* Tap into the test case to perform an action and return the test case.
*
* @param callable(): TValue $callable
*
* @return TValue|object
* @return TestCall|TestCase|object
*/
public function tap(callable $callable)
{

View File

@ -4,6 +4,7 @@ declare(strict_types=1);
namespace Pest\Support;
use PHPUnit\Framework\TestCase;
use ReflectionClass;
use Throwable;
@ -17,16 +18,14 @@ final class HigherOrderTapProxy
/**
* The target being tapped.
*
* @var mixed
* @var TestCase
*/
public $target;
/**
* Create a new tap proxy instance.
*
* @param mixed $target
*/
public function __construct($target)
public function __construct(TestCase $target)
{
$this->target = $target;
}

View File

@ -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); })