• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

NexusPHP / tachycardia / 6604137746

22 Oct 2023 01:30PM UTC coverage: 98.325% (-1.7%) from 100.0%
6604137746

Pull #12

github

paulbalandan
Fix GithubRendererTest
Pull Request #12: feature: Update to PHPUnit 10

411 of 418 new or added lines in 30 files covered. (98.33%)

411 of 418 relevant lines covered (98.33%)

8.31 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

94.44
/src/Subscriber/PassedTestSubscriber.php
1
<?php
2

3
declare(strict_types=1);
4

5
/**
6
 * This file is part of Nexus Tachycardia.
7
 *
8
 * (c) 2021 John Paul E. Balandan, CPA <paulbalandan@gmail.com>
9
 *
10
 * For the full copyright and license information, please view
11
 * the LICENSE file that was distributed with this source code.
12
 */
13

14
namespace Nexus\PHPUnit\Tachycardia\Subscriber;
15

16
use Nexus\PHPUnit\Tachycardia\Metadata\Parser\Registry;
17
use Nexus\PHPUnit\Tachycardia\Parameter\Limit as ParameterLimit;
18
use Nexus\PHPUnit\Tachycardia\SlowTest\SlowTest;
19
use Nexus\PHPUnit\Tachycardia\SlowTest\SlowTestCollection;
20
use Nexus\PHPUnit\Tachycardia\Stopwatch;
21
use PHPUnit\Event\Code\TestMethod;
22
use PHPUnit\Event\Test\Passed;
23
use PHPUnit\Event\Test\PassedSubscriber;
24

25
final class PassedTestSubscriber implements PassedSubscriber
26
{
27
    public function __construct(
28
        private readonly SlowTestCollection $collection,
29
        private readonly Stopwatch $stopwatch,
30
        private readonly ParameterLimit $defaultTimeLimit,
31
    ) {}
6✔
32

33
    public function notify(Passed $event): void
34
    {
35
        $test = $event->test();
6✔
36

37
        if (! $test instanceof TestMethod) {
6✔
NEW
38
            return;
×
39
        }
40

41
        $limit = Registry::parser()->forClassAndMethod(
6✔
42
            $test->className(),
6✔
43
            $test->methodName(),
6✔
44
        )->reduce($this->defaultTimeLimit);
6✔
45

46
        if (! $limit->hasTimeLimit()) {
6✔
47
            return;
2✔
48
        }
49

50
        $duration = $this->stopwatch->stop($test, $event->telemetryInfo()->time());
6✔
51

52
        if ($duration->isLessThan($limit->getTimeLimit())) {
6✔
53
            return;
4✔
54
        }
55

56
        $this->collection->push(new SlowTest(
6✔
57
            test: $test,
6✔
58
            testTime: $duration,
6✔
59
            limit: $limit->getTimeLimit(),
6✔
60
        ));
6✔
61
    }
62
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc