chore: fixes test suite

This commit is contained in:
Nuno Maduro
2024-04-28 12:02:42 +01:00
parent a2cb78710d
commit 2070538fd3
7 changed files with 14 additions and 54 deletions

View File

@ -54,7 +54,7 @@ final class AfterEachCall
$proxies = $this->proxies; $proxies = $this->proxies;
$afterEachTestCase = ChainableClosure::boundWhen( $afterEachTestCase = ChainableClosure::boundWhen(
fn (): bool => is_null($describing) || $this->__describing === $describing, // @phpstan-ignore-line fn (): bool => is_null($describing) || $this->__describing === $describing,
ChainableClosure::bound(fn () => $proxies->chain($this), $this->closure)->bindTo($this, self::class), // @phpstan-ignore-line ChainableClosure::bound(fn () => $proxies->chain($this), $this->closure)->bindTo($this, self::class), // @phpstan-ignore-line
)->bindTo($this, self::class); )->bindTo($this, self::class);

View File

@ -69,7 +69,7 @@ final class BeforeEachCall
}; };
$beforeEachTestCase = ChainableClosure::boundWhen( $beforeEachTestCase = ChainableClosure::boundWhen(
fn (): bool => is_null($describing) || $this->__describing === $describing, // @phpstan-ignore-line fn (): bool => is_null($describing) || $this->__describing === $describing,
ChainableClosure::bound(fn () => $testCaseProxies->chain($this), $this->closure)->bindTo($this, self::class), // @phpstan-ignore-line ChainableClosure::bound(fn () => $testCaseProxies->chain($this), $this->closure)->bindTo($this, self::class), // @phpstan-ignore-line
)->bindTo($this, self::class); )->bindTo($this, self::class);

View File

@ -10,8 +10,7 @@ namespace Pest\PendingCalls\Concerns;
trait Describable trait Describable
{ {
/** /**
* Note: this is property is not used; however, * Note: this is property is not used; however, it gets added automatically by rector php.
* it gets added automatically by rector php.
*/ */
public string $__describing; public string $__describing;

View File

@ -170,9 +170,9 @@
✓ it is a test ✓ it is a test
✓ it uses correct parent class ✓ it uses correct parent class
FAIL Tests\Features\Deprecated DEPR Tests\Features\Deprecated
! deprecated → str_contains(): Passing null to parameter #1 ($haystack) of type string is deprecated // tests/Features/Deprecated.php:6 ! deprecated → str_contains(): Passing null to parameter #1 ($haystack) of type string is deprecated // tests/Features/Deprecated.php:4
user deprecated ! user deprecated → Since foo 1.0: This is a deprecation description // tests/Features/Deprecated.php:10
PASS Tests\Features\Describe - 5 todos PASS Tests\Features\Describe - 5 todos
✓ before each ✓ before each
@ -1415,8 +1415,8 @@
✓ junit output ✓ junit output
- junit with parallel → Not working yet - junit with parallel → Not working yet
FAIL Tests\Visual\Parallel PASS Tests\Visual\Parallel
parallel parallel
✓ a parallel test can extend another test with same name ✓ a parallel test can extend another test with same name
PASS Tests\Visual\SingleTestOrDirectory PASS Tests\Visual\SingleTestOrDirectory
@ -1439,44 +1439,5 @@
WARN Tests\Visual\Version WARN Tests\Visual\Version
- visual snapshot of help command output - visual snapshot of help command output
────────────────────────────────────────────────────────────────────────────
FAILED Tests\Features\Deprecated > user deprecated Error
Call to undefined function trigger_deprecation()
at tests/Features/Deprecated.php:12 Tests: 2 deprecated, 4 warnings, 5 incomplete, 2 notices, 13 todos, 20 skipped, 1031 passed (2520 assertions)
8▕ expect(true)->toBeTrue();
9▕ });
10▕
11▕ test('user deprecated', function () {
➜ 12▕ trigger_deprecation('foo', '1.0', 'This is a deprecation description');
13▕
14▕ expect(true)->toBeTrue();
15▕ });
16▕
1 tests/Features/Deprecated.php:12
────────────────────────────────────────────────────────────────────────────
FAILED Tests\Visual\Parallel > parallel
Expected: \n
...............sssssss......................................................\n
...............................................................s....!......\n
... (36 more lines)
To contain: Tests: 1 deprecated, 4 warnings, 5 incomplete, 2 notices, 13 todos, 16 skipped, 1017 passed (2483 assertions)
at tests/Visual/Parallel.php:19
15▕ };
16▕
17▕ test('parallel', function () use ($run) {
18▕ expect($run('--exclude-group=integration'))
➜ 19▕ ->toContain('Tests: 1 deprecated, 4 warnings, 5 incomplete, 2 notices, 13 todos, 16 skipped, 1017 passed (2483 assertions)')
20▕ ->toContain('Parallel: 3 processes');
21▕ })->skipOnWindows();
22▕
23▕ test('a parallel test can extend another test with same name', function () use ($run) {
1 tests/Visual/Parallel.php:19
Tests: 1 deprecated, 2 failed, 4 warnings, 5 incomplete, 2 notices, 13 todos, 20 skipped, 1030 passed (2518 assertions)

View File

@ -1,7 +1,5 @@
<?php <?php
error_reporting(E_ALL);
test('deprecated', function () { test('deprecated', function () {
str_contains(null, null); str_contains(null, null);
@ -9,7 +7,7 @@ test('deprecated', function () {
}); });
test('user deprecated', function () { test('user deprecated', function () {
trigger_deprecation('foo', '1.0', 'This is a deprecation description'); trigger_error('Since foo 1.0: This is a deprecation description', \E_USER_DEPRECATED);
@trigger_error(($package || $version ? "Since $package $version: " : '').($args ? vsprintf($message, $args) : $message), \E_USER_DEPRECATED);
expect(true)->toBeTrue(); expect(true)->toBeTrue();
}); });

View File

@ -3,6 +3,8 @@
use Tests\CustomTestCase\CustomTestCase; use Tests\CustomTestCase\CustomTestCase;
use Tests\CustomTestCaseInSubFolders\SubFolder\SubFolder\CustomTestCaseInSubFolder; use Tests\CustomTestCaseInSubFolders\SubFolder\SubFolder\CustomTestCaseInSubFolder;
error_reporting(E_ALL);
$GLOBALS['__PEST_INTERNAL_TEST_SUITE'] = true; $GLOBALS['__PEST_INTERNAL_TEST_SUITE'] = true;
uses(CustomTestCaseInSubFolder::class)->in('PHPUnit/CustomTestCaseInSubFolders/SubFolder/SubFolder'); uses(CustomTestCaseInSubFolder::class)->in('PHPUnit/CustomTestCaseInSubFolders/SubFolder/SubFolder');

View File

@ -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: 1 deprecated, 4 warnings, 5 incomplete, 2 notices, 13 todos, 16 skipped, 1017 passed (2483 assertions)') ->toContain('Tests: 2 deprecated, 4 warnings, 5 incomplete, 2 notices, 13 todos, 15 skipped, 1017 passed (2488 assertions)')
->toContain('Parallel: 3 processes'); ->toContain('Parallel: 3 processes');
})->skipOnWindows(); })->skipOnWindows();