mirror of
https://github.com/pestphp/pest.git
synced 2026-03-06 15:57:21 +01:00
feat: allows to chain todo
This commit is contained in:
@ -87,7 +87,7 @@ if (! function_exists('test')) {
|
|||||||
* is the test description; the second argument is
|
* is the test description; the second argument is
|
||||||
* a closure that contains the test expectations.
|
* a closure that contains the test expectations.
|
||||||
*
|
*
|
||||||
* @return TestCall|TestCase|mixed
|
* @return HigherOrderTapProxy<TestCall|TestCase>|TestCall
|
||||||
*/
|
*/
|
||||||
function test(string $description = null, Closure $closure = null): HigherOrderTapProxy|TestCall
|
function test(string $description = null, Closure $closure = null): HigherOrderTapProxy|TestCall
|
||||||
{
|
{
|
||||||
@ -130,10 +130,11 @@ if (! function_exists('todo')) {
|
|||||||
*/
|
*/
|
||||||
function todo(string $description): TestCall
|
function todo(string $description): TestCall
|
||||||
{
|
{
|
||||||
/* @phpstan-ignore-next-line */
|
$test = test($description);
|
||||||
return test($description, fn () => self::markTestSkipped(
|
|
||||||
'__TODO__',
|
assert($test instanceof TestCall);
|
||||||
));
|
|
||||||
|
return $test->skip('__TODO__');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -170,6 +170,16 @@ final class TestCall
|
|||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the test as "todo".
|
||||||
|
*/
|
||||||
|
public function todo(): self
|
||||||
|
{
|
||||||
|
$this->skip('__TODO__');
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the covered classes or methods.
|
* Sets the covered classes or methods.
|
||||||
*/
|
*/
|
||||||
|
|||||||
@ -44,7 +44,7 @@ final class ExceptionTrace
|
|||||||
*/
|
*/
|
||||||
public static function removePestReferences(Throwable $t): void
|
public static function removePestReferences(Throwable $t): void
|
||||||
{
|
{
|
||||||
if (! property_exists($t, 'serializableTrace')) { // @phpstan-ignore-line
|
if (! property_exists($t, 'serializableTrace')) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -10,6 +10,10 @@ use Throwable;
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @internal
|
* @internal
|
||||||
|
*
|
||||||
|
* @template TProxy
|
||||||
|
*
|
||||||
|
* @mixin TProxy
|
||||||
*/
|
*/
|
||||||
final class HigherOrderTapProxy
|
final class HigherOrderTapProxy
|
||||||
{
|
{
|
||||||
|
|||||||
@ -734,6 +734,8 @@
|
|||||||
|
|
||||||
PASS Tests\Features\Todo
|
PASS Tests\Features\Todo
|
||||||
↓ something todo later
|
↓ something todo later
|
||||||
|
↓ something todo later chained
|
||||||
|
↓ something todo later chained and with function body
|
||||||
✓ it does something within a file with a todo
|
✓ it does something within a file with a todo
|
||||||
|
|
||||||
PASS Tests\Fixtures\DirectoryWithTests\ExampleTest
|
PASS Tests\Fixtures\DirectoryWithTests\ExampleTest
|
||||||
@ -896,4 +898,4 @@
|
|||||||
PASS Tests\Visual\Version
|
PASS Tests\Visual\Version
|
||||||
✓ visual snapshot of help command output
|
✓ visual snapshot of help command output
|
||||||
|
|
||||||
Tests: 4 incomplete, 2 todos, 17 skipped, 624 passed (1511 assertions)
|
Tests: 4 incomplete, 4 todos, 17 skipped, 624 passed (1511 assertions)
|
||||||
@ -2,6 +2,12 @@
|
|||||||
|
|
||||||
todo('something todo later');
|
todo('something todo later');
|
||||||
|
|
||||||
|
test('something todo later chained')->todo();
|
||||||
|
|
||||||
|
test('something todo later chained and with function body', function () {
|
||||||
|
expect(true)->toBeFalse();
|
||||||
|
})->todo();
|
||||||
|
|
||||||
it('does something within a file with a todo', function () {
|
it('does something within a file with a todo', function () {
|
||||||
expect(true)->toBeTrue();
|
expect(true)->toBeTrue();
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user