Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
D
drupal
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Custom Issue Tracker
Custom Issue Tracker
Labels
Merge Requests
225
Merge Requests
225
Requirements
Requirements
List
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Analytics
Analytics
Code Review
Insights
Issue
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Commits
Open sidebar
project
drupal
Commits
e9d97f1e
Commit
e9d97f1e
authored
Jun 08, 2009
by
Dries
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
- Patch
#449198
by boombatower: cealn up test loading and related API.
parent
b9ed1bc6
Changes
41
Hide whitespace changes
Inline
Side-by-side
Showing
41 changed files
with
371 additions
and
114 deletions
+371
-114
includes/registry.inc
includes/registry.inc
+19
-4
modules/aggregator/aggregator.info
modules/aggregator/aggregator.info
+1
-0
modules/block/block.api.php
modules/block/block.api.php
+46
-0
modules/block/block.info
modules/block/block.info
+1
-0
modules/block/block.module
modules/block/block.module
+81
-44
modules/block/block.test
modules/block/block.test
+31
-0
modules/blog/blog.info
modules/blog/blog.info
+1
-0
modules/blogapi/blogapi.info
modules/blogapi/blogapi.info
+1
-0
modules/book/book.info
modules/book/book.info
+1
-0
modules/comment/comment.info
modules/comment/comment.info
+1
-0
modules/contact/contact.info
modules/contact/contact.info
+1
-0
modules/dblog/dblog.info
modules/dblog/dblog.info
+1
-0
modules/field/field.info
modules/field/field.info
+1
-0
modules/field/modules/field_sql_storage/field_sql_storage.info
...es/field/modules/field_sql_storage/field_sql_storage.info
+1
-0
modules/field/modules/text/text.info
modules/field/modules/text/text.info
+2
-1
modules/filter/filter.info
modules/filter/filter.info
+1
-0
modules/forum/forum.info
modules/forum/forum.info
+1
-0
modules/help/help.info
modules/help/help.info
+1
-0
modules/locale/locale.info
modules/locale/locale.info
+1
-0
modules/menu/menu.info
modules/menu/menu.info
+1
-0
modules/node/node.info
modules/node/node.info
+1
-0
modules/openid/openid.info
modules/openid/openid.info
+1
-0
modules/path/path.info
modules/path/path.info
+1
-0
modules/php/php.info
modules/php/php.info
+1
-0
modules/poll/poll.info
modules/poll/poll.info
+1
-0
modules/profile/profile.info
modules/profile/profile.info
+1
-0
modules/simpletest/simpletest.info
modules/simpletest/simpletest.info
+23
-0
modules/simpletest/simpletest.module
modules/simpletest/simpletest.module
+73
-47
modules/simpletest/simpletest.pages.inc
modules/simpletest/simpletest.pages.inc
+5
-12
modules/simpletest/tests/graph.test
modules/simpletest/tests/graph.test
+1
-1
modules/statistics/statistics.info
modules/statistics/statistics.info
+1
-0
modules/syslog/syslog.info
modules/syslog/syslog.info
+1
-0
modules/system/system.api.php
modules/system/system.api.php
+53
-0
modules/system/system.info
modules/system/system.info
+1
-0
modules/taxonomy/taxonomy.info
modules/taxonomy/taxonomy.info
+1
-0
modules/tracker/tracker.info
modules/tracker/tracker.info
+1
-0
modules/translation/translation.info
modules/translation/translation.info
+1
-0
modules/trigger/trigger.info
modules/trigger/trigger.info
+1
-0
modules/upload/upload.info
modules/upload/upload.info
+1
-0
modules/user/user.info
modules/user/user.info
+1
-0
scripts/run-tests.sh
scripts/run-tests.sh
+7
-5
No files found.
includes/registry.inc
View file @
e9d97f1e
...
...
@@ -45,11 +45,19 @@ function _registry_rebuild() {
system_get_files_database
(
$modules
,
'module'
);
// Get the list of files we are going to parse.
$files
=
array
();
foreach
(
$modules
as
$module
)
{
foreach
(
$modules
as
&
$module
)
{
$dir
=
dirname
(
$module
->
filepath
);
// Store the module directory for use in hook_registry_files_alter().
$module
->
dir
=
$dir
;
// Parse the .info file for all modules, reguardless of their status so the
// list of files can then be used in hook_registry_files_alter()
// implementations.
$module
->
info
=
drupal_parse_info_file
(
$dir
.
'/'
.
$module
->
name
.
'.info'
);
if
(
$module
->
status
)
{
// Parse .info file only for enabled modules.
$module
->
info
=
drupal_parse_info_file
(
dirname
(
$module
->
filepath
)
.
'/'
.
$module
->
name
.
'.info'
);
$dir
=
dirname
(
$module
->
filepath
);
// Add files for enabled modules to the registry.
foreach
(
$module
->
info
[
'files'
]
as
$file
)
{
$files
[
"
$dir
/
$file
"
]
=
array
(
'module'
=>
$module
->
name
,
'weight'
=>
$module
->
weight
);
}
...
...
@@ -59,6 +67,13 @@ function _registry_rebuild() {
$files
[
"
$filename
"
]
=
array
(
'module'
=>
''
,
'weight'
=>
0
);
}
// Allow modules to manually modify the list of files before the registry
// parses them. The $modules array provides the .info file information, which
// includes the list of files registered to each module. Any files in the
// list can then be added to the list of files that the registry will parse,
// or modify attributes of a file.
drupal_alter
(
'registry_files'
,
$files
,
$modules
);
foreach
(
registry_get_parsed_files
()
as
$filename
=>
$file
)
{
// Add the md5 to those files we've already parsed.
if
(
isset
(
$files
[
$filename
]))
{
...
...
modules/aggregator/aggregator.info
View file @
e9d97f1e
...
...
@@ -11,3 +11,4 @@ files[] = aggregator.fetcher.inc
files
[]
=
aggregator
.
parser
.
inc
files
[]
=
aggregator
.
processor
.
inc
files
[]
=
aggregator
.
install
files
[]
=
aggregator
.
test
modules/block/block.api.php
View file @
e9d97f1e
...
...
@@ -171,6 +171,52 @@ function hook_block_view($delta = '') {
return
$block
;
}
/**
* Act on blocks prior to rendering.
*
* This hook allows you to add, remove or modify blocks in the block list. The
* block list contains the block definitions not the rendered blocks. The blocks
* are rendered after the modules have had a chance to manipulate the block
* list.
* Alternatively you can set $block->content here, which will override the
* content of the block and prevent hook_block_view() from running.
*
* @param $blocks
* An array of $blocks, keyed by $bid
*
* This example shows how to achieve language specific visibility setting for
* blocks.
*/
function
hook_block_list_alter
(
&
$blocks
)
{
global
$language
,
$theme_key
;
$result
=
db_query
(
'SELECT module, delta, language FROM {my_table}'
);
$block_languages
=
array
();
foreach
(
$result
as
$record
)
{
$block_languages
[
$record
->
module
][
$record
->
delta
][
$record
->
language
]
=
TRUE
;
}
foreach
(
$blocks
as
$key
=>
$block
)
{
// Any module using this alter should inspect the data before changing it,
// to ensure it is what they expect.
if
(
$block
->
theme
!=
$theme_key
||
$block
->
status
!=
1
)
{
// This block was added by a contrib module, leave it in the list.
continue
;
}
if
(
!
isset
(
$block_languages
[
$block
->
module
][
$block
->
delta
]))
{
// No language setting for this block, leave it in the list.
continue
;
}
if
(
!
isset
(
$block_languages
[
$block
->
module
][
$block
->
delta
][
$language
->
language
]))
{
// This block should not be displayed with the active language, remove
// from the list.
unset
(
$blocks
[
$key
]);
}
}
}
/**
* @} End of "addtogroup hooks".
*/
modules/block/block.info
View file @
e9d97f1e
...
...
@@ -8,3 +8,4 @@ core = 7.x
files
[]
=
block
.
module
files
[]
=
block
.
admin
.
inc
files
[]
=
block
.
install
files
[]
=
block
.
test
modules/block/block.module
View file @
e9d97f1e
...
...
@@ -586,30 +586,64 @@ function block_list($region) {
* Load blocks information from the database.
*/
function
_block_load_blocks
()
{
global
$
user
,
$
theme_key
;
global
$theme_key
;
$blocks
=
array
();
$rids
=
array_keys
(
$user
->
roles
);
$query
=
db_select
(
'block'
,
'b'
);
$query
->
leftJoin
(
'block_role'
,
'r'
,
'b.module = r.module AND b.delta = r.delta'
);
$result
=
$query
->
distinct
()
->
fields
(
'b'
)
->
condition
(
'b.theme'
,
$theme_key
)
->
condition
(
'b.status'
,
1
)
->
condition
(
db_or
()
->
condition
(
'r.rid'
,
$rids
,
'IN'
)
->
isNull
(
'r.rid'
)
)
->
orderBy
(
'b.region'
)
->
orderBy
(
'b.weight'
)
->
orderBy
(
'b.module'
)
->
addTag
(
'block_load'
)
->
execute
();
foreach
(
$result
as
$block
)
{
if
(
!
isset
(
$blocks
[
$block
->
region
]))
{
$blocks
[
$block
->
region
]
=
array
();
$block_list
=
$result
->
fetchAllAssoc
(
'bid'
);
// Allow modules to modify the block list.
drupal_alter
(
'block_list'
,
$block_list
);
$blocks
=
array
();
foreach
(
$block_list
as
$block
)
{
$blocks
[
$block
->
region
][
"
{
$block
->
module
}
_
{
$block
->
delta
}
"
]
=
$block
;
}
return
$blocks
;
}
/**
* Implement hook_block_list_alter().
*
* Check the page, role and user specific visibilty settings. Remove the block
* if the visibility conditions are not met.
*/
function
block_block_list_alter
(
&
$blocks
)
{
global
$user
,
$theme_key
;
// Build an array of roles for each block.
$block_roles
=
array
();
$result
=
db_query
(
'SELECT module, delta, rid FROM {block_role}'
);
foreach
(
$result
as
$record
)
{
$block_roles
[
$record
->
module
][
$record
->
delta
][]
=
$record
->
rid
;
}
foreach
(
$blocks
as
$key
=>
$block
)
{
if
(
$block
->
theme
!=
$theme_key
||
$block
->
status
!=
1
)
{
// This block was added by a contrib module, leave it in the list.
continue
;
}
// If a block has no roles associated, it is displayed for every role.
// For blocks with roles associated, if none of the user's roles matches
// the settings from this block, remove it from the block list.
if
(
!
isset
(
$block_roles
[
$block
->
module
][
$block
->
delta
]))
{
// No roles associated.
}
elseif
(
!
array_intersect
(
$block_roles
[
$block
->
module
][
$block
->
delta
],
array_keys
(
$user
->
roles
)))
{
// No match.
unset
(
$blocks
[
$key
]);
continue
;
}
// Use the user's block visibility setting, if necessary.
if
(
$block
->
custom
!=
0
)
{
if
(
$user
->
uid
&&
isset
(
$user
->
block
[
$block
->
module
][
$block
->
delta
]))
{
...
...
@@ -622,6 +656,10 @@ function _block_load_blocks() {
else
{
$enabled
=
TRUE
;
}
if
(
!
$enabled
)
{
unset
(
$blocks
[
$key
]);
continue
;
}
// Match path if necessary.
if
(
$block
->
pages
)
{
...
...
@@ -647,12 +685,10 @@ function _block_load_blocks() {
else
{
$page_match
=
TRUE
;
}
$block
->
enabled
=
$enabled
;
$block
->
page_match
=
$page_match
;
$blocks
[
$block
->
region
][
"
{
$block
->
module
}
_
{
$block
->
delta
}
"
]
=
$block
;
if
(
!
$page_match
)
{
unset
(
$blocks
[
$key
])
;
}
}
return
$blocks
;
}
/**
...
...
@@ -668,38 +704,39 @@ function _block_render_blocks($region_blocks) {
foreach
(
$region_blocks
as
$key
=>
$block
)
{
// Render the block content if it has not been created already.
if
(
!
isset
(
$block
->
content
))
{
// Erase the block from the static array - we'll put it back if it has content.
// Erase the block from the static array - we'll put it back if it has
// content.
unset
(
$region_blocks
[
$key
]);
if
(
$block
->
enabled
&&
$block
->
page_match
)
{
// Try fetching the block from cache. Block caching is not compatible with
// node_access modules. We also preserve the submission of forms in blocks,
// by fetching from cache only if the request method is 'GET' (or 'HEAD').
if
(
!
count
(
module_implements
(
'node_grants'
))
&&
(
$_SERVER
[
'REQUEST_METHOD'
]
==
'GET'
||
$_SERVER
[
'REQUEST_METHOD'
]
==
'HEAD'
)
&&
(
$cid
=
_block_get_cache_id
(
$block
))
&&
(
$cache
=
cache_get
(
$cid
,
'cache_block'
)))
{
$array
=
$cache
->
data
;
}
else
{
$array
=
module_invoke
(
$block
->
module
,
'block_view'
,
$block
->
delta
);
if
(
isset
(
$cid
))
{
cache_set
(
$cid
,
$array
,
'cache_block'
,
CACHE_TEMPORARY
);
}
// Try fetching the block from cache. Block caching is not compatible
// with node_access modules. We also preserve the submission of forms in
// blocks, by fetching from cache only if the request method is 'GET'
// (or 'HEAD').
if
(
!
count
(
module_implements
(
'node_grants'
))
&&
(
$_SERVER
[
'REQUEST_METHOD'
]
==
'GET'
||
$_SERVER
[
'REQUEST_METHOD'
]
==
'HEAD'
)
&&
(
$cid
=
_block_get_cache_id
(
$block
))
&&
(
$cache
=
cache_get
(
$cid
,
'cache_block'
)))
{
$array
=
$cache
->
data
;
}
else
{
$array
=
module_invoke
(
$block
->
module
,
'block_view'
,
$block
->
delta
);
if
(
isset
(
$cid
))
{
cache_set
(
$cid
,
$array
,
'cache_block'
,
CACHE_TEMPORARY
);
}
}
if
(
isset
(
$array
)
&&
is_array
(
$array
))
{
foreach
(
$array
as
$k
=>
$v
)
{
$block
->
$k
=
$v
;
}
if
(
isset
(
$array
)
&&
is_array
(
$array
))
{
foreach
(
$array
as
$k
=>
$v
)
{
$block
->
$k
=
$v
;
}
if
(
isset
(
$block
->
content
)
&&
$block
->
content
)
{
// Override default block title if a custom display title is present.
if
(
$block
->
title
)
{
// Check plain here to allow module generated titles to keep any markup.
$block
->
subject
=
$block
->
title
==
'<none>'
?
''
:
check_plain
(
$block
->
title
);
}
if
(
!
isset
(
$block
->
subject
))
{
$block
->
subject
=
''
;
}
$
region_blocks
[
"
{
$block
->
module
}
_
{
$block
->
delta
}
"
]
=
$block
;
}
if
(
isset
(
$block
->
content
)
&&
$block
->
content
)
{
// Override default block title if a custom display title is present.
if
(
$block
->
title
)
{
// Check plain here to allow module generated titles to keep any
// markup.
$block
->
subject
=
$block
->
title
==
'<none>'
?
''
:
check_plain
(
$block
->
title
);
}
if
(
!
isset
(
$block
->
subject
))
{
$
block
->
subject
=
''
;
}
$region_blocks
[
"
{
$block
->
module
}
_
{
$block
->
delta
}
"
]
=
$block
;
}
}
}
...
...
modules/block/block.test
View file @
e9d97f1e
...
...
@@ -99,6 +99,37 @@ class BlockTestCase extends DrupalWebTestCase {
$this
->
assertRaw
(
'<h1>Full HTML</h1>'
,
t
(
'Box successfully being displayed using Full HTML.'
));
}
/**
* Test block visibility.
*/
function
testBlockVisibility
()
{
$block
=
array
();
$block
[
'title'
]
=
'Syndicate'
;
$block
[
'module'
]
=
'node'
;
$block
[
'delta'
]
=
'syndicate'
;
// Set the block to be hidden on any user path, and to be shown only to
// authenticated users.
$edit
=
array
();
$edit
[
'pages'
]
=
'user*'
;
$edit
[
'roles[2]'
]
=
TRUE
;
$this
->
drupalPost
(
'admin/build/block/configure/'
.
$block
[
'module'
]
.
'/'
.
$block
[
'delta'
],
$edit
,
t
(
'Save block'
));
// Move block to the left sidebar.
$this
->
moveBlockToRegion
(
$block
,
$this
->
regions
[
1
]);
$this
->
drupalGet
(
''
);
$this
->
assertText
(
'Syndicate'
,
t
(
'Block was displayed on the front page.'
));
$this
->
drupalGet
(
'user*'
);
$this
->
assertNoText
(
'Syndicate'
,
t
(
'Block was not displayed according to block visibility rules.'
));
// Confirm that the block is not displayed to anonymous users.
$this
->
drupalLogout
();
$this
->
drupalGet
(
''
);
$this
->
assertNoText
(
'Syndicate'
,
t
(
'Block was not displayed to anonymous users.'
));
}
/**
* Test configuring and moving a module-define block to specific regions.
*/
...
...
modules/blog/blog.info
View file @
e9d97f1e
...
...
@@ -7,3 +7,4 @@ version = VERSION
core
=
7.
x
files
[]
=
blog
.
module
files
[]
=
blog
.
pages
.
inc
files
[]
=
blog
.
test
modules/blogapi/blogapi.info
View file @
e9d97f1e
...
...
@@ -7,3 +7,4 @@ version = VERSION
core
=
7.
x
files
[]
=
blogapi
.
module
files
[]
=
blogapi
.
install
files
[]
=
blogapi
.
test
modules/book/book.info
View file @
e9d97f1e
...
...
@@ -9,3 +9,4 @@ files[] = book.module
files
[]
=
book
.
admin
.
inc
files
[]
=
book
.
pages
.
inc
files
[]
=
book
.
install
files
[]
=
book
.
test
modules/comment/comment.info
View file @
e9d97f1e
...
...
@@ -9,3 +9,4 @@ files[] = comment.module
files
[]
=
comment
.
admin
.
inc
files
[]
=
comment
.
pages
.
inc
files
[]
=
comment
.
install
files
[]
=
comment
.
test
modules/contact/contact.info
View file @
e9d97f1e
...
...
@@ -8,3 +8,4 @@ files[] = contact.module
files
[]
=
contact
.
admin
.
inc
files
[]
=
contact
.
pages
.
inc
files
[]
=
contact
.
install
files
[]
=
contact
.
test
modules/dblog/dblog.info
View file @
e9d97f1e
...
...
@@ -7,3 +7,4 @@ core = 7.x
files
[]
=
dblog
.
module
files
[]
=
dblog
.
admin
.
inc
files
[]
=
dblog
.
install
files
[]
=
dblog
.
test
modules/field/field.info
View file @
e9d97f1e
...
...
@@ -11,5 +11,6 @@ files[] = field.info.inc
files
[]
=
field
.
default
.
inc
files
[]
=
field
.
attach
.
inc
files
[]
=
field
.
form
.
inc
files
[]
=
field
.
test
dependencies
[]
=
field_sql_storage
required
=
TRUE
modules/field/modules/field_sql_storage/field_sql_storage.info
View file @
e9d97f1e
...
...
@@ -6,4 +6,5 @@ version = VERSION
core
=
7.
x
files
[]
=
field_sql_storage
.
module
files
[]
=
field_sql_storage
.
install
files
[]
=
field_sql_storage
.
test
required
=
TRUE
modules/field/modules/text/text.info
View file @
e9d97f1e
...
...
@@ -4,4 +4,5 @@ description = Defines simple text field types.
package
=
Core
-
fields
version
=
VERSION
core
=
7.
x
files
[]=
text
.
module
files
[]
=
text
.
module
files
[]
=
text
.
test
modules/filter/filter.info
View file @
e9d97f1e
...
...
@@ -8,4 +8,5 @@ files[] = filter.module
files
[]
=
filter
.
admin
.
inc
files
[]
=
filter
.
pages
.
inc
files
[]
=
filter
.
install
files
[]
=
filter
.
test
required
=
TRUE
modules/forum/forum.info
View file @
e9d97f1e
...
...
@@ -10,3 +10,4 @@ files[] = forum.module
files
[]
=
forum
.
admin
.
inc
files
[]
=
forum
.
pages
.
inc
files
[]
=
forum
.
install
files
[]
=
forum
.
test
modules/help/help.info
View file @
e9d97f1e
...
...
@@ -6,3 +6,4 @@ version = VERSION
core
=
7.
x
files
[]
=
help
.
module
files
[]
=
help
.
admin
.
inc
files
[]
=
help
.
test
modules/locale/locale.info
View file @
e9d97f1e
...
...
@@ -6,3 +6,4 @@ version = VERSION
core
=
7.
x
files
[]
=
locale
.
module
files
[]
=
locale
.
install
files
[]
=
locale
.
test
modules/menu/menu.info
View file @
e9d97f1e
...
...
@@ -7,3 +7,4 @@ core = 7.x
files
[]
=
menu
.
module
files
[]
=
menu
.
admin
.
inc
files
[]
=
menu
.
install
files
[]
=
menu
.
test
modules/node/node.info
View file @
e9d97f1e
...
...
@@ -9,4 +9,5 @@ files[] = content_types.inc
files
[]
=
node
.
admin
.
inc
files
[]
=
node
.
pages
.
inc
files
[]
=
node
.
install
files
[]
=
node
.
test
required
=
TRUE
modules/openid/openid.info
View file @
e9d97f1e
...
...
@@ -9,3 +9,4 @@ files[] = openid.inc
files
[]
=
openid
.
pages
.
inc
files
[]
=
xrds
.
inc
files
[]
=
openid
.
install
files
[]
=
openid
.
test
modules/path/path.info
View file @
e9d97f1e
...
...
@@ -6,3 +6,4 @@ version = VERSION
core
=
7.
x
files
[]
=
path
.
module
files
[]
=
path
.
admin
.
inc
files
[]
=
path
.
test
modules/php/php.info
View file @
e9d97f1e
...
...
@@ -6,3 +6,4 @@ version = VERSION
core
=
7.
x
files
[]
=
php
.
module
files
[]
=
php
.
install
files
[]
=
php
.
test
modules/poll/poll.info
View file @
e9d97f1e
...
...
@@ -7,3 +7,4 @@ core = 7.x
files
[]
=
poll
.
module
files
[]
=
poll
.
pages
.
inc
files
[]
=
poll
.
install
files
[]
=
poll
.
test
modules/profile/profile.info
View file @
e9d97f1e
...
...
@@ -8,3 +8,4 @@ files[] = profile.module
files
[]
=
profile
.
admin
.
inc
files
[]
=
profile
.
pages
.
inc
files
[]
=
profile
.
install
files
[]
=
profile
.
test
modules/simpletest/simpletest.info
View file @
e9d97f1e
...
...
@@ -7,3 +7,26 @@ core = 7.x
files
[]
=
simpletest
.
module
files
[]
=
simpletest
.
pages
.
inc
files
[]
=
simpletest
.
install
files
[]
=
simpletest
.
test
files
[]
=
drupal_web_test_case
.
php
;
Tests
in
tests
directory
.
files
[]
=
tests
/
actions
.
test
files
[]
=
tests
/
batch
.
test
files
[]
=
tests
/
bootstrap
.
test
files
[]
=
tests
/
cache
.
test
files
[]
=
tests
/
common
.
test
files
[]
=
tests
/
database_test
.
test
files
[]
=
tests
/
error
.
test
files
[]
=
tests
/
file
.
test
files
[]
=
tests
/
form
.
test
files
[]
=
tests
/
graph
.
test
files
[]
=
tests
/
image
.
test
files
[]
=
tests
/
menu
.
test
files
[]
=
tests
/
module
.
test
files
[]
=
tests
/
registry
.
test
files
[]
=
tests
/
schema
.
test
files
[]
=
tests
/
session
.
test
files
[]
=
tests
/
theme
.
test
files
[]
=
tests
/
unicode
.
test
files
[]
=
tests
/
xmlrpc
.
test
modules/simpletest/simpletest.module
View file @
e9d97f1e
...
...
@@ -139,9 +139,6 @@ function simpletest_run_tests($test_list, $reporter = 'drupal') {
* Batch operation callback.
*/
function
_simpletest_batch_operation
(
$test_list_init
,
$test_id
,
&
$context
)
{
// Ensure that all classes are loaded before we unserialize some instances.
simpletest_get_all_tests
();
// Get working values.
if
(
!
isset
(
$context
[
'sandbox'
][
'max'
]))
{
// First iteration: initialize working values.
...
...
@@ -200,65 +197,94 @@ function _simpletest_batch_finished($success, $results, $operations, $elapsed) {
}
/**
* Get a list of all of the tests.
* Get a list of all of the tests provided by the system.
*
* The list of test classes is loaded from the registry where it looks for
* files ending in ".test". Once loaded the test list is cached and stored in
* a static variable. In order to list tests provided by disabled modules
* hook_registry_files_alter() is used to forcefully add them to the registry.
*
* @return
* An array of tests, with the class name as the keys and the instantiated
* versions of the classes as the values.
* An array of tests keyed with the groups specified in each of the tests
* getInfo() method and then keyed by the test class. An example of the array
* structure is provided below.
*
* @code
* $groups['Blog'] => array(
* 'BlogTestCase' => array(
* 'name' => 'Blog functionality',
* 'description' => 'Create, view, edit, delete, ...',
* 'group' => 'Blog',
* ),
* );
* @endcode
* @see simpletest_registry_files_alter()
*/
function
simpletest_get_all_tests
()
{
static
$classes
;
if
(
!
isset
(
$classes
))
{
require_once
DRUPAL_ROOT
.
'/'
.
drupal_get_path
(
'module'
,
'simpletest'
)
.
'/drupal_web_test_case.php'
;
$files
=
array
();
foreach
(
array_keys
(
system_get_module_data
())
as
$module
)
{
$module_path
=
drupal_get_path
(
'module'
,
$module
);
$test
=
$module_path
.
"/
$module
.test"
;
if
(
file_exists
(
$test
))
{
$files
[]
=
$test
;
}
function
simpletest_test_get_all
()
{
$groups
=
&
drupal_static
(
__FUNCTION__
);
if
(
!
$groups
)
{
// Load test information from cache if available, otherwise retrieve the
// information from each tests getInfo() method.
if
(
$cache
=
cache_get
(
'simpletest'
,
'cache'
))
{
$groups
=
$cache
->
data
;
}
else
{
// Select all clases in files ending with .test.
$classes
=
db_select
(
'registry'
)
->
fields
(
'registry'
,
array
(
'name'
))
->
condition
(
'type'
,
'class'
)
->
condition
(
'filename'
,
'%.test'
,
'LIKE'
)
->
execute
();
$tests_directory
=
$module_path
.
'/tests'
;
if
(
is_dir
(
$tests_directory
))
{
foreach
(
file_scan_directory
(
$tests_directory
,
'/\.test$/'
)
as
$file
)
{
$files
[]
=
$file
->
filepath
;
$groups
=
array
();
// Check that each class has a getInfo() method and store the information
// in an array keyed with the group specified in the test information.
foreach
(
$classes
as
$class
)
{
$class
=
$class
->
name
;
if
(
class_exists
(
$class
)
&&
method_exists
(
$class
,
'getInfo'
))
{
// Valid test class, retrieve test information.
$info
=
call_user_func
(
array
(
$class
,
'getInfo'
));
// Initialize test groups.
if
(
!
isset
(
$groups
[
$info
[
'group'
]]))
{
$groups
[
$info
[
'group'
]]
=
array
();
}
$groups
[
$info
[
'group'
]][
$class
]
=
$info
;
}
}
}
$existing_classes
=
get_declared_classes
();
foreach
(
$files
as
$file
)
{
include_once
DRUPAL_ROOT
.
'/'
.
$file
;
}
$classes
=
array_values
(
array_diff
(
get_declared_classes
(),
$existing_classes
));
foreach
(
$classes
as
$key
=>
$class
)
{
if
(
!
is_subclass_of
(
$class
,
'DrupalTestCase'
)
||
!
method_exists
(
$class
,
'getInfo'
))
{
unset
(
$classes
[
$key
]);
// Sort the groups and tests within the groups by name.
uksort
(
$groups
,
'strnatcasecmp'
);
foreach
(
$groups
as
$group
=>
&
$tests
)
{
uksort
(
$tests
,
'strnatcasecmp'
);
}
cache_set
(
'simpletest'
,
$groups
);
}
}
if
(
count
(
$classes
)
==
0
)
{
drupal_set_message
(
'No test cases found.'
,
'error'
);
return
FALSE
;
}
return
$classes
;
return
$groups
;
}
/**
*
Categorize the tests into groups
.
*
Implementation of hook_registry_files_alter()
.
*
* @param $tests
* A list of tests from simpletest_get_all_tests.
* @see simpletest_get_all_tests.
* Add the test files for disabled modules so that we get a list containing
* all the avialable tests.
*/
function
simpletest_categorize_tests
(
$tests
)
{
$groups
=
array
();
foreach
(
$tests
as
$test
)
{
$info
=
call_user_func
(
array
(
$test
,
'getInfo'
));
$groups
[
$info
[
'group'
]][
$test
]
=
$info
;
function
simpletest_registry_files_alter
(
&
$files
,
$modules
)
{
foreach
(
$modules
as
$module
)
{
// Only add test files for disabled modules, as enabled modules should
// already include any test files they provide.
if
(
!
$module
->
status
)
{
$dir
=
$module
->
dir
;
foreach
(
$module
->
info
[
'files'
]
as
$file
)
{
if
(
substr
(
$file
,
-
5
)
==
'.test'
)
{
$files
[
"
$dir
/
$file
"
]
=
array
(
'module'
=>
$module
->
name
,
'weight'
=>
$module
->
weight
);
}
}
}
}
uksort
(
$groups
,
'strnatcasecmp'
);
return
$groups
;
}
/**
...
...
modules/simpletest/simpletest.pages.inc
View file @
e9d97f1e
...
...
@@ -12,10 +12,6 @@
function
simpletest_test_form
()
{
$form
=
array
();