@@ -15,6 +15,7 @@ class ConfigurationTest extends TestCase
15
15
private const APPLICATION_DIR = self ::ROOT_DIR .'/app ' ;
16
16
private const REPORT_DIR = self ::APPLICATION_DIR .'/report ' ;
17
17
private const LOGS_DIR = self ::APPLICATION_DIR .'/logs ' ;
18
+ private const CUSTOM_LOG_PROVIDER = self ::APPLICATION_DIR .'/src/Tombstone/LogProvider.php ' ;
18
19
19
20
private const FULL_CONFIG = [
20
21
'source_code ' => [
@@ -29,6 +30,10 @@ class ConfigurationTest extends TestCase
29
30
],
30
31
'logs ' => [
31
32
'directory ' => self ::LOGS_DIR ,
33
+ 'custom ' => [
34
+ 'file ' => self ::CUSTOM_LOG_PROVIDER ,
35
+ 'class ' => 'LogProvider ' ,
36
+ ],
32
37
],
33
38
'report ' => [
34
39
'php ' => self ::REPORT_DIR .'/report.php ' ,
@@ -170,6 +175,7 @@ public function getConfigTreeBuilder_missingLogNode_throwsException(): void
170
175
public function getConfigTreeBuilder_emptyLogDirectory_throwsException (): void
171
176
{
172
177
$ config = self ::FULL_CONFIG ;
178
+ unset($ config ['logs ' ]['custom ' ]);
173
179
$ config ['logs ' ]['directory ' ] = '' ;
174
180
175
181
$ this ->expectException (InvalidConfigurationException::class);
@@ -183,13 +189,42 @@ public function getConfigTreeBuilder_emptyLogDirectory_throwsException(): void
183
189
public function getConfigTreeBuilder_invalidLogDirectory_throwsException (): void
184
190
{
185
191
$ config = self ::FULL_CONFIG ;
192
+ unset($ config ['logs ' ]['custom ' ]);
186
193
$ config ['logs ' ]['directory ' ] = 'invalid ' ;
187
194
188
195
$ this ->expectException (InvalidConfigurationException::class);
189
196
$ this ->expectExceptionMessage ('Must be a valid directory path, given: "invalid" ' );
190
197
$ this ->processConfiguration ($ config );
191
198
}
192
199
200
+ /**
201
+ * @test
202
+ */
203
+ public function getConfigTreeBuilder_missingCustomLogProviderClass_throwsException (): void
204
+ {
205
+ $ config = self ::FULL_CONFIG ;
206
+ unset($ config ['logs ' ]['directory ' ]);
207
+ unset($ config ['logs ' ]['custom ' ]['class ' ]);
208
+
209
+ $ this ->expectException (InvalidConfigurationException::class);
210
+ $ this ->expectExceptionMessageMatches ('/"class".*must be configured/ ' );
211
+ $ this ->processConfiguration ($ config );
212
+ }
213
+
214
+ /**
215
+ * @test
216
+ */
217
+ public function getConfigTreeBuilder_customLogProviderInvalidFile_throwsException (): void
218
+ {
219
+ $ config = self ::FULL_CONFIG ;
220
+ unset($ config ['logs ' ]['directory ' ]);
221
+ $ config ['logs ' ]['custom ' ]['file ' ] = 'invalid ' ; // Not a valid file
222
+
223
+ $ this ->expectException (InvalidConfigurationException::class);
224
+ $ this ->expectExceptionMessage ('Must be a valid file path, given: "invalid" ' );
225
+ $ this ->processConfiguration ($ config );
226
+ }
227
+
193
228
/**
194
229
* @test
195
230
*/
0 commit comments