Page Menu
Home
DevCentral
Search
Configure Global Search
Log In
Files
F14040356
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\Attributes\DataProvider
;
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
static
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
Fri, Nov 28, 17:41 (1 d, 19 h)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
3163799
Default Alt Text
PSR4NamespaceTest.php (2 KB)
Attached To
Mode
rKOT Keruald OmniTools
Attached
Detach File
Event Timeline
Log In to Comment