mirror of
https://github.com/pestphp/pest.git
synced 2026-03-06 07:47:22 +01:00
chore: adjusts tests
This commit is contained in:
@ -19,7 +19,7 @@
|
||||
"require": {
|
||||
"php": "^8.2.0",
|
||||
"brianium/paratest": "^7.5.0",
|
||||
"nunomaduro/collision": "^8.1.1",
|
||||
"nunomaduro/collision": "8.x-dev",
|
||||
"nunomaduro/termwind": "^2.0.1",
|
||||
"pestphp/pest-plugin": "^3.0.0",
|
||||
"pestphp/pest-plugin-arch": "^3.0.0",
|
||||
|
||||
@ -613,8 +613,6 @@ final class Expectation
|
||||
|
||||
/**
|
||||
* Asserts that the given expectation target to use the given trait.
|
||||
*
|
||||
* @param string $trait
|
||||
*/
|
||||
public function toUseTrait(string $trait): ArchExpectation
|
||||
{
|
||||
@ -703,8 +701,6 @@ final class Expectation
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Asserts that the given expectation target to implement the given interfaces.
|
||||
*
|
||||
|
||||
@ -254,8 +254,6 @@ final class OppositeExpectation
|
||||
|
||||
/**
|
||||
* Asserts that the given expectation target not to use the given trait.
|
||||
*
|
||||
* @param string $trait
|
||||
*/
|
||||
public function toUseTrait(string $trait): ArchExpectation
|
||||
{
|
||||
@ -282,8 +280,8 @@ final class OppositeExpectation
|
||||
|
||||
return true;
|
||||
},
|
||||
"not to use traits '" . implode("', '", $traits) . "'",
|
||||
FileLineFinder::where(fn(string $line): bool => str_contains($line, 'class')),
|
||||
"not to use traits '".implode("', '", $traits)."'",
|
||||
FileLineFinder::where(fn (string $line): bool => str_contains($line, 'class')),
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@ -31,7 +31,7 @@ final class ExceptionTrace
|
||||
$message = str_replace(self::UNDEFINED_METHOD, 'Call to undefined method ', $message);
|
||||
|
||||
if (class_exists((string) $class) && (is_countable(class_parents($class)) ? count(class_parents($class)) : 0) > 0 && array_values(class_parents($class))[0] === TestCase::class) { // @phpstan-ignore-line
|
||||
$message .= '. Did you forget to use the [pest()->uses()] function? Read more at: https://pestphp.com/docs/configuring-tests';
|
||||
$message .= '. Did you forget to use the [pest()->extend()] function? Read more at: https://pestphp.com/docs/configuring-tests';
|
||||
}
|
||||
|
||||
Reflection::setPropertyValue($throwable, 'message', $message);
|
||||
|
||||
@ -11,6 +11,6 @@ final class NotesTestCaseFilter implements TestCaseMethodFilter
|
||||
{
|
||||
public function accept(TestCaseMethodFactory $factory): bool
|
||||
{
|
||||
return count($factory->notes) > 0;
|
||||
return $factory->notes !== [];
|
||||
}
|
||||
}
|
||||
|
||||
@ -21,6 +21,7 @@
|
||||
SELECTION OPTIONS:
|
||||
--bail ........................... Stop execution upon first not-passed test
|
||||
--todos ........................ Output to standard output the list of todos
|
||||
--notes ......................... Output to standard output tests with notes
|
||||
--retry Run non-passing tests first and stop execution upon first error or failure
|
||||
--list-suites ................................... List available test suites
|
||||
--testsuite [name] ......... Only run tests from the specified test suite(s)
|
||||
|
||||
@ -928,6 +928,11 @@
|
||||
✓ it can handle a non-defined exception
|
||||
✓ it can handle a class not found Error
|
||||
|
||||
PASS Tests\Features\Expect\toUseTrait
|
||||
✓ pass
|
||||
✓ failures
|
||||
✓ not failures
|
||||
|
||||
PASS Tests\Features\Expect\unless
|
||||
✓ it pass
|
||||
✓ it failures
|
||||
@ -992,6 +997,31 @@
|
||||
✓ a "describe" group of tests → it is a test
|
||||
✓ a "describe" group of tests → it is a higher order message test
|
||||
|
||||
PASS Tests\Features\Note
|
||||
✓ it may have a static note
|
||||
// This is before each static note
|
||||
// This is a note
|
||||
// This is before each runtime note
|
||||
✓ it may have a runtime note
|
||||
// This is before each static note
|
||||
// This is before each runtime note
|
||||
// This is a runtime note
|
||||
✓ it may have static note and runtime note
|
||||
// This is before each static note
|
||||
// This is a static note
|
||||
// This is before each runtime note
|
||||
// This is a runtime note
|
||||
✓ nested → it may have static note and runtime note
|
||||
// This is describe static note
|
||||
// This is a static note within describe
|
||||
// This is before each runtime note
|
||||
// This is a runtime note within describe
|
||||
✓ multiple notes
|
||||
// This is before each static note
|
||||
// This is before each runtime note
|
||||
// This is a runtime note
|
||||
// This is another runtime note
|
||||
|
||||
NOTI Tests\Features\Notices
|
||||
! notice → This is a notice description // tests/Features/Notices.php:4
|
||||
! a "describe" group of tests → notice → This is a notice description // tests/Features/Notices.php:11
|
||||
@ -1470,4 +1500,4 @@
|
||||
WARN Tests\Visual\Version
|
||||
- visual snapshot of help command output
|
||||
|
||||
Tests: 2 deprecated, 4 warnings, 5 incomplete, 2 notices, 13 todos, 24 skipped, 1049 passed (2577 assertions)
|
||||
Tests: 2 deprecated, 4 warnings, 5 incomplete, 2 notices, 13 todos, 24 skipped, 1057 passed (2588 assertions, 18 notes)
|
||||
@ -29,6 +29,8 @@ describe('nested', function () {
|
||||
})->note('This is describe static note');
|
||||
|
||||
test('multiple notes', function () {
|
||||
expect(true)->toBeTrue(true);
|
||||
|
||||
$this->note([
|
||||
'This is a runtime note',
|
||||
'This is another runtime note',
|
||||
|
||||
@ -17,5 +17,5 @@ it('ensures the given closures reports the correct class name and suggests the [
|
||||
$this->get();
|
||||
})->throws(
|
||||
Error::class,
|
||||
'Call to undefined method Tests\Unit\Support\ExceptionTrace::get(). Did you forget to use the [uses()] function? Read more at: https://pestphp.com/docs/configuring-tests',
|
||||
'Call to undefined method Tests\Unit\Support\ExceptionTrace::get(). Did you forget to use the [pest()->extend()] function? Read more at: https://pestphp.com/docs/configuring-tests',
|
||||
);
|
||||
|
||||
@ -16,7 +16,7 @@ $run = function () {
|
||||
|
||||
test('parallel', function () use ($run) {
|
||||
expect($run('--exclude-group=integration'))
|
||||
->toContain('Tests: 2 deprecated, 4 warnings, 5 incomplete, 2 notices, 13 todos, 19 skipped, 1035 passed (2545 assertions)')
|
||||
->toContain('Tests: 2 deprecated, 4 warnings, 5 incomplete, 2 notices, 13 todos, 19 skipped, 1043 passed (2556 assertions)')
|
||||
->toContain('Parallel: 3 processes');
|
||||
})->skipOnWindows();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user