mirror of
https://github.com/pestphp/pest.git
synced 2026-03-07 00:07:22 +01:00
Compare commits
6 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| eb6de433b7 | |||
| 32f72cdf55 | |||
| c160d97428 | |||
| 5ab3c6e2d7 | |||
| 50ece576a7 | |||
| 9c202fa2d7 |
@ -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/)
|
The format is based on [Keep a Changelog](http://keepachangelog.com/)
|
||||||
and this project adheres to [Semantic Versioning](http://semver.org/).
|
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)
|
## [v1.9.0 (2021-07-09)](https://github.com/pestphp/pest/compare/v1.8.0...v1.9.0)
|
||||||
### Changed
|
### Changed
|
||||||
- You may now pass just an exception message when using the `throws` method ([#339](https://github.com/pestphp/pest/pull/339))
|
- You may now pass just an exception message when using the `throws` method ([#339](https://github.com/pestphp/pest/pull/339))
|
||||||
|
|||||||
@ -6,7 +6,7 @@ namespace Pest;
|
|||||||
|
|
||||||
function version(): string
|
function version(): string
|
||||||
{
|
{
|
||||||
return '1.9.0';
|
return '1.9.1';
|
||||||
}
|
}
|
||||||
|
|
||||||
function testDirectory(string $file = ''): string
|
function testDirectory(string $file = ''): string
|
||||||
|
|||||||
@ -4,7 +4,10 @@ declare(strict_types=1);
|
|||||||
|
|
||||||
namespace Pest\Support;
|
namespace Pest\Support;
|
||||||
|
|
||||||
|
use Closure;
|
||||||
use Pest\Expectation;
|
use Pest\Expectation;
|
||||||
|
use Pest\PendingObjects\TestCall;
|
||||||
|
use PHPUnit\Framework\TestCase;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @internal
|
* @internal
|
||||||
@ -32,7 +35,7 @@ final class HigherOrderCallables
|
|||||||
*/
|
*/
|
||||||
public function expect($value)
|
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 TestCall|TestCase|object
|
||||||
*
|
|
||||||
* @return TValue|object
|
|
||||||
*/
|
*/
|
||||||
public function tap(callable $callable)
|
public function tap(callable $callable)
|
||||||
{
|
{
|
||||||
|
|||||||
@ -4,6 +4,7 @@ declare(strict_types=1);
|
|||||||
|
|
||||||
namespace Pest\Support;
|
namespace Pest\Support;
|
||||||
|
|
||||||
|
use PHPUnit\Framework\TestCase;
|
||||||
use ReflectionClass;
|
use ReflectionClass;
|
||||||
use Throwable;
|
use Throwable;
|
||||||
|
|
||||||
@ -17,16 +18,14 @@ final class HigherOrderTapProxy
|
|||||||
/**
|
/**
|
||||||
* The target being tapped.
|
* The target being tapped.
|
||||||
*
|
*
|
||||||
* @var mixed
|
* @var TestCase
|
||||||
*/
|
*/
|
||||||
public $target;
|
public $target;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a new tap proxy instance.
|
* Create a new tap proxy instance.
|
||||||
*
|
|
||||||
* @param mixed $target
|
|
||||||
*/
|
*/
|
||||||
public function __construct($target)
|
public function __construct(TestCase $target)
|
||||||
{
|
{
|
||||||
$this->target = $target;
|
$this->target = $target;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -18,6 +18,9 @@ it('resolves expect callables correctly')
|
|||||||
->toBeString()
|
->toBeString()
|
||||||
->toBe('bar');
|
->toBe('bar');
|
||||||
|
|
||||||
|
test('does not treat method names as callables')
|
||||||
|
->expect('it')->toBeString();
|
||||||
|
|
||||||
it('can tap into the test')
|
it('can tap into the test')
|
||||||
->expect('foo')->toBeString()
|
->expect('foo')->toBeString()
|
||||||
->tap(function () { expect($this)->toBeInstanceOf(TestCase::class); })
|
->tap(function () { expect($this)->toBeInstanceOf(TestCase::class); })
|
||||||
|
|||||||
Reference in New Issue
Block a user