• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

orchestral / testbench-core / 14963886593

12 May 2025 04:33AM UTC coverage: 92.387% (+0.06%) from 92.331%
14963886593

push

github

crynobone
wip

Signed-off-by: Mior Muhammad Zaki <crynobone@gmail.com>

6 of 7 new or added lines in 1 file covered. (85.71%)

1529 of 1655 relevant lines covered (92.39%)

75.04 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

79.31
/src/Bootstrap/HandleExceptions.php
1
<?php
2

3
namespace Orchestra\Testbench\Bootstrap;
4

5
use Illuminate\Log\LogManager;
6
use Orchestra\Testbench\Exceptions\DeprecatedException;
7
use Orchestra\Testbench\Foundation\Env;
8
use Throwable;
9

10
use function Orchestra\Sidekick\join_paths;
11

12
/**
13
 * @internal
14
 */
15
final class HandleExceptions extends \Illuminate\Foundation\Bootstrap\HandleExceptions
16
{
17
    /**
18
     * {@inheritDoc}
19
     *
20
     * @throws \Orchestra\Testbench\Exceptions\DeprecatedException
21
     */
22
    #[\Override]
23
    public function handleDeprecationError($message, $file, $line, $level = E_DEPRECATED)
24
    {
25
        try {
26
            parent::handleDeprecationError($message, $file, $line, $level);
2✔
NEW
27
        } catch (Throwable) {
×
28
            //
29
        } finally {
30
            $testbenchConvertDeprecationsToExceptions = (bool) Env::get(
2✔
31
                'TESTBENCH_CONVERT_DEPRECATIONS_TO_EXCEPTIONS', false
2✔
32
            );
2✔
33

34
            if ($testbenchConvertDeprecationsToExceptions === true) {
2✔
35
                throw new DeprecatedException($message, $level, $file, $line);
2✔
36
            }
37
        }
38
    }
39

40
    /** {@inheritDoc} */
41
    #[\Override]
42
    protected function ensureDeprecationLoggerIsConfigured()
43
    {
44
        with(self::$app->make('config'), static function ($config) {
2✔
45
            /** @var \Illuminate\Contracts\Config\Repository $config */
46
            if ($config->get('logging.channels.deprecations')) {
2✔
47
                return;
×
48
            }
49

50
            /** @var array{channel?: string, trace?: bool}|string|null $options */
51
            $options = $config->get('logging.deprecations');
2✔
52
            $trace = Env::get('LOG_DEPRECATIONS_TRACE', false);
2✔
53

54
            if (\is_array($options)) {
2✔
55
                $driver = $options['channel'] ?? 'null';
2✔
56
                $trace = $options['trace'] ?? true;
2✔
57
            } else {
58
                $driver = $options ?? 'null';
×
59
            }
60

61
            if ($driver === 'single') {
2✔
62
                $config->set('logging.channels.deprecations', array_merge($config->get('logging.channels.single'), [
×
63
                    'path' => self::$app->storagePath(join_paths('logs', 'deprecations.log')),
×
64
                ]));
×
65
            } else {
66
                $config->set('logging.channels.deprecations', $config->get("logging.channels.{$driver}"));
2✔
67
            }
68

69
            $config->set('logging.deprecations', [
2✔
70
                'channel' => 'deprecations',
2✔
71
                'trace' => $trace,
2✔
72
            ]);
2✔
73
        });
2✔
74
    }
75

76
    /** {@inheritDoc} */
77
    #[\Override]
78
    protected function shouldIgnoreDeprecationErrors()
79
    {
80
        return ! class_exists(LogManager::class)
2✔
81
            || ! self::$app->hasBeenBootstrapped()
2✔
82
            || ! (bool) Env::get('LOG_DEPRECATIONS_WHILE_TESTING', true);
2✔
83
    }
84
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc