chore: adjusts tests

This commit is contained in:
Nuno Maduro
2024-09-03 14:09:03 +01:00
parent 8920b850e1
commit e2d360b1b5
36 changed files with 187 additions and 84 deletions

View File

@ -1286,6 +1286,13 @@
! user warning → This is a warning description
! a "describe" group of tests → user warning → This is a warning description
PASS Tests\Features\Wip
✓ it may have an associated assignee [@nunomaduro]
✓ it may have an associated issue #1
✓ it may have an associated PR #1
✓ it may have an associated note
// a note
WARN Tests\Fixtures\CollisionTest
- error
- success
@ -1308,7 +1315,7 @@
PASS Tests\Hooks\BeforeEachTest
✓ global beforeEach execution order
PASS Tests\Overrides\VersionsTest
FAIL Tests\Overrides\VersionsTest
✓ versions with dataset "Runner/Filter/NameFilterIterator.php"
✓ versions with dataset "Runner/ResultCache/DefaultResultCache.php"
✓ versions with dataset "Runner/TestSuiteLoader.php"
@ -1316,7 +1323,7 @@
✓ versions with dataset "TextUI/Output/Default/ProgressPrinter/Subscriber/TestSkippedSubscriber.php"
✓ versions with dataset "TextUI/TestSuiteFilterProcessor.php"
✓ versions with dataset "Event/Value/ThrowableBuilder.php"
versions with dataset "Logging/JUnit/JunitXmlLogger.php"
versions with dataset "Logging/JUnit/JunitXmlLogger.php"
PASS Tests\PHPUnit\CustomAffixes\InvalidTestName
✓ it runs file names like @#$%^&()-_=+.php
@ -1542,8 +1549,8 @@
✓ junit output
- junit with parallel → Not working yet
PASS Tests\Visual\Parallel
parallel
FAIL Tests\Visual\Parallel
parallel
✓ a parallel test can extend another test with same name
PASS Tests\Visual\SingleTestOrDirectory
@ -1566,5 +1573,45 @@
WARN Tests\Visual\Version
- visual snapshot of help command output
────────────────────────────────────────────────────────────────────────────
FAILED Tests\Overrides\VersionsTest > versions with dataset "Logging/JUn…
Failed asserting that two strings are identical.
-'676273f1fe483877cf2d95c5aedbf9ae5d6a8e2f4c12d6ce716df6591e6db023'
+'01974a686eba69b5fbb87a904d936eae2176e39567616898c5b758db71d87a22'
Tests: 2 deprecated, 4 warnings, 5 incomplete, 2 notices, 17 todos, 28 skipped, 1085 passed (2617 assertions)
at tests/Overrides/VersionsTest.php:8
4▕
5▕ use Pest\Bootstrappers\BootOverrides;
6▕
7▕ test('versions', function (string $vendorPath, string $expectedHash) {
➜ 8▕ expect(hash_file('sha256', $vendorPath))->toBe($expectedHash);
9▕ })->with(function () {
10▕ foreach (BootOverrides::FILES as $hash => $file) {
11▕ $path = implode(DIRECTORY_SEPARATOR, [
12▕ dirname(__DIR__, 2),
────────────────────────────────────────────────────────────────────────────
FAILED Tests\Visual\Parallel > parallel
Expected: \n
........ss...s............sssssss.s.........................................\n
............................................................................\n
... (40 more lines)
To contain: Tests: 2 deprecated, 4 warnings, 5 incomplete, 2 notices, 17 todos, 19 skipped, 1079 passed (2597 assertions)
at tests/Visual/Parallel.php:19
15▕ };
16▕
17▕ test('parallel', function () use ($run) {
18▕ expect($run('--exclude-group=integration'))
➜ 19▕ ->toContain('Tests: 2 deprecated, 4 warnings, 5 incomplete, 2 notices, 17 todos, 19 skipped, 1079 passed (2597 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: 2 deprecated, 2 failed, 4 warnings, 5 incomplete, 2 notices, 17 todos, 28 skipped, 1087 passed (2620 assertions)

View File

@ -150,7 +150,7 @@ test('high order test with skip')
dd('This should not run 5');
});
uses(Postable::class);
pest()->use(Postable::class);
/**
* @return TestCase|TestCall|Gettable

View File

@ -10,7 +10,7 @@ class InheritanceTest extends TestCase
}
}
uses(InheritanceTest::class);
pest()->extend(InheritanceTest::class);
it('is a test', function () {
expect(true)->toBeTrue();

View File

@ -3,7 +3,7 @@
use Pest\PendingCalls\TestCall;
use PHPUnit\Framework\TestCase;
uses(Gettable::class);
pest()->use(Gettable::class);
/**
* @return TestCase|TestCall|Gettable

17
tests/Features/Wip.php Normal file
View File

@ -0,0 +1,17 @@
<?php
it('may have an associated assignee', function () {
expect(true)->toBeTrue();
})->wip(assignee: 'nunomaduro');
it('may have an associated issue', function () {
expect(true)->toBeTrue();
})->wip(issue: 1);
it('may have an associated PR', function () {
expect(true)->toBeTrue();
})->wip(pr: 1);
it('may have an associated note', function () {
expect(true)->toBeTrue();
})->wip(note: 'a note');

View File

@ -1,6 +1,6 @@
<?php
uses()->afterEach(function () {
pest()->afterEach(function () {
expect($this)
->toHaveProperty('ith')
->and($this->ith)

View File

@ -1,6 +1,6 @@
<?php
uses()->beforeEach(function () {
pest()->beforeEach(function () {
expect($this)
->toHaveProperty('baz')
->and($this->baz)

View File

@ -10,7 +10,7 @@ class MyCustomClassTest extends PHPUnit\Framework\TestCase
}
}
uses(MyCustomClassTest::class);
pest()->extend(MyCustomClassTest::class);
test('custom traits can be used', function () {
$this->assertTrueIsTrue();

View File

@ -1,6 +1,6 @@
<?php
uses(Tests\CustomTestCase\CustomTestCase::class)->in(__DIR__);
pest()->use(Tests\CustomTestCase\CustomTestCase::class)->in(__DIR__);
test('closure was bound to CustomTestCase', function () {
$this->assertCustomTrue();

View File

@ -16,7 +16,7 @@ abstract class MyCustomClass extends PHPUnit\Framework\TestCase
}
}
uses(MyCustomClass::class, MyCustomTrait::class);
pest()->extend(MyCustomClass::class)->use(MyCustomTrait::class);
test('custom traits can be used', function () {
$this->assertTrueIsTrue();

View File

@ -7,7 +7,7 @@ error_reporting(E_ALL);
$GLOBALS['__PEST_INTERNAL_TEST_SUITE'] = true;
pest()->context()->github('pestphp/pest');
pest()->project()->github('pestphp/pest');
pest()->in('PHPUnit/CustomTestCaseInSubFolders/SubFolder/SubFolder')->use(CustomTestCaseInSubFolder::class);

View File

@ -4,7 +4,7 @@ use Pest\Exceptions\ShouldNotHappen;
use Pest\Support\Container;
use Pest\TestSuite;
uses()->group('container');
pest()->group('container');
beforeEach(function () {
$this->container = new Container;

View File

@ -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, 17 todos, 19 skipped, 1075 passed (2593 assertions)')
->toContain('Tests: 2 deprecated, 4 warnings, 5 incomplete, 2 notices, 17 todos, 19 skipped, 1079 passed (2597 assertions)')
->toContain('Parallel: 3 processes');
})->skipOnWindows();