PHP Classes

File: tests/util-tests/ExceptionErrorHandlerTest.php

Recommend this page to a friend!
  Classes of Maik Greubel   PHP Generics   tests/util-tests/ExceptionErrorHandlerTest.php   Download  
File: tests/util-tests/ExceptionErrorHandlerTest.php
Role: Class source
Content type: text/plain
Description: Class source
Class: PHP Generics
Framework for accessing streams, sockets and logs
Author: By
Last change: Update of tests/util-tests/ExceptionErrorHandlerTest.php
Date: 7 months ago
Size: 1,891 bytes
 

Contents

Class file image Download
<?php
namespace Generics\Tests;

use
PHPUnit\Framework\TestCase;
use
Generics\NoticeException;
use
Generics\Util\ExceptionErrorHandler;
use
Generics\WarningException;
use
Generics\UserErrorException;
use
Generics\UserWarningException;
use
Generics\UserNoticeException;
use
Generics\RecoverableErrorException;
use
Generics\DeprecatedException;
use
Generics\UserDeprecatedException;

class
A
{
}

class
B
{
    function
B()
    {
    }
}

class
C
{
    function
bar()
    {
    }
}

class
ExceptionErrorHandlerTest extends TestCase
{
    protected function
setUp()
    {
        new
ExceptionErrorHandler();
    }

    public function
testNoticeException()
    {
       
$this->expectException(NoticeException::class);

        echo
$a['b'];
    }

    public function
testWarningException()
    {
       
$this->expectException(WarningException::class);

       
trigger_error('A warning', E_WARNING);
    }

    public function
testUserError()
    {
       
$this->expectException(UserErrorException::class);

       
trigger_error('A user error', E_USER_ERROR);
    }

    public function
testUserWarning()
    {
       
$this->expectException(UserWarningException::class);

       
trigger_error('A user warning', E_USER_WARNING);
    }

    public function
testUserNotice()
    {
       
$this->expectException(UserNoticeException::class);

       
trigger_error('A user notice', E_USER_NOTICE);
    }

    public function
testRecoverableError()
    {
       
$this->expectException(RecoverableErrorException::class);

       
$a = new A();
       
printf("%s\n", $a);
    }

    public function
testDeprecated()
    {
       
$this->expectException(DeprecatedException::class);

       
C::bar();
    }

    public function
testUserDeprecated()
    {
       
$this->expectException(UserDeprecatedException::class);

       
trigger_error('A user deprecated', E_USER_DEPRECATED);
    }
}