HandleExceptionsRegistrationTest.php
1.5 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
<?php
use Illuminate\Config\Repository as Config;
use Illuminate\Contracts\Foundation\Application as ApplicationContract;
use Roots\Acorn\Bootstrap\HandleExceptions;
use Roots\Acorn\Tests\Test\TestCase;
use function Roots\Acorn\Tests\mock;
uses(TestCase::class);
beforeAll(function () {
if (! defined('WP_DEBUG')) {
define('WP_DEBUG', true);
}
});
beforeEach(function () {
/** @var \Mockery\MockInterface|ApplicationContract */
$this->application = mock(ApplicationContract::class);
$this->application
->shouldIgnoreMissing()
->shouldreceive('runningInConsole')
->andReturn(false);
$this->application->config = new Config(['app' => ['debug' => true]]);
$this->handleExceptions = new HandleExceptions();
});
it('registers error handler', function () {
set_error_handler(null);
$this->handleExceptions->bootstrap($this->application);
expect(set_error_handler(null))->not()->toBeNull();
});
it('registers exception handler', function () {
set_exception_handler(null);
$this->handleExceptions->bootstrap($this->application);
expect(set_exception_handler(null))->not()->toBeNull();
});
it('does not register handlers when debugging is disabled', function () {
$this->application->config->set('app.debug', false);
set_error_handler(null);
set_exception_handler(null);
$this->handleExceptions->bootstrap($this->application);
expect(set_error_handler(null))->toBeNull();
expect(set_exception_handler(null))->toBeNull();
});