Skip to content

Commit

Permalink
Add integration tests
Browse files Browse the repository at this point in the history
  • Loading branch information
brendt committed May 2, 2024
1 parent 13eeeef commit 1368452
Show file tree
Hide file tree
Showing 3 changed files with 58 additions and 0 deletions.
3 changes: 3 additions & 0 deletions phpunit.xml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@
<testsuite name="Unit">
<directory suffix="Test.php">./tests/Unit</directory>
</testsuite>
<testsuite name="Integration">
<directory suffix="Test.php">./tests/Integration</directory>
</testsuite>
</testsuites>
<coverage />
<source>
Expand Down
20 changes: 20 additions & 0 deletions tests/Integration/EventIntegrationTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<?php

namespace Tests\Tempest\Integration;

use App\Events\ItHappened;
use App\Events\MyEventHandler;
use Tests\Tempest\IntegrationTest;
use function Tempest\event;

class EventIntegrationTest extends IntegrationTest
{
public function test_event(): void
{
MyEventHandler::$itHappened = false;

event(new ItHappened());

$this->assertTrue(MyEventHandler::$itHappened);
}
}
35 changes: 35 additions & 0 deletions tests/IntegrationTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
<?php

namespace Tests\Tempest;

use PHPUnit\Framework\TestCase;
use Tempest\AppConfig;
use Tempest\Container\Container;
use Tempest\Discovery\DiscoveryLocation;
use Tempest\Kernel;

abstract class IntegrationTest extends TestCase
{
protected AppConfig $appConfig;
protected Kernel $kernel;
protected Container $container;

protected function setUp(): void
{
parent::setUp();

$this->appConfig = new AppConfig(
root: __DIR__ . '/..',
discoveryCache: true,
discoveryLocations: [
new DiscoveryLocation(
'App\\',
__DIR__ . '/../app/',
),
],
);

$this->kernel = new Kernel($this->appConfig);
$this->container = $this->kernel->init();
}
}

0 comments on commit 1368452

Please sign in to comment.