mirror of
https://github.com/pestphp/pest.git
synced 2026-09-05 14:23:34 +02:00
Compare commits
5 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 585de259a2 | |||
| 953664dce0 | |||
| 1dd959848c | |||
| 047753c836 | |||
| b63626a94d |
@@ -35,6 +35,7 @@ We cannot thank our sponsors enough for their incredible support in funding Pest
|
|||||||
- **[SerpApi](https://serpapi.com/?ref=nunomaduro)**
|
- **[SerpApi](https://serpapi.com/?ref=nunomaduro)**
|
||||||
- **[Typesense](https://typesense.org/?ref=nunomaduro)**
|
- **[Typesense](https://typesense.org/?ref=nunomaduro)**
|
||||||
- **[Bento](https://bentonow.com/?ref=nunomaduro)**
|
- **[Bento](https://bentonow.com/?ref=nunomaduro)**
|
||||||
- **[Redberry](https://redberry.international/laravel-development/)**
|
- **[Pixel](https://wearepixel.com.au/?ref=nunomaduro)**
|
||||||
|
- **[Redberry](https://redberry.international/laravel-development/?ref=nunomaduro)**
|
||||||
|
|
||||||
Pest is an open-sourced software licensed under the **[MIT license](https://opensource.org/licenses/MIT)**.
|
Pest is an open-sourced software licensed under the **[MIT license](https://opensource.org/licenses/MIT)**.
|
||||||
|
|||||||
@@ -280,7 +280,7 @@ trait Testable
|
|||||||
|
|
||||||
/** @var Tia $tia */
|
/** @var Tia $tia */
|
||||||
$tia = Container::getInstance()->get(Tia::class);
|
$tia = Container::getInstance()->get(Tia::class);
|
||||||
$status = $tia->getStatus(self::$__filename, $this::class.'::'.$this->name());
|
$status = $tia->getStatus(self::$__filename, $this->valueObjectForEvents()->id());
|
||||||
$replay = ReplayType::fromStatus($status);
|
$replay = ReplayType::fromStatus($status);
|
||||||
|
|
||||||
if ($replay !== ReplayType::None) {
|
if ($replay !== ReplayType::None) {
|
||||||
@@ -319,7 +319,7 @@ trait Testable
|
|||||||
private function __beginReplay(ReplayType $replay, Tia $tia): void
|
private function __beginReplay(ReplayType $replay, Tia $tia): void
|
||||||
{
|
{
|
||||||
$this->__replay = $replay;
|
$this->__replay = $replay;
|
||||||
$this->__replayAssertions = $tia->getAssertionCount($this::class.'::'.$this->name());
|
$this->__replayAssertions = $tia->getAssertionCount($this->valueObjectForEvents()->id());
|
||||||
$this->__ran = true;
|
$this->__ran = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+1
-1
@@ -6,7 +6,7 @@ namespace Pest;
|
|||||||
|
|
||||||
function version(): string
|
function version(): string
|
||||||
{
|
{
|
||||||
return '5.0.2';
|
return '5.0.3';
|
||||||
}
|
}
|
||||||
|
|
||||||
function testDirectory(string $file = ''): string
|
function testDirectory(string $file = ''): string
|
||||||
|
|||||||
@@ -22,7 +22,7 @@ final readonly class EnsureTiaAssertionsAreRecordedOnFinished implements Finishe
|
|||||||
|
|
||||||
if ($test instanceof TestMethod) {
|
if ($test instanceof TestMethod) {
|
||||||
$this->collector->recordAssertions(
|
$this->collector->recordAssertions(
|
||||||
$test->className().'::'.$test->methodName(),
|
$test->id(),
|
||||||
$event->numberOfAssertionsPerformed(),
|
$event->numberOfAssertionsPerformed(),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -21,7 +21,7 @@ final readonly class EnsureTiaResultsAreCollected implements PreparationStartedS
|
|||||||
$test = $event->test();
|
$test = $event->test();
|
||||||
|
|
||||||
if ($test instanceof TestMethod) {
|
if ($test instanceof TestMethod) {
|
||||||
$this->collector->testPrepared($test->className().'::'.$test->methodName(), $test->file());
|
$this->collector->testPrepared($test->id(), $test->file());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
|
|
||||||
Pest Testing Framework 5.0.2.
|
Pest Testing Framework 5.0.3.
|
||||||
|
|
||||||
USAGE: pest <file> [options]
|
USAGE: pest <file> [options]
|
||||||
|
|
||||||
|
|||||||
@@ -1,3 +1,3 @@
|
|||||||
|
|
||||||
Pest Testing Framework 5.0.2.
|
Pest Testing Framework 5.0.3.
|
||||||
|
|
||||||
|
|||||||
@@ -1908,6 +1908,11 @@
|
|||||||
✓ activateLinkTracking() → it tracks linked sources across consecutive tests
|
✓ activateLinkTracking() → it tracks linked sources across consecutive tests
|
||||||
✓ activateLinkTracking() → it records nothing while inactive
|
✓ activateLinkTracking() → it records nothing while inactive
|
||||||
|
|
||||||
|
PASS Tests\Unit\Plugins\Tia\ResultKey
|
||||||
|
✓ it keys a result per dataset row rather than per method
|
||||||
|
✓ it records assertions against the same per-dataset key
|
||||||
|
✓ it leaves a test without a dataset keyed by class and method
|
||||||
|
|
||||||
PASS Tests\Unit\Plugins\Tia\TableExtractor
|
PASS Tests\Unit\Plugins\Tia\TableExtractor
|
||||||
✓ fromSql() → it extracts tables from plain DML
|
✓ fromSql() → it extracts tables from plain DML
|
||||||
✓ fromSql() → it extracts tables from joins
|
✓ fromSql() → it extracts tables from joins
|
||||||
@@ -2186,4 +2191,4 @@
|
|||||||
✓ pass with dataset with ('my-datas-set-value')
|
✓ pass with dataset with ('my-datas-set-value')
|
||||||
✓ within describe → pass with dataset with ('my-datas-set-value')
|
✓ within describe → pass with dataset with ('my-datas-set-value')
|
||||||
|
|
||||||
Tests: 1 deprecated, 4 warnings, 5 incomplete, 2 notices, 40 todos, 35 skipped, 1542 passed (3375 assertions)
|
Tests: 1 deprecated, 4 warnings, 5 incomplete, 2 notices, 40 todos, 35 skipped, 1545 passed (3378 assertions)
|
||||||
@@ -0,0 +1,114 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
use Pest\Plugins\Tia\ResultCollector;
|
||||||
|
use Pest\Subscribers\EnsureTiaAssertionsAreRecordedOnFinished;
|
||||||
|
use Pest\Subscribers\EnsureTiaResultsAreCollected;
|
||||||
|
use PHPUnit\Event\Code\TestDox;
|
||||||
|
use PHPUnit\Event\Code\TestMethod;
|
||||||
|
use PHPUnit\Event\Telemetry\Duration;
|
||||||
|
use PHPUnit\Event\Telemetry\Info;
|
||||||
|
use PHPUnit\Event\Telemetry\MemoryUsage;
|
||||||
|
use PHPUnit\Event\Telemetry\System;
|
||||||
|
use PHPUnit\Event\Telemetry\SystemCpuTimeMeter;
|
||||||
|
use PHPUnit\Event\Telemetry\SystemGarbageCollectorStatusProvider;
|
||||||
|
use PHPUnit\Event\Telemetry\SystemMemoryMeter;
|
||||||
|
use PHPUnit\Event\Telemetry\SystemStopWatch;
|
||||||
|
use PHPUnit\Event\Test\Finished;
|
||||||
|
use PHPUnit\Event\Test\PreparationStarted;
|
||||||
|
use PHPUnit\Event\TestData\DataFromDataProvider;
|
||||||
|
use PHPUnit\Event\TestData\TestDataCollection;
|
||||||
|
use PHPUnit\Metadata\MetadataCollection;
|
||||||
|
|
||||||
|
function tiaResultKeyTestMethod(?string $dataSetName): TestMethod
|
||||||
|
{
|
||||||
|
$testData = $dataSetName === null
|
||||||
|
? TestDataCollection::fromArray([])
|
||||||
|
: TestDataCollection::fromArray([DataFromDataProvider::from($dataSetName, '', '')]);
|
||||||
|
|
||||||
|
return new TestMethod(
|
||||||
|
'Tests\Feature\OrderTest',
|
||||||
|
'it prices an order',
|
||||||
|
'/project/tests/Feature/OrderTest.php',
|
||||||
|
1,
|
||||||
|
new TestDox('Order', 'it prices an order', 'it prices an order'),
|
||||||
|
MetadataCollection::fromArray([]),
|
||||||
|
$testData,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
function tiaResultKeyTelemetryInfo(): Info
|
||||||
|
{
|
||||||
|
$system = new System(
|
||||||
|
new SystemStopWatch,
|
||||||
|
new SystemMemoryMeter,
|
||||||
|
new SystemGarbageCollectorStatusProvider,
|
||||||
|
new SystemCpuTimeMeter,
|
||||||
|
);
|
||||||
|
|
||||||
|
$zeroDuration = Duration::fromSecondsAndNanoseconds(0, 0);
|
||||||
|
$zeroMemory = MemoryUsage::fromBytes(0);
|
||||||
|
$zeroCpuTime = $system->snapshot()->userCpuTime();
|
||||||
|
|
||||||
|
return new Info(
|
||||||
|
$system->snapshot(),
|
||||||
|
$zeroDuration,
|
||||||
|
$zeroMemory,
|
||||||
|
$zeroDuration,
|
||||||
|
$zeroMemory,
|
||||||
|
$zeroCpuTime,
|
||||||
|
$zeroCpuTime,
|
||||||
|
$zeroCpuTime,
|
||||||
|
$zeroCpuTime,
|
||||||
|
$zeroCpuTime,
|
||||||
|
$zeroCpuTime,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
it('keys a result per dataset row rather than per method', function (): void {
|
||||||
|
$collector = new ResultCollector;
|
||||||
|
$subscriber = new EnsureTiaResultsAreCollected($collector);
|
||||||
|
|
||||||
|
$subscriber->notify(new PreparationStarted(tiaResultKeyTelemetryInfo(), tiaResultKeyTestMethod('opp')));
|
||||||
|
$collector->testPassed();
|
||||||
|
$collector->finishTest();
|
||||||
|
|
||||||
|
$subscriber->notify(new PreparationStarted(tiaResultKeyTelemetryInfo(), tiaResultKeyTestMethod('fake')));
|
||||||
|
$collector->testSkipped('the fake driver does not report balances');
|
||||||
|
$collector->finishTest();
|
||||||
|
|
||||||
|
// Without the dataset in the key both rows write to `Class::method`, so the
|
||||||
|
// second one overwrites the first and a replay hands every row the same
|
||||||
|
// status — a passing row reported as skipped, or a failing one as passed.
|
||||||
|
expect(array_keys($collector->all()))->toBe([
|
||||||
|
'Tests\Feature\OrderTest::it prices an order#opp',
|
||||||
|
'Tests\Feature\OrderTest::it prices an order#fake',
|
||||||
|
]);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('records assertions against the same per-dataset key', function (): void {
|
||||||
|
$collector = new ResultCollector;
|
||||||
|
|
||||||
|
new EnsureTiaResultsAreCollected($collector)->notify(
|
||||||
|
new PreparationStarted(tiaResultKeyTelemetryInfo(), tiaResultKeyTestMethod('opp')),
|
||||||
|
);
|
||||||
|
$collector->testPassed();
|
||||||
|
|
||||||
|
new EnsureTiaAssertionsAreRecordedOnFinished($collector)->notify(
|
||||||
|
new Finished(tiaResultKeyTelemetryInfo(), tiaResultKeyTestMethod('opp'), 7),
|
||||||
|
);
|
||||||
|
|
||||||
|
expect($collector->all()['Tests\Feature\OrderTest::it prices an order#opp']['assertions'])->toBe(7);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('leaves a test without a dataset keyed by class and method', function (): void {
|
||||||
|
$collector = new ResultCollector;
|
||||||
|
|
||||||
|
new EnsureTiaResultsAreCollected($collector)->notify(
|
||||||
|
new PreparationStarted(tiaResultKeyTelemetryInfo(), tiaResultKeyTestMethod(null)),
|
||||||
|
);
|
||||||
|
$collector->testPassed();
|
||||||
|
|
||||||
|
expect(array_keys($collector->all()))->toBe(['Tests\Feature\OrderTest::it prices an order']);
|
||||||
|
});
|
||||||
@@ -24,13 +24,13 @@ test('parallel', function () use ($run): void {
|
|||||||
$file = file_get_contents(__FILE__);
|
$file = file_get_contents(__FILE__);
|
||||||
$file = preg_replace(
|
$file = preg_replace(
|
||||||
'/\$expected = \'.*?\';/',
|
'/\$expected = \'.*?\';/',
|
||||||
"\$expected = '1 deprecated, 4 warnings, 5 incomplete, 3 notices, 40 todos, 27 skipped, 1525 passed (3322 assertions)';",
|
"\$expected = '1 deprecated, 4 warnings, 5 incomplete, 3 notices, 40 todos, 27 skipped, 1528 passed (3325 assertions)';",
|
||||||
$file,
|
$file,
|
||||||
);
|
);
|
||||||
file_put_contents(__FILE__, $file);
|
file_put_contents(__FILE__, $file);
|
||||||
}
|
}
|
||||||
|
|
||||||
$expected = '1 deprecated, 4 warnings, 5 incomplete, 3 notices, 40 todos, 27 skipped, 1525 passed (3322 assertions)';
|
$expected = '1 deprecated, 4 warnings, 5 incomplete, 3 notices, 40 todos, 27 skipped, 1528 passed (3325 assertions)';
|
||||||
|
|
||||||
expect($output)
|
expect($output)
|
||||||
->toContain("Tests: {$expected}")
|
->toContain("Tests: {$expected}")
|
||||||
|
|||||||
Reference in New Issue
Block a user