Skip to content
This repository has been archived by the owner on Jan 30, 2020. It is now read-only.

Commit

Permalink
Merge branch 'hotfix/47'
Browse files Browse the repository at this point in the history
Closes #46
  • Loading branch information
heiglandreas committed May 23, 2016
2 parents f1a18f3 + f73e411 commit 14c5b86
Show file tree
Hide file tree
Showing 4 changed files with 57 additions and 9 deletions.
5 changes: 3 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

All notable changes to this project will be documented in this file, in reverse chronological order by release.

## 2.7.1 - TBD
## 2.7.1 - 2016-05-23

### Added

Expand All @@ -19,7 +19,8 @@ All notable changes to this project will be documented in this file, in reverse

### Fixed

- Nothing.
- [#47](https://github.com/zendframework/zend-ldap/pull/47) Fixes a BC-Break caused
by the missing default-ErrorHandler

## 2.7.0 - 2016-04-21

Expand Down
4 changes: 2 additions & 2 deletions src/ErrorHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ protected static function getErrorHandler()
*/
public function startErrorHandling($level = E_WARNING)
{
// Do nothing!
set_error_handler(function ($errNo, $errString) {});
}

/**
Expand All @@ -83,7 +83,7 @@ public function startErrorHandling($level = E_WARNING)
*/
public function stopErrorHandling($throw = false)
{
// Do nothing;
restore_error_handler();
}

/**
Expand Down
52 changes: 52 additions & 0 deletions test/ErrorHandlerTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
<?php
/**
* Zend Framework (http://framework.zend.com/)
*
* @link http://github.com/zendframework/zf2 for the canonical source repository
* @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/

namespace ZendTest\Ldap;

use Zend\Ldap\ErrorHandler;

/**
* @group Zend_Ldap
*/
class ErrorHandlerTest extends \PHPUnit_Framework_TestCase
{
protected $dummyErrorHandler;

protected $currentErrorHandler = [
'PHPUnit_Util_ErrorHandler',
'handleError',
];

public function setup()
{
$this->dummyErrorHandler = function ($errno, $error) {};
}
public function testErrorHandlerSettingWorks()
{
$errorHandler = new ErrorHandler();

$this->assertEquals($this->currentErrorHandler, set_error_handler($this->dummyErrorHandler));
$errorHandler->startErrorHandling();
$this->assertEquals($this->dummyErrorHandler, set_error_handler($this->dummyErrorHandler));

restore_error_handler();
restore_error_handler();
}

public function testErrorHandlerREmovalWorks()
{
$errorHandler = new ErrorHandler();

$this->assertEquals($this->currentErrorHandler, set_error_handler($this->dummyErrorHandler));
$errorHandler->stopErrorHandling();
$this->assertEquals($this->currentErrorHandler, set_error_handler($this->dummyErrorHandler));

restore_error_handler();
}
}
5 changes: 0 additions & 5 deletions test/bootstrap.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,6 @@
*/
require __DIR__ . '/../vendor/autoload.php';

/**
* Setting the ZendTest\Ldap\ErrorHandler as default ErrorHandler
*/
Zend\Ldap\ErrorHandler::setErrorHandler(new ZendTest\Ldap\ErrorHandler());

/**
* Start output buffering, if enabled
*/
Expand Down

0 comments on commit 14c5b86

Please sign in to comment.