Skip to content

Commit e56395f

Browse files
committed
Show enums in input tables
1 parent edbf44d commit e56395f

2 files changed

Lines changed: 21 additions & 2 deletions

File tree

src/Views/exceptions/development.php

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -390,12 +390,19 @@
390390
</tr>
391391
</thead>
392392
<tbody>
393-
<?php foreach ($values as $field => $value) : ?>
393+
<?php
394+
foreach ($values as $field => $value) :
395+
if ($value instanceof UnitEnum) {
396+
$value = $value::class . '::' . $value->name;
397+
}
398+
?>
394399
<tr>
395400
<th><?= htmlentities($field) ?></th>
396401
<td><?= htmlentities((string) $value) ?></td>
397402
</tr>
398-
<?php endforeach ?>
403+
<?php
404+
endforeach
405+
?>
399406
</tbody>
400407
</table>
401408
<?php endforeach ?>

tests/ExceptionHandlerTest.php

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
use Framework\Log\Logger;
1717
use Framework\Log\Loggers\FileLogger;
1818
use Framework\Log\Loggers\SysLogger;
19+
use Framework\Log\LogLevel;
1920
use PHPUnit\Framework\TestCase;
2021

2122
final class ExceptionHandlerTest extends TestCase
@@ -63,6 +64,17 @@ public function testDevelopmentView() : void
6364
$exceptions->setDevelopmentView('/unknown/foo.php');
6465
}
6566

67+
public function testDevelopmentViewWithEnum() : void
68+
{
69+
$_ENV['logger.default.level'] = LogLevel::CRITICAL;
70+
$exceptions = new ExceptionHandlerMock(ExceptionHandler::DEVELOPMENT);
71+
$exceptions->cli = false;
72+
\ob_start();
73+
$exceptions->exceptionHandler(new \Exception('Foo'));
74+
\ob_end_clean();
75+
self::assertTrue(true); // This test is only to increase coverage.
76+
}
77+
6678
public function testProductionView() : void
6779
{
6880
$exceptions = new ExceptionHandler();

0 commit comments

Comments
 (0)