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
To update a property in a configuration object, you may simply assign a new value. Due to the object being a singleton, the modification will be persisted throught the rest of the application's lifecycle.
54
+
To update a property in a configuration object, you may simply assign a new value. Due to the object being a singleton, the modification will be persisted through the rest of the application's lifecycle.
55
55
56
56
```php
57
57
use Tempest\Support\Random;
@@ -81,7 +81,7 @@ final class SlackConfig
81
81
public string $token,
82
82
public string $baseUrl,
83
83
public string $applicationId,
84
-
public string $userAgent,
84
+
public ?string $userAgent = null,
85
85
) {}
86
86
}
87
87
```
@@ -120,7 +120,7 @@ final class SlackConnector extends HttpConnector
120
120
121
121
## Per-environment configuration
122
122
123
-
Whenever possible, you should have a single configuration file per feature. You may use the `Tempest\env()` function inside that file to reference credentials and environment-specific values.
123
+
Whenever possible, you should have a single configuration file per feature. You may use the {b`Tempest\env()`} function inside that file to reference credentials and environment-specific values.
124
124
125
125
However, it's sometimes needed to have completely different configurations in development and in production. For instance, you may use S3 for your [storage](../2-features/05-file-storage.md) in production, but use the local filesystem during development.
126
126
@@ -135,6 +135,13 @@ return new S3StorageConfig(
135
135
);
136
136
```
137
137
138
+
The following suffixes are supported:
139
+
140
+
-`.prd.config.php`, `.prod.config.php`, and `.production.config.php` for the production environment.
141
+
-`.stg.config.php` and `.staging.config.php` for the staging environment.
142
+
-`.dev.config.php` and `.local.config.php` for the development environment.
143
+
-`.test.config.php` and `.testing.config.php` for the testing environment.
144
+
138
145
## Disabling the configuration cache
139
146
140
147
During development, Tempest will discover configuration files every time the framework is booted. In a production environment, configuration files are automatically cached.
Copy file name to clipboardExpand all lines: docs/1-essentials/07-testing.md
+12Lines changed: 12 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -125,6 +125,18 @@ $this->console
125
125
126
126
And many, many more.
127
127
128
+
## Spoofing the environment
129
+
130
+
By default, Tempest provides a `phpunit.xml` that sets the `ENVIRONMENT` variable to `testing`. This is needed so that Tempest can adapt its boot process and load the proper configuration files for the testing environment.
131
+
132
+
During tests, you may want to test different paths of your application depending on the environment. For instance, you may want to test that certain features are only available in production. To do this, you may override the {b`Tempest\Core\Environment`} singleton:
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.
0 commit comments