/
ErrorHandlerTest.php
34 lines (26 loc) · 1.12 KB
/
ErrorHandlerTest.php
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
<?php
use Codeception\Event\SuiteEvent;
use Codeception\Lib\Notification;
use Codeception\Subscriber\ErrorHandler;
use Codeception\Suite;
class ErrorHandlerTest extends \PHPUnit\Framework\TestCase
{
public function testDeprecationMessagesRespectErrorLevelSetting()
{
$errorHandler = new ErrorHandler();
$suiteEvent = new SuiteEvent(new Suite(), null, ['error_level' => 'E_ERROR']);
$errorHandler->handle($suiteEvent);
//Satisfying The Premature Exit Handling
$errorHandler->onFinish($suiteEvent);
Notification::all(); //clear the messages
$errorHandler->errorHandler(E_USER_DEPRECATED, 'deprecated message', __FILE__, __LINE__, []);
$this->assertEquals([], Notification::all(), 'Deprecation message was added to notifications');
}
public function testShowsLocationOfWarning()
{
$this->expectException(\PHPUnit\Framework\Exception::class);
$SEP = DIRECTORY_SEPARATOR;
$this->expectErrorMessage("Undefined variable: a at tests{$SEP}unit{$SEP}Codeception{$SEP}Subscriber{$SEP}ErrorHandlerTest.php:32");
$b = $a + 1;
}
}