| 1 | 1 |
new file mode 100644 |
| ... | ... |
@@ -0,0 +1,29 @@ |
| 1 |
+<?php |
|
| 2 |
+ |
|
| 3 |
+namespace Telnyx\Util; |
|
| 4 |
+ |
|
| 5 |
+/** |
|
| 6 |
+ * @internal |
|
| 7 |
+ * @covers \Telnyx\Util\DefaultLogger |
|
| 8 |
+ */ |
|
| 9 |
+final class DefaultLoggerTest extends \PHPUnit\Framework\TestCase |
|
| 10 |
+{
|
|
| 11 |
+ public function testDefaultLogger() |
|
| 12 |
+ {
|
|
| 13 |
+ // DefaultLogger uses PHP's `error_log` function. In order to capture |
|
| 14 |
+ // the output, we need to temporarily redirect it to a temporary file. |
|
| 15 |
+ |
|
| 16 |
+ $capture = \tmpfile(); |
|
| 17 |
+ $origErrorLog = \ini_set('error_log', \stream_get_meta_data($capture)['uri']);
|
|
| 18 |
+ |
|
| 19 |
+ try {
|
|
| 20 |
+ $logger = new DefaultLogger(); |
|
| 21 |
+ $logger->error('This is a test message');
|
|
| 22 |
+ |
|
| 23 |
+ static::assertRegExp('/This is a test message/', \stream_get_contents($capture));
|
|
| 24 |
+ } finally {
|
|
| 25 |
+ \ini_set('error_log', $origErrorLog);
|
|
| 26 |
+ \fclose($capture); |
|
| 27 |
+ } |
|
| 28 |
+ } |
|
| 29 |
+} |