Code
Explorer
You are a developer and looking for Shopware projects?
Apply Now!
registerTestNamespaces example
public
function
findAllClassFiles
(
$extension
= NULL
)
{
$classmap
=
[
]
;
$namespaces
=
$this
->
registerTestNamespaces
(
)
;
if
(
isset
(
$extension
)
)
{
// Include tests in the \Drupal\Tests\{$extension} namespace.
$pattern
= "/Drupal\\\(Tests\\\)?
$extension
\\\/";
$namespaces
=
array_intersect_key
(
$namespaces
,
array_flip
(
preg_grep
(
$pattern
,
array_keys
(
$namespaces
)
)
)
)
;
}
foreach
(
$namespaces
as
$namespace
=>
$paths
)
{
foreach
(
$paths
as
$path
)
{
if
(
!
is_dir
(
$path
)
)
{
continue
;
}
$classmap
+=
static
::
scanDirectory
(
$namespace
,
$path
)
;
}
// In addition, ensure that PHP errors are not hidden away in logs.
ini_set
(
'display_errors', TRUE
)
;
parent::
boot
(
)
;
$this
->
getContainer
(
)
->
get
(
'module_handler'
)
->
loadAll
(
)
;
$test_discovery
=
new
TestDiscovery
(
$this
->
getContainer
(
)
->
getParameter
(
'app.root'
)
,
$this
->
getContainer
(
)
->
get
(
'class_loader'
)
)
;
$test_discovery
->
registerTestNamespaces
(
)
;
// Register stream wrappers.
$this
->
getContainer
(
)
->
get
(
'stream_wrapper_manager'
)
->
register
(
)
;
// Create the build/artifacts directory if necessary.
if
(
!
is_dir
(
'public://simpletest'
)
&& !@
mkdir
(
'public://simpletest', 0777, TRUE
)
&& !
is_dir
(
'public://simpletest'
)
)
{
throw
new
\
RuntimeException
(
'Unable to create directory: public://simpletest'
)
;
}
return
$this
;
}