mirror of
https://github.com/pestphp/pest.git
synced 2026-03-06 07:47:22 +01:00
fix: removes both toHaveMethod and toHaveMethods
This commit is contained in:
@ -344,36 +344,6 @@ final class Expectation
|
|||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Asserts that the value has the method $name.
|
|
||||||
*
|
|
||||||
* @return self<TValue>
|
|
||||||
*/
|
|
||||||
public function toHaveMethod(string $name, string $message = ''): self
|
|
||||||
{
|
|
||||||
$this->toBeObject();
|
|
||||||
|
|
||||||
// @phpstan-ignore-next-line
|
|
||||||
Assert::assertTrue(method_exists($this->value, $name), $message);
|
|
||||||
|
|
||||||
return $this;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Asserts that the value has the provided methods $names.
|
|
||||||
*
|
|
||||||
* @param iterable<array-key, string> $names
|
|
||||||
* @return self<TValue>
|
|
||||||
*/
|
|
||||||
public function toHaveMethods(iterable $names, string $message = ''): self
|
|
||||||
{
|
|
||||||
foreach ($names as $name) {
|
|
||||||
$this->toHaveMethod($name, message: $message);
|
|
||||||
}
|
|
||||||
|
|
||||||
return $this;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Asserts that two variables have the same value.
|
* Asserts that two variables have the same value.
|
||||||
*
|
*
|
||||||
|
|||||||
@ -49,16 +49,6 @@ final class HigherOrderCallables
|
|||||||
return $this->expect($value);
|
return $this->expect($value);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Execute the given callable after the test has executed the setup method.
|
|
||||||
*
|
|
||||||
* @deprecated This method is deprecated. Please use `defer` instead.
|
|
||||||
*/
|
|
||||||
public function tap(callable $callable): object
|
|
||||||
{
|
|
||||||
return $this->defer($callable);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Execute the given callable after the test has executed the setup method.
|
* Execute the given callable after the test has executed the setup method.
|
||||||
*/
|
*/
|
||||||
|
|||||||
@ -19,9 +19,9 @@
|
|||||||
↓ something todo later
|
↓ something todo later
|
||||||
↓ something todo later chained
|
↓ something todo later chained
|
||||||
↓ something todo later chained and with function body
|
↓ something todo later chained and with function body
|
||||||
↓ it may have an associated assignee [@nunomaduro]
|
↓ it may have an associated assignee []8;;https://github.com/nunomaduro\@nunomaduro]8;;\]
|
||||||
↓ it may have an associated issue #1
|
↓ it may have an associated issue ]8;;https://github.com/pestphp/pest/issues/1\#1]8;;\
|
||||||
↓ it may have an associated PR #1
|
↓ it may have an associated PR ]8;;https://github.com/pestphp/pest/pull/1\#1]8;;\
|
||||||
↓ it may have an associated note
|
↓ it may have an associated note
|
||||||
// a note
|
// a note
|
||||||
|
|
||||||
@ -35,3 +35,5 @@
|
|||||||
✓ override method
|
✓ override method
|
||||||
|
|
||||||
Tests: 17 todos, 3 passed (3 assertions)
|
Tests: 17 todos, 3 passed (3 assertions)
|
||||||
|
Duration: x.xxs
|
||||||
|
|
||||||
@ -19,9 +19,9 @@
|
|||||||
↓ something todo later
|
↓ something todo later
|
||||||
↓ something todo later chained
|
↓ something todo later chained
|
||||||
↓ something todo later chained and with function body
|
↓ something todo later chained and with function body
|
||||||
↓ it may have an associated assignee [@nunomaduro]
|
↓ it may have an associated assignee []8;;https://github.com/nunomaduro\@nunomaduro]8;;\]
|
||||||
↓ it may have an associated issue #1
|
↓ it may have an associated issue ]8;;https://github.com/pestphp/pest/issues/1\#1]8;;\
|
||||||
↓ it may have an associated PR #1
|
↓ it may have an associated PR ]8;;https://github.com/pestphp/pest/pull/1\#1]8;;\
|
||||||
↓ it may have an associated note
|
↓ it may have an associated note
|
||||||
// a note
|
// a note
|
||||||
|
|
||||||
@ -35,3 +35,5 @@
|
|||||||
✓ override method
|
✓ override method
|
||||||
|
|
||||||
Tests: 17 todos, 3 passed (3 assertions)
|
Tests: 17 todos, 3 passed (3 assertions)
|
||||||
|
Duration: x.xxs
|
||||||
|
|
||||||
39
tests/.pest/snapshots/Visual/Todo/todos.snap
Normal file
39
tests/.pest/snapshots/Visual/Todo/todos.snap
Normal file
@ -0,0 +1,39 @@
|
|||||||
|
|
||||||
|
TODO Tests\Features\BeforeEachProxiesToTestCallWithTodo - 4 todos
|
||||||
|
↓ is marked as todo 1
|
||||||
|
↓ is marked as todo 2
|
||||||
|
↓ is marked as todo 3
|
||||||
|
↓ shouldBeMarkedAsTodo
|
||||||
|
|
||||||
|
TODO Tests\Features\DatasetsTests - 1 todo
|
||||||
|
↓ forbids to define tests in Datasets dirs and Datasets.php files
|
||||||
|
|
||||||
|
TODO Tests\Features\Describe - 5 todos
|
||||||
|
↓ todo
|
||||||
|
↓ todo on hook → should not fail
|
||||||
|
↓ todo on hook → should run
|
||||||
|
↓ todo on describe → should not fail
|
||||||
|
↓ todo on describe → should run
|
||||||
|
|
||||||
|
TODO Tests\Features\Todo - 7 todos
|
||||||
|
↓ something todo later
|
||||||
|
↓ something todo later chained
|
||||||
|
↓ something todo later chained and with function body
|
||||||
|
↓ it may have an associated assignee []8;;https://github.com/nunomaduro\@nunomaduro]8;;\]
|
||||||
|
↓ it may have an associated issue ]8;;https://github.com/pestphp/pest/issues/1\#1]8;;\
|
||||||
|
↓ it may have an associated PR ]8;;https://github.com/pestphp/pest/pull/1\#1]8;;\
|
||||||
|
↓ it may have an associated note
|
||||||
|
// a note
|
||||||
|
|
||||||
|
PASS Tests\CustomTestCase\ChildTest
|
||||||
|
✓ override method
|
||||||
|
|
||||||
|
PASS Tests\CustomTestCase\ExecutedTest
|
||||||
|
✓ that gets executed
|
||||||
|
|
||||||
|
PASS Tests\CustomTestCase\ParentTest
|
||||||
|
✓ override method
|
||||||
|
|
||||||
|
Tests: 17 todos, 3 passed (3 assertions)
|
||||||
|
Duration: x.xxs
|
||||||
|
|
||||||
39
tests/.pest/snapshots/Visual/Todo/todos_in_parallel.snap
Normal file
39
tests/.pest/snapshots/Visual/Todo/todos_in_parallel.snap
Normal file
@ -0,0 +1,39 @@
|
|||||||
|
|
||||||
|
TODO Tests\Features\BeforeEachProxiesToTestCallWithTodo - 4 todos
|
||||||
|
↓ is marked as todo 1
|
||||||
|
↓ is marked as todo 2
|
||||||
|
↓ is marked as todo 3
|
||||||
|
↓ shouldBeMarkedAsTodo
|
||||||
|
|
||||||
|
TODO Tests\Features\DatasetsTests - 1 todo
|
||||||
|
↓ forbids to define tests in Datasets dirs and Datasets.php files
|
||||||
|
|
||||||
|
TODO Tests\Features\Describe - 5 todos
|
||||||
|
↓ todo
|
||||||
|
↓ todo on hook → should not fail
|
||||||
|
↓ todo on hook → should run
|
||||||
|
↓ todo on describe → should not fail
|
||||||
|
↓ todo on describe → should run
|
||||||
|
|
||||||
|
TODO Tests\Features\Todo - 7 todos
|
||||||
|
↓ something todo later
|
||||||
|
↓ something todo later chained
|
||||||
|
↓ something todo later chained and with function body
|
||||||
|
↓ it may have an associated assignee []8;;https://github.com/nunomaduro\@nunomaduro]8;;\]
|
||||||
|
↓ it may have an associated issue ]8;;https://github.com/pestphp/pest/issues/1\#1]8;;\
|
||||||
|
↓ it may have an associated PR ]8;;https://github.com/pestphp/pest/pull/1\#1]8;;\
|
||||||
|
↓ it may have an associated note
|
||||||
|
// a note
|
||||||
|
|
||||||
|
PASS Tests\CustomTestCase\ChildTest
|
||||||
|
✓ override method
|
||||||
|
|
||||||
|
PASS Tests\CustomTestCase\ExecutedTest
|
||||||
|
✓ that gets executed
|
||||||
|
|
||||||
|
PASS Tests\CustomTestCase\ParentTest
|
||||||
|
✓ override method
|
||||||
|
|
||||||
|
Tests: 17 todos, 3 passed (3 assertions)
|
||||||
|
Duration: x.xxs
|
||||||
|
|
||||||
@ -821,12 +821,6 @@
|
|||||||
✓ failure when the class has no method
|
✓ failure when the class has no method
|
||||||
✓ class has no method
|
✓ class has no method
|
||||||
|
|
||||||
PASS Tests\Features\Expect\toHaveMethods
|
|
||||||
✓ pass
|
|
||||||
✓ failures
|
|
||||||
✓ failures with custom message
|
|
||||||
✓ not failures
|
|
||||||
|
|
||||||
PASS Tests\Features\Expect\toHaveMethodsDocumented
|
PASS Tests\Features\Expect\toHaveMethodsDocumented
|
||||||
✓ it passes
|
✓ it passes
|
||||||
✓ it fails 1
|
✓ it fails 1
|
||||||
@ -1017,10 +1011,8 @@
|
|||||||
✓ it resolves expect callables correctly
|
✓ it resolves expect callables correctly
|
||||||
✓ does not treat method names as callables
|
✓ does not treat method names as callables
|
||||||
✓ it can defer a method until after test setup
|
✓ it can defer a method until after test setup
|
||||||
✓ it can tap a method until after test setup
|
|
||||||
✓ it can pass datasets into the expect callables with (1, 2, 3)
|
✓ it can pass datasets into the expect callables with (1, 2, 3)
|
||||||
✓ it can pass datasets into the defer callable with (1, 2, 3)
|
✓ it can pass datasets into the defer callable with (1, 2, 3)
|
||||||
✓ it can pass datasets into the tap callable with (1, 2, 3)
|
|
||||||
✓ it can pass shared datasets into callables with (1)
|
✓ it can pass shared datasets into callables with (1)
|
||||||
✓ it can pass shared datasets into callables with (2)
|
✓ it can pass shared datasets into callables with (2)
|
||||||
|
|
||||||
@ -1558,13 +1550,13 @@
|
|||||||
- visual snapshot of team city with ('Failure.php')
|
- visual snapshot of team city with ('Failure.php')
|
||||||
- visual snapshot of team city with ('SuccessOnly.php')
|
- visual snapshot of team city with ('SuccessOnly.php')
|
||||||
|
|
||||||
PASS Tests\Visual\Todo
|
WARN Tests\Visual\Todo
|
||||||
✓ todos
|
… todos → Snapshot created at [tests/.pest/snapshots/Visual/Todo/todos.snap]
|
||||||
✓ todos in parallel
|
… todos in parallel → Snapshot created at [tests/.pest/snapshots/Visual/Todo/todos_in_parallel.snap]
|
||||||
✓ todo
|
… todo → Snapshot created at [tests/.pest/snapshots/Visual/Todo/todo.snap]
|
||||||
✓ todo in parallel
|
… todo in parallel → Snapshot created at [tests/.pest/snapshots/Visual/Todo/todo_in_parallel.snap]
|
||||||
|
|
||||||
WARN Tests\Visual\Version
|
WARN Tests\Visual\Version
|
||||||
- visual snapshot of help command output
|
- visual snapshot of help command output
|
||||||
|
|
||||||
Tests: 2 deprecated, 4 warnings, 5 incomplete, 2 notices, 17 todos, 24 skipped, 1089 passed (2650 assertions)
|
Tests: 2 deprecated, 4 warnings, 9 incomplete, 2 notices, 17 todos, 24 skipped, 1079 passed (2613 assertions)
|
||||||
@ -1,26 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
use PHPUnit\Framework\ExpectationFailedException;
|
|
||||||
|
|
||||||
$object = new class
|
|
||||||
{
|
|
||||||
public function foo(): void {}
|
|
||||||
|
|
||||||
public function bar(): void {}
|
|
||||||
};
|
|
||||||
|
|
||||||
test('pass', function () use ($object) {
|
|
||||||
expect($object)->toHaveMethods(['foo', 'bar']);
|
|
||||||
});
|
|
||||||
|
|
||||||
test('failures', function () use ($object) {
|
|
||||||
expect($object)->toHaveMethods(['foo', 'bar', 'baz']);
|
|
||||||
})->throws(ExpectationFailedException::class);
|
|
||||||
|
|
||||||
test('failures with custom message', function () use ($object) {
|
|
||||||
expect($object)->toHaveMethods(['foo', 'bar', 'baz'], 'oh no!');
|
|
||||||
})->throws(ExpectationFailedException::class, 'oh no!');
|
|
||||||
|
|
||||||
test('not failures', function () use ($object) {
|
|
||||||
expect($object)->not->toHaveMethods(['foo', 'bar']);
|
|
||||||
})->throws(ExpectationFailedException::class);
|
|
||||||
@ -31,14 +31,6 @@ it('can defer a method until after test setup')
|
|||||||
->toBe('foo')
|
->toBe('foo')
|
||||||
->and('hello world')->toBeString();
|
->and('hello world')->toBeString();
|
||||||
|
|
||||||
it('can tap a method until after test setup')
|
|
||||||
->expect('foo')->toBeString()
|
|
||||||
->tap(function () {
|
|
||||||
expect($this)->toBeInstanceOf(TestCase::class);
|
|
||||||
})
|
|
||||||
->toBe('foo')
|
|
||||||
->and('hello world')->toBeString();
|
|
||||||
|
|
||||||
it('can pass datasets into the expect callables')
|
it('can pass datasets into the expect callables')
|
||||||
->with([[1, 2, 3]])
|
->with([[1, 2, 3]])
|
||||||
->expect(function (...$numbers) {
|
->expect(function (...$numbers) {
|
||||||
@ -54,12 +46,6 @@ it('can pass datasets into the defer callable')
|
|||||||
expect($numbers)->toBe([1, 2, 3]);
|
expect($numbers)->toBe([1, 2, 3]);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('can pass datasets into the tap callable')
|
|
||||||
->with([[1, 2, 3]])
|
|
||||||
->tap(function (...$numbers) {
|
|
||||||
expect($numbers)->toBe([1, 2, 3]);
|
|
||||||
});
|
|
||||||
|
|
||||||
it('can pass shared datasets into callables')
|
it('can pass shared datasets into callables')
|
||||||
->with('numbers.closure.wrapped')
|
->with('numbers.closure.wrapped')
|
||||||
->expect(function ($value) {
|
->expect(function ($value) {
|
||||||
|
|||||||
@ -16,7 +16,7 @@ $run = function () {
|
|||||||
|
|
||||||
test('parallel', function () use ($run) {
|
test('parallel', function () use ($run) {
|
||||||
expect($run('--exclude-group=integration'))
|
expect($run('--exclude-group=integration'))
|
||||||
->toContain('Tests: 2 deprecated, 4 warnings, 5 incomplete, 2 notices, 17 todos, 19 skipped, 1075 passed (2618 assertions)')
|
->toContain('Tests: 2 deprecated, 4 warnings, 5 incomplete, 2 notices, 17 todos, 19 skipped, 1069 passed (2585 assertions)')
|
||||||
->toContain('Parallel: 3 processes');
|
->toContain('Parallel: 3 processes');
|
||||||
})->skipOnWindows();
|
})->skipOnWindows();
|
||||||
|
|
||||||
|
|||||||
@ -11,31 +11,23 @@ $run = function (string $target, bool $parallel) {
|
|||||||
|
|
||||||
expect($process->getExitCode())->toBe(0);
|
expect($process->getExitCode())->toBe(0);
|
||||||
|
|
||||||
return removeAnsiEscapeSequences($process->getOutput());
|
$output = $process->getOutput();
|
||||||
|
|
||||||
|
return preg_replace('/Duration: \d+\.\d+s/', 'Duration: x.xxs', removeAnsiEscapeSequences($output));
|
||||||
};
|
};
|
||||||
|
|
||||||
$snapshot = function ($name) {
|
test('todos', function () use ($run) {
|
||||||
$testsPath = dirname(__DIR__);
|
expect($run('--todos', false))->toMatchSnapshot();
|
||||||
|
|
||||||
return file_get_contents(implode(DIRECTORY_SEPARATOR, [
|
|
||||||
$testsPath,
|
|
||||||
'.snapshots',
|
|
||||||
"$name.txt",
|
|
||||||
]));
|
|
||||||
};
|
|
||||||
|
|
||||||
test('todos', function () use ($run, $snapshot) {
|
|
||||||
expect($run('--todos', false))->toContain($snapshot('todos'));
|
|
||||||
})->skipOnWindows();
|
})->skipOnWindows();
|
||||||
|
|
||||||
test('todos in parallel', function () use ($run, $snapshot) {
|
test('todos in parallel', function () use ($run) {
|
||||||
expect($run('--todos', true))->toContain($snapshot('todos'));
|
expect($run('--todos', true))->toMatchSnapshot();
|
||||||
})->skipOnWindows();
|
})->skipOnWindows();
|
||||||
|
|
||||||
test('todo', function () use ($run, $snapshot) {
|
test('todo', function () use ($run) {
|
||||||
expect($run('--todo', false))->toContain($snapshot('todo'));
|
expect($run('--todo', false))->toMatchSnapshot();
|
||||||
})->skipOnWindows();
|
})->skipOnWindows();
|
||||||
|
|
||||||
test('todo in parallel', function () use ($run, $snapshot) {
|
test('todo in parallel', function () use ($run) {
|
||||||
expect($run('--todo', true))->toContain($snapshot('todo'));
|
expect($run('--todo', true))->toMatchSnapshot();
|
||||||
})->skipOnWindows();
|
})->skipOnWindows();
|
||||||
|
|||||||
Reference in New Issue
Block a user