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

tempestphp / tempest-framework / 14724150077

29 Apr 2025 05:39AM UTC coverage: 80.147% (-0.1%) from 80.275%
14724150077

Pull #1120

github

web-flow
Merge 4c33421e1 into afcfb4d76
Pull Request #1120: feat(container): support dynamic tags using dynamic initializers

23 of 23 new or added lines in 7 files covered. (100.0%)

23 existing lines in 5 files now uncovered.

11849 of 14784 relevant lines covered (80.15%)

107.18 hits per line

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

75.68
/src/Tempest/Framework/Testing/IntegrationTest.php
1
<?php
2

3
declare(strict_types=1);
4

5
namespace Tempest\Framework\Testing;
6

7
use DateTimeInterface;
8
use PHPUnit\Framework\TestCase;
9
use Tempest\Clock\Clock;
10
use Tempest\Clock\MockClock;
11
use Tempest\Console\Testing\ConsoleTester;
12
use Tempest\Container\Container;
13
use Tempest\Core\AppConfig;
14
use Tempest\Core\FrameworkKernel;
15
use Tempest\Core\Kernel;
16
use Tempest\Database\Migrations\MigrationManager;
17
use Tempest\EventBus\Testing\EventBusTester;
18
use Tempest\Framework\Testing\Http\HttpRouterTester;
19
use Tempest\Http\Method;
20
use Tempest\Router\GenericRequest;
21
use Tempest\Router\Request;
22
use Tempest\Storage\Testing\StorageTester;
23

24
use function Tempest\Support\Path\normalize;
25

26
/** @mago-expect maintainability/too-many-properties */
27
abstract class IntegrationTest extends TestCase
28
{
29
    protected string $root;
30

31
    /** @var \Tempest\Discovery\DiscoveryLocation[] */
32
    protected array $discoveryLocations = [];
33

34
    protected AppConfig $appConfig;
35

36
    protected Kernel $kernel;
37

38
    protected Container $container;
39

40
    protected ConsoleTester $console;
41

42
    protected HttpRouterTester $http;
43

44
    protected InstallerTester $installer;
45

46
    protected ViteTester $vite;
47

48
    protected EventBusTester $eventBus;
49

50
    protected StorageTester $storage;
51

52
    protected function setUp(): void
792✔
53
    {
54
        parent::setUp();
792✔
55

56
        // We force forward slashes for consistency even on Windows.
57
        $this->root ??= normalize(realpath(__DIR__ . '/../../'));
792✔
58

59
        $this->kernel ??= FrameworkKernel::boot(
792✔
60
            root: $this->root,
792✔
61
            discoveryLocations: $this->discoveryLocations,
792✔
62
        );
792✔
63

64
        $this->container = $this->kernel->container;
792✔
65

66
        $this->console = $this->container->get(ConsoleTester::class);
792✔
67
        $this->http = $this->container->get(HttpRouterTester::class);
792✔
68
        $this->installer = $this->container->get(InstallerTester::class);
792✔
69
        $this->eventBus = $this->container->get(EventBusTester::class);
792✔
70
        $this->storage = $this->container->get(StorageTester::class);
792✔
71

72
        $this->vite = $this->container->get(ViteTester::class);
792✔
73
        $this->vite->preventTagResolution();
792✔
74
        $this->vite->clearCaches();
792✔
75

76
        $request = new GenericRequest(Method::GET, '/', []);
792✔
77
        $this->container->singleton(Request::class, fn () => $request);
792✔
78
        $this->container->singleton(GenericRequest::class, fn () => $request);
792✔
79
    }
80

81
    protected function migrate(string|object ...$migrationClasses): void
50✔
82
    {
83
        $migrationManager = $this->container->get(MigrationManager::class);
50✔
84

85
        foreach ($migrationClasses as $migrationClass) {
50✔
86
            $migration = is_string($migrationClass) ? $this->container->get($migrationClass) : $migrationClass;
50✔
87

88
            $migrationManager->executeUp($migration);
50✔
89
        }
90
    }
91

92
    protected function clock(DateTimeInterface|string $now): MockClock
3✔
93
    {
94
        $clock = new MockClock($now);
3✔
95

96
        $this->container->singleton(Clock::class, fn () => $clock);
3✔
97

98
        return $clock;
3✔
99
    }
100

UNCOV
101
    protected function tearDown(): void
×
102
    {
UNCOV
103
        parent::tearDown();
×
104

105
        /** @phpstan-ignore-next-line */
UNCOV
106
        unset($this->root);
×
107
        /** @phpstan-ignore-next-line */
UNCOV
108
        unset($this->discoveryLocations);
×
109
        /** @phpstan-ignore-next-line */
UNCOV
110
        unset($this->appConfig);
×
111
        /** @phpstan-ignore-next-line */
UNCOV
112
        unset($this->kernel);
×
113
        /** @phpstan-ignore-next-line */
UNCOV
114
        unset($this->container);
×
115
        /** @phpstan-ignore-next-line */
UNCOV
116
        unset($this->console);
×
117
        /** @phpstan-ignore-next-line */
UNCOV
118
        unset($this->http);
×
119
    }
120
}
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

© 2025 Coveralls, Inc