@@ -37,6 +37,46 @@ public function setUp() {
3737 ->getMock ();
3838 }
3939
40+ public function errorProvider () {
41+ return [
42+ [
43+ 'ldap_search(): Partial search results returned: Sizelimit exceeded at /srv/http/nextcloud/master/apps/user_ldap/lib/LDAP.php#292 ' ,
44+ false
45+ ],
46+ [
47+ 'Some other error ' , true
48+ ]
49+ ];
50+ }
51+
52+ /**
53+ * @param string $errorMessage
54+ * @param bool $passThrough
55+ * @dataProvider errorProvider
56+ */
57+ public function testSearchWithErrorHandler (string $ errorMessage , bool $ passThrough ) {
58+
59+ $ wasErrorHandlerCalled = false ;
60+ $ errorHandler = function ($ number , $ message , $ file , $ line ) use (&$ wasErrorHandlerCalled ) {
61+ $ wasErrorHandlerCalled = true ;
62+ };
63+
64+ set_error_handler ($ errorHandler );
65+
66+ $ this ->ldap
67+ ->expects ($ this ->once ())
68+ ->method ('invokeLDAPMethod ' )
69+ ->with ('search ' , $ this ->anything (), $ this ->anything (), $ this ->anything (), $ this ->anything (), $ this ->anything ())
70+ ->willReturnCallback (function () use ($ errorMessage ) {
71+ trigger_error ($ errorMessage );
72+ });
73+
74+ $ this ->ldap ->search ('pseudo-resource ' , 'base ' , 'filter ' , []);
75+ $ this ->assertSame ($ wasErrorHandlerCalled , $ passThrough );
76+
77+ restore_error_handler ();
78+ }
79+
4080 public function testModReplace () {
4181 $ link = $ this ->createMock (LDAP ::class);
4282 $ userDN = 'CN=user ' ;
0 commit comments