Page Menu
Home
DevCentral
Search
Configure Global Search
Log In
Files
F12742468
PropagationTest.php
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
1 KB
Referenced Files
None
Subscribers
None
PropagationTest.php
View Options
<?php
namespace
Keruald\OmniTools\Tests\Events
;
use
Keruald\OmniTools\Events\Propagation
;
use
PHPUnit\Framework\TestCase
;
use
BadFunctionCallException
;
use
Exception
;
use
LogicException
;
use
RuntimeException
;
class
PropagationTest
extends
TestCase
{
private
int
$counter
;
private
iterable
$callbacks
;
protected
function
setUp
()
:
void
{
$this
->
counter
=
0
;
$this
->
callbacks
=
[
function
(
int
$a
,
int
$b
)
{
$this
->
counter
++;
},
function
(
int
$a
,
int
$b
)
{
$this
->
counter
++;
},
];
}
public
function
testCallWithoutAnyCallback
()
{
$this
->
expectNotToPerformAssertions
();
Propagation
::
call
([]);
}
public
function
testCall
()
{
Propagation
::
call
(
$this
->
callbacks
,
[
3
,
4
]);
$this
->
assertEquals
(
2
,
$this
->
counter
);
}
public
function
testCallOrThrowWithCallbacks
()
{
Propagation
::
callOrThrow
(
$this
->
callbacks
,
[
3
,
4
]);
$this
->
assertEquals
(
2
,
$this
->
counter
);
}
public
function
testCallOrThrowWithoutAnyCallback
()
{
$this
->
expectException
(
RuntimeException
::
class
);
Propagation
::
callOrThrow
([],
[
3
,
4
]);
}
public
function
testCallOrThrowWithCustomException
()
{
$this
->
expectException
(
LogicException
::
class
);
Propagation
::
callOrThrow
([],
[
3
,
4
],
new
LogicException
);
}
public
function
testCallWhenArgumentIsAnException
()
{
// Dubious case with anonymous functions using strong types
$arguments
=
[
3
,
Exception
::
class
,
];
// Inner exception need to be
$this
->
expectException
(
BadFunctionCallException
::
class
);
Propagation
::
call
([
null
],
$arguments
);
}
}
File Metadata
Details
Attached
Mime Type
text/x-php
Expires
Sun, Nov 16, 13:46 (8 h, 16 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
3140640
Default Alt Text
PropagationTest.php (1 KB)
Attached To
Mode
rKERUALD Keruald libraries development repository
Attached
Detach File
Event Timeline
Log In to Comment