Page Menu
Home
DevCentral
Search
Configure Global Search
Log In
Files
F8322059
PSR4NamespaceTest.php
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
2 KB
Referenced Files
None
Subscribers
None
PSR4NamespaceTest.php
View Options
<?php
declare
(
strict_types
=
1
);
namespace
Keruald\OmniTools\Tests\Registration\PSR4
;
use
Keruald\OmniTools\Registration\PSR4\PSR4Namespace
;
use
Keruald\OmniTools\Tests\WithData
;
use
PHPUnit\Framework\TestCase
;
class
PSR4NamespaceTest
extends
TestCase
{
use
WithData
;
///
/// Discovery tests
///
const
ALL_CLASSES
=
[
"Acme
\\
SolarSystemLib
\\
Sun"
,
"Acme
\\
SolarSystemLib
\\
Planets
\\
Pluton"
,
"Acme
\\
SolarSystemLib
\\
Planets
\\
Inner
\\
Mercure"
,
"Acme
\\
SolarSystemLib
\\
Planets
\\
Inner
\\
Venus"
,
];
/**
* @dataProvider provideClasses
*/
public
function
testDiscover
(
string
$path
,
string
$prefix
,
array
$expected
)
:
void
{
$ns
=
new
PSR4Namespace
(
$prefix
,
$this
->
getDataPath
(
$path
));
$this
->
assertEquals
(
$expected
,
$ns
->
discover
());
}
public
function
testDiscoverRecursive
()
:
void
{
$baseDirectory
=
$this
->
getDataPath
(
"SolarSystemLib"
);
$ns
=
new
PSR4Namespace
(
"Acme
\\
SolarSystemLib"
,
$baseDirectory
);
$this
->
assertEquals
(
self
::
ALL_CLASSES
,
$ns
->
discoverRecursive
());
}
public
function
testDiscoverAllClasses
()
:
void
{
$actual
=
PSR4Namespace
::
discoverAllClasses
(
"Acme
\\
SolarSystemLib"
,
$this
->
getDataPath
(
"SolarSystemLib"
),
);
$this
->
assertEquals
(
self
::
ALL_CLASSES
,
$actual
);
}
///
/// Data providers
///
public
function
provideClasses
()
:
iterable
{
// [string $path, string $prefix, string[] $expectedClasses]
yield
[
"MockLib"
,
"Acme
\\
MockLib"
,
[
"Acme
\\
MockLib
\\
Bar"
,
"Acme
\\
MockLib
\\
Foo"
,
]];
yield
[
"SolarSystemLib"
,
"Acme
\\
SolarSystemLib"
,
[
"Acme
\\
SolarSystemLib
\\
Sun"
,
]];
yield
[
"SolarSystemLib/Planets"
,
"Acme
\\
SolarSystemLib
\\
Planets"
,
[
"Acme
\\
SolarSystemLib
\\
Planets
\\
Pluton"
,
]];
yield
[
"SolarSystemLib/Planets/Inner"
,
"Acme
\\
SolarSystemLib
\\
Planets
\\
Inner"
,
[
"Acme
\\
SolarSystemLib
\\
Planets
\\
Inner
\\
Mercure"
,
"Acme
\\
SolarSystemLib
\\
Planets
\\
Inner
\\
Venus"
,
]
];
yield
[
"NotExisting"
,
"AnyPrefix"
,
[]];
}
}
File Metadata
Details
Attached
Mime Type
text/x-php
Expires
Tue, May 13, 16:58 (13 h, 21 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2567159
Default Alt Text
PSR4NamespaceTest.php (2 KB)
Attached To
Mode
rKERUALD Keruald libraries development repository
Attached
Detach File
Event Timeline
Log In to Comment