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

orchestral / testbench-core / 11997703869

24 Nov 2024 04:17PM UTC coverage: 91.265% (-0.008%) from 91.273%
11997703869

push

github

web-flow
Update UserFactoryTest.php

1421 of 1557 relevant lines covered (91.27%)

71.0 hits per line

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

80.77
/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

9
use function Orchestra\Testbench\join_paths;
10

11
/**
12
 * @internal
13
 */
14
final class HandleExceptions extends \Illuminate\Foundation\Bootstrap\HandleExceptions
15
{
16
    /**
17
     * {@inheritDoc}
18
     *
19
     * @throws \Orchestra\Testbench\Exceptions\DeprecatedException
20
     */
21
    #[\Override]
22
    public function handleDeprecationError($message, $file, $line, $level = E_DEPRECATED)
23
    {
24
        parent::handleDeprecationError($message, $file, $line, $level);
2✔
25

26
        $testbenchConvertDeprecationsToExceptions = Env::get('TESTBENCH_CONVERT_DEPRECATIONS_TO_EXCEPTIONS', false);
2✔
27

28
        if ($testbenchConvertDeprecationsToExceptions === true) {
2✔
29
            throw new DeprecatedException($message, $level, $file, $line);
1✔
30
        }
31
    }
32

33
    /** {@inheritDoc} */
34
    #[\Override]
35
    protected function ensureDeprecationLoggerIsConfigured()
36
    {
37
        with(self::$app->make('config'), static function ($config) {
2✔
38
            /** @var \Illuminate\Contracts\Config\Repository $config */
39
            if ($config->get('logging.channels.deprecations')) {
2✔
40
                return;
×
41
            }
42

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

47
            if (\is_array($options)) {
2✔
48
                $driver = $options['channel'] ?? 'null';
2✔
49
                $trace = $options['trace'] ?? true;
2✔
50
            } else {
51
                $driver = $options ?? 'null';
×
52
            }
53

54
            if ($driver === 'single') {
2✔
55
                $config->set('logging.channels.deprecations', array_merge($config->get('logging.channels.single'), [
×
56
                    'path' => self::$app->storagePath(join_paths('logs', 'deprecations.log')),
×
57
                ]));
×
58
            } else {
59
                $config->set('logging.channels.deprecations', $config->get("logging.channels.{$driver}"));
2✔
60
            }
61

62
            $config->set('logging.deprecations', [
2✔
63
                'channel' => 'deprecations',
2✔
64
                'trace' => $trace,
2✔
65
            ]);
2✔
66
        });
2✔
67
    }
68

69
    /** {@inheritDoc} */
70
    #[\Override]
71
    protected function shouldIgnoreDeprecationErrors()
72
    {
73
        return ! class_exists(LogManager::class)
2✔
74
            || ! self::$app->hasBeenBootstrapped()
2✔
75
            || ! Env::get('LOG_DEPRECATIONS_WHILE_TESTING', true);
2✔
76
    }
77
}
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