diff --git a/composer.json b/composer.json index 6fd435a2..a478a0b4 100644 --- a/composer.json +++ b/composer.json @@ -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", diff --git a/src/Expectation.php b/src/Expectation.php index ac4c020c..155dc1d2 100644 --- a/src/Expectation.php +++ b/src/Expectation.php @@ -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. * diff --git a/src/Expectations/OppositeExpectation.php b/src/Expectations/OppositeExpectation.php index d2a3b112..9e5d67f3 100644 --- a/src/Expectations/OppositeExpectation.php +++ b/src/Expectations/OppositeExpectation.php @@ -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')), ); } diff --git a/src/Support/ExceptionTrace.php b/src/Support/ExceptionTrace.php index 5ab37f65..9af6aa5b 100644 --- a/src/Support/ExceptionTrace.php +++ b/src/Support/ExceptionTrace.php @@ -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); diff --git a/src/TestCaseMethodFilters/NotesTestCaseFilter.php b/src/TestCaseMethodFilters/NotesTestCaseFilter.php index 6678b659..cd33edec 100644 --- a/src/TestCaseMethodFilters/NotesTestCaseFilter.php +++ b/src/TestCaseMethodFilters/NotesTestCaseFilter.php @@ -11,6 +11,6 @@ final class NotesTestCaseFilter implements TestCaseMethodFilter { public function accept(TestCaseMethodFactory $factory): bool { - return count($factory->notes) > 0; + return $factory->notes !== []; } } diff --git a/tests/.pest/snapshots/Visual/Help/visual_snapshot_of_help_command_output.snap b/tests/.pest/snapshots/Visual/Help/visual_snapshot_of_help_command_output.snap index 15e52032..5d03115e 100644 --- a/tests/.pest/snapshots/Visual/Help/visual_snapshot_of_help_command_output.snap +++ b/tests/.pest/snapshots/Visual/Help/visual_snapshot_of_help_command_output.snap @@ -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) diff --git a/tests/.snapshots/success.txt b/tests/.snapshots/success.txt index 6d49eda4..6e00cb57 100644 --- a/tests/.snapshots/success.txt +++ b/tests/.snapshots/success.txt @@ -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) \ No newline at end of file + Tests: 2 deprecated, 4 warnings, 5 incomplete, 2 notices, 13 todos, 24 skipped, 1057 passed (2588 assertions, 18 notes) \ No newline at end of file diff --git a/tests/Features/Note.php b/tests/Features/Note.php index 1878a024..85868d48 100644 --- a/tests/Features/Note.php +++ b/tests/Features/Note.php @@ -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', diff --git a/tests/Unit/Support/ExceptionTrace.php b/tests/Unit/Support/ExceptionTrace.php index 1eb92066..7bf01898 100644 --- a/tests/Unit/Support/ExceptionTrace.php +++ b/tests/Unit/Support/ExceptionTrace.php @@ -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', ); diff --git a/tests/Visual/Parallel.php b/tests/Visual/Parallel.php index 6e25deef..51ad3d6d 100644 --- a/tests/Visual/Parallel.php +++ b/tests/Visual/Parallel.php @@ -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();