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: src/Web/Documentation/content/1.x/1-essentials/07-testing.md
+27-1Lines changed: 27 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -38,13 +38,39 @@ final class HomeControllerTest extends IntegrationTestCase
38
38
}
39
39
```
40
40
41
+
## Additional configuration
42
+
43
+
By default, only the entries inside the `require` key of the `composer.json` file are discovered.
44
+
As such if the tests need additional configuration, these locations need to be discovered manually.
45
+
In which case you may add these locations to the `discoveryLocations` property of the `IntegrationTestCase` class.
46
+
47
+
For example `tests/Config` contains configuration that is only needed for tests, like database configuration.
48
+
49
+
```php tests/IntegrationTestCase.php
50
+
use Tempest\Core\DiscoveryLocation;
51
+
52
+
final class IntegrationTestCase extends TestCase
53
+
{
54
+
protected string $root = __DIR__ . '/../';
55
+
56
+
protected function setUp(): void
57
+
{
58
+
$this->discoveryLocations = [
59
+
new DiscoveryLocation(namespace: 'Tests\\Config', path: __DIR__ . '/Config'),
60
+
];
61
+
62
+
parent::setUp();
63
+
}
64
+
}
65
+
```
66
+
41
67
## Changing the location of tests
42
68
43
69
The `phpunit.xml` file contains a `{html}<testsuite>` element that configures the directory in which PHPUnit looks for test files. This may be changed to follow any rule of your convenience.
44
70
45
71
For instance, you may colocate test files and their corresponding class by changing the `{html}suffix` attribute in `phpunit.xml` to the following:
0 commit comments