|
| 1 | +<?php |
| 2 | +/** |
| 3 | + * Zend Framework (http://framework.zend.com/) |
| 4 | + * |
| 5 | + * @link http://github.com/zendframework/zf2 for the canonical source repository |
| 6 | + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) |
| 7 | + * @license http://framework.zend.com/license/new-bsd New BSD License |
| 8 | + */ |
| 9 | + |
| 10 | +namespace ZendTest\Ldap; |
| 11 | + |
| 12 | +use Zend\Ldap\ErrorHandler; |
| 13 | + |
| 14 | +/** |
| 15 | + * @group Zend_Ldap |
| 16 | + */ |
| 17 | +class ErrorHandlerTest extends \PHPUnit_Framework_TestCase |
| 18 | +{ |
| 19 | + protected $dummyErrorHandler; |
| 20 | + |
| 21 | + protected $currentErrorHandler = [ |
| 22 | + 'PHPUnit_Util_ErrorHandler', |
| 23 | + 'handleError', |
| 24 | + ]; |
| 25 | + |
| 26 | + public function setup() |
| 27 | + { |
| 28 | + $this->dummyErrorHandler = function ($errno, $error) {}; |
| 29 | + } |
| 30 | + public function testErrorHandlerSettingWorks() |
| 31 | + { |
| 32 | + $errorHandler = new ErrorHandler(); |
| 33 | + |
| 34 | + $this->assertEquals($this->currentErrorHandler, set_error_handler($this->dummyErrorHandler)); |
| 35 | + $errorHandler->startErrorHandling(); |
| 36 | + $this->assertEquals($this->dummyErrorHandler, set_error_handler($this->dummyErrorHandler)); |
| 37 | + |
| 38 | + restore_error_handler(); |
| 39 | + restore_error_handler(); |
| 40 | + } |
| 41 | + |
| 42 | + public function testErrorHandlerREmovalWorks() |
| 43 | + { |
| 44 | + $errorHandler = new ErrorHandler(); |
| 45 | + |
| 46 | + $this->assertEquals($this->currentErrorHandler, set_error_handler($this->dummyErrorHandler)); |
| 47 | + $errorHandler->stopErrorHandling(); |
| 48 | + $this->assertEquals($this->currentErrorHandler, set_error_handler($this->dummyErrorHandler)); |
| 49 | + |
| 50 | + restore_error_handler(); |
| 51 | + } |
| 52 | +} |
0 commit comments