You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/1-essentials/07-testing.md
+4-6Lines changed: 4 additions & 6 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -22,7 +22,7 @@ composer phpunit
22
22
23
23
## Test-specific discovery locations
24
24
25
-
Tempest will only discover non-dev namespaces defined in composer.json automatically. That means that `{:hl-keyword:require-dev:}` namespaces aren't discovered automatically. Whenever you need Tempest to discover test-specific locations, you may specify them within the `discoverTestLocations()` method of the provided `IntegrationTest` class.
25
+
Tempest will only discover non-dev namespaces defined in composer.json automatically. That means that `{:hl-keyword:require-dev:}` namespaces aren't discovered automatically. Whenever you need Tempest to discover test-specific locations, you may specify them within the `discoverTestLocations()` method of the provided `IntegrationTest` class.
26
26
27
27
On top of that, Tempest _will_ look for files in the `tests/Fixtures` directory and discover them by default. You can override this behavior by providing your own implementation of `discoverTestLocations()`, where you can return an array of `DiscoveryLocation` objects (or nothing).
28
28
@@ -46,7 +46,7 @@ final class HomeControllerTest extends IntegrationTest
46
46
If you want to test code that interacts with the database, your test class can call the `setupDatabase()` method. This method will create and migrate a clean database for you on the fly.
47
47
48
48
```php
49
-
class TodoControllerTest extends IntegrationTest
49
+
final class TodoControllerTest extends IntegrationTest
50
50
{
51
51
protected function setUp(): void
52
52
{
@@ -60,8 +60,6 @@ class TodoControllerTest extends IntegrationTest
60
60
Most likely, you'll want to use a test-specific database connection. You can create a `database.config.php` file anywhere within test-specific discovery locations, and Tempest will use that connection instead of the project's default. For example, you can create a file `tests/Fixtures/database.config.php` like so:
61
61
62
62
```php tests/Fixtures/database.config.php
63
-
<?php
64
-
65
63
use Tempest\Database\Config\SQLiteConfig;
66
64
67
65
return new SQLiteConfig(
@@ -72,7 +70,7 @@ return new SQLiteConfig(
72
70
By default, no tables will be migrated. You can choose to provide a list of migrations that will be run for every test that calls `setupDatabase()`, or you can run specific migrations on a per-test basis.
73
71
74
72
```php
75
-
class TodoControllerTest extends IntegrationTest
73
+
final class TodoControllerTest extends IntegrationTest
76
74
{
77
75
protected function migrateDatabase(): void
78
76
{
@@ -85,7 +83,7 @@ class TodoControllerTest extends IntegrationTest
85
83
```
86
84
87
85
```php
88
-
class TodoControllerTest extends IntegrationTest
86
+
final class TodoControllerTest extends IntegrationTest
0 commit comments