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

Commit 14c5b86

Browse files
committed
Merge branch 'hotfix/47'
Closes #46
2 parents f1a18f3 + f73e411 commit 14c5b86

File tree

4 files changed

+57
-9
lines changed

4 files changed

+57
-9
lines changed

CHANGELOG.md

+3-2
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

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

5-
## 2.7.1 - TBD
5+
## 2.7.1 - 2016-05-23
66

77
### Added
88

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

2020
### Fixed
2121

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

2425
## 2.7.0 - 2016-04-21
2526

src/ErrorHandler.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ protected static function getErrorHandler()
7070
*/
7171
public function startErrorHandling($level = E_WARNING)
7272
{
73-
// Do nothing!
73+
set_error_handler(function ($errNo, $errString) {});
7474
}
7575

7676
/**
@@ -83,7 +83,7 @@ public function startErrorHandling($level = E_WARNING)
8383
*/
8484
public function stopErrorHandling($throw = false)
8585
{
86-
// Do nothing;
86+
restore_error_handler();
8787
}
8888

8989
/**

test/ErrorHandlerTest.php

+52
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
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+
}

test/bootstrap.php

-5
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,6 @@
1515
*/
1616
require __DIR__ . '/../vendor/autoload.php';
1717

18-
/**
19-
* Setting the ZendTest\Ldap\ErrorHandler as default ErrorHandler
20-
*/
21-
Zend\Ldap\ErrorHandler::setErrorHandler(new ZendTest\Ldap\ErrorHandler());
22-
2318
/**
2419
* Start output buffering, if enabled
2520
*/

0 commit comments

Comments
 (0)