Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F1821576
ContinueCallbackTest.php
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Size
1 KB
Subscribers
None
ContinueCallbackTest.php
View Options
<?php
namespace
Sabre\Event
;
class
ContinueCallbackTest
extends
\PHPUnit_Framework_TestCase
{
function
testContinueCallBack
()
{
$ee
=
new
EventEmitter
();
$handlerCounter
=
0
;
$bla
=
function
()
use
(&
$handlerCounter
)
{
$handlerCounter
++;
};
$ee
->
on
(
'foo'
,
$bla
);
$ee
->
on
(
'foo'
,
$bla
);
$ee
->
on
(
'foo'
,
$bla
);
$continueCounter
=
0
;
$r
=
$ee
->
emit
(
'foo'
,
[],
function
()
use
(&
$continueCounter
)
{
$continueCounter
++;
return
true
;
});
$this
->
assertTrue
(
$r
);
$this
->
assertEquals
(
3
,
$handlerCounter
);
$this
->
assertEquals
(
2
,
$continueCounter
);
}
function
testContinueCallBackBreak
()
{
$ee
=
new
EventEmitter
();
$handlerCounter
=
0
;
$bla
=
function
()
use
(&
$handlerCounter
)
{
$handlerCounter
++;
};
$ee
->
on
(
'foo'
,
$bla
);
$ee
->
on
(
'foo'
,
$bla
);
$ee
->
on
(
'foo'
,
$bla
);
$continueCounter
=
0
;
$r
=
$ee
->
emit
(
'foo'
,
[],
function
()
use
(&
$continueCounter
)
{
$continueCounter
++;
return
false
;
});
$this
->
assertTrue
(
$r
);
$this
->
assertEquals
(
1
,
$handlerCounter
);
$this
->
assertEquals
(
1
,
$continueCounter
);
}
function
testContinueCallBackBreakByHandler
()
{
$ee
=
new
EventEmitter
();
$handlerCounter
=
0
;
$bla
=
function
()
use
(&
$handlerCounter
)
{
$handlerCounter
++;
return
false
;
};
$ee
->
on
(
'foo'
,
$bla
);
$ee
->
on
(
'foo'
,
$bla
);
$ee
->
on
(
'foo'
,
$bla
);
$continueCounter
=
0
;
$r
=
$ee
->
emit
(
'foo'
,
[],
function
()
use
(&
$continueCounter
)
{
$continueCounter
++;
return
false
;
});
$this
->
assertFalse
(
$r
);
$this
->
assertEquals
(
1
,
$handlerCounter
);
$this
->
assertEquals
(
0
,
$continueCounter
);
}
}
File Metadata
Details
Attached
Mime Type
text/x-php
Expires
Tue, Dec 24, 4:45 AM (1 d, 17 h)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
914616
Default Alt Text
ContinueCallbackTest.php (1 KB)
Attached To
rDAVCAL DokuWiki DAVCal PlugIn
Event Timeline
Log In to Comment