Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
project
drupal
Commits
768208f8
Commit
768208f8
authored
Feb 28, 2011
by
Dries
Browse files
- Patch
#1076394
by pillarsdotnet: improved test code.
parent
540ee5f4
Changes
8
Hide whitespace changes
Inline
Side-by-side
modules/comment/comment.test
View file @
768208f8
...
...
@@ -1698,7 +1698,7 @@ class CommentTokenReplaceTestCase extends CommentHelperCase {
foreach
(
$tests
as
$input
=>
$expected
)
{
$output
=
token_replace
(
$input
,
array
(
'comment'
=>
$comment
),
array
(
'language'
=>
$language
));
$this
->
assert
False
(
strcmp
(
$output
,
$expected
)
,
t
(
'Sanitized comment token %token replaced.'
,
array
(
'%token'
=>
$input
)));
$this
->
assert
Equal
(
$output
,
$expected
,
t
(
'Sanitized comment token %token replaced.'
,
array
(
'%token'
=>
$input
)));
}
// Generate and test unsanitized tokens.
...
...
@@ -1714,7 +1714,7 @@ class CommentTokenReplaceTestCase extends CommentHelperCase {
foreach
(
$tests
as
$input
=>
$expected
)
{
$output
=
token_replace
(
$input
,
array
(
'comment'
=>
$comment
),
array
(
'language'
=>
$language
,
'sanitize'
=>
FALSE
));
$this
->
assert
False
(
strcmp
(
$output
,
$expected
)
,
t
(
'Unsanitized comment token %token replaced.'
,
array
(
'%token'
=>
$input
)));
$this
->
assert
Equal
(
$output
,
$expected
,
t
(
'Unsanitized comment token %token replaced.'
,
array
(
'%token'
=>
$input
)));
}
// Load node so comment_count gets computed.
...
...
@@ -1727,7 +1727,7 @@ class CommentTokenReplaceTestCase extends CommentHelperCase {
foreach
(
$tests
as
$input
=>
$expected
)
{
$output
=
token_replace
(
$input
,
array
(
'node'
=>
$node
),
array
(
'language'
=>
$language
));
$this
->
assert
False
(
strcmp
(
$output
,
$expected
)
,
t
(
'Node comment token %token replaced.'
,
array
(
'%token'
=>
$input
)));
$this
->
assert
Equal
(
$output
,
$expected
,
t
(
'Node comment token %token replaced.'
,
array
(
'%token'
=>
$input
)));
}
}
}
...
...
modules/file/tests/file.test
View file @
768208f8
...
...
@@ -1026,7 +1026,7 @@ class FileTokenReplaceTestCase extends FileFieldTestCase {
foreach
(
$tests
as
$input
=>
$expected
)
{
$output
=
token_replace
(
$input
,
array
(
'file'
=>
$file
),
array
(
'language'
=>
$language
));
$this
->
assert
False
(
strcmp
(
$output
,
$expected
)
,
t
(
'Sanitized file token %token replaced.'
,
array
(
'%token'
=>
$input
)));
$this
->
assert
Equal
(
$output
,
$expected
,
t
(
'Sanitized file token %token replaced.'
,
array
(
'%token'
=>
$input
)));
}
// Generate and test unsanitized tokens.
...
...
@@ -1038,7 +1038,7 @@ class FileTokenReplaceTestCase extends FileFieldTestCase {
foreach
(
$tests
as
$input
=>
$expected
)
{
$output
=
token_replace
(
$input
,
array
(
'file'
=>
$file
),
array
(
'language'
=>
$language
,
'sanitize'
=>
FALSE
));
$this
->
assert
False
(
strcmp
(
$output
,
$expected
)
,
t
(
'Unsanitized file token %token replaced.'
,
array
(
'%token'
=>
$input
)));
$this
->
assert
Equal
(
$output
,
$expected
,
t
(
'Unsanitized file token %token replaced.'
,
array
(
'%token'
=>
$input
)));
}
}
}
modules/node/node.test
View file @
768208f8
...
...
@@ -2130,7 +2130,7 @@ class NodeTokenReplaceTestCase extends DrupalWebTestCase {
foreach
(
$tests
as
$input
=>
$expected
)
{
$output
=
token_replace
(
$input
,
array
(
'node'
=>
$node
),
array
(
'language'
=>
$language
));
$this
->
assert
False
(
strcmp
(
$output
,
$expected
)
,
t
(
'Sanitized node token %token replaced.'
,
array
(
'%token'
=>
$input
)));
$this
->
assert
Equal
(
$output
,
$expected
,
t
(
'Sanitized node token %token replaced.'
,
array
(
'%token'
=>
$input
)));
}
// Generate and test unsanitized tokens.
...
...
@@ -2142,7 +2142,7 @@ class NodeTokenReplaceTestCase extends DrupalWebTestCase {
foreach
(
$tests
as
$input
=>
$expected
)
{
$output
=
token_replace
(
$input
,
array
(
'node'
=>
$node
),
array
(
'language'
=>
$language
,
'sanitize'
=>
FALSE
));
$this
->
assert
False
(
strcmp
(
$output
,
$expected
)
,
t
(
'Unsanitized node token %token replaced.'
,
array
(
'%token'
=>
$input
)));
$this
->
assert
Equal
(
$output
,
$expected
,
t
(
'Unsanitized node token %token replaced.'
,
array
(
'%token'
=>
$input
)));
}
}
}
modules/poll/poll.test
View file @
768208f8
...
...
@@ -652,7 +652,7 @@ class PollTokenReplaceTestCase extends PollTestCase {
foreach
(
$tests
as
$input
=>
$expected
)
{
$output
=
token_replace
(
$input
,
array
(
'node'
=>
$poll
),
array
(
'language'
=>
$language
));
$this
->
assert
False
(
strcmp
(
$output
,
$expected
)
,
t
(
'Sanitized poll token %token replaced.'
,
array
(
'%token'
=>
$input
)));
$this
->
assert
Equal
(
$output
,
$expected
,
t
(
'Sanitized poll token %token replaced.'
,
array
(
'%token'
=>
$input
)));
}
// Generate and test unsanitized tokens.
...
...
@@ -660,7 +660,7 @@ class PollTokenReplaceTestCase extends PollTestCase {
foreach
(
$tests
as
$input
=>
$expected
)
{
$output
=
token_replace
(
$input
,
array
(
'node'
=>
$poll
),
array
(
'language'
=>
$language
,
'sanitize'
=>
FALSE
));
$this
->
assert
False
(
strcmp
(
$output
,
$expected
)
,
t
(
'Unsanitized poll token %token replaced.'
,
array
(
'%token'
=>
$input
)));
$this
->
assert
Equal
(
$output
,
$expected
,
t
(
'Unsanitized poll token %token replaced.'
,
array
(
'%token'
=>
$input
)));
}
}
}
...
...
modules/statistics/statistics.test
View file @
768208f8
...
...
@@ -438,7 +438,7 @@ class StatisticsTokenReplaceTestCase extends StatisticsTestCase {
foreach
(
$tests
as
$input
=>
$expected
)
{
$output
=
token_replace
(
$input
,
array
(
'node'
=>
$node
),
array
(
'language'
=>
$language
));
$this
->
assert
False
(
strcmp
(
$output
,
$expected
)
,
t
(
'Statistics token %token replaced.'
,
array
(
'%token'
=>
$input
)));
$this
->
assert
Equal
(
$output
,
$expected
,
t
(
'Statistics token %token replaced.'
,
array
(
'%token'
=>
$input
)));
}
}
}
modules/system/system.test
View file @
768208f8
...
...
@@ -1575,13 +1575,13 @@ class TokenReplaceTestCase extends DrupalWebTestCase {
// Test that the clear parameter cleans out non-existent tokens.
$result
=
token_replace
(
$source
,
array
(
'node'
=>
$node
),
array
(
'language'
=>
$language
,
'clear'
=>
TRUE
));
$result
=
$this
->
assert
False
(
strcmp
(
$target
,
$result
)
,
'Valid tokens replaced while invalid tokens cleared out.'
);
$result
=
$this
->
assert
Equal
(
$target
,
$result
,
'Valid tokens replaced while invalid tokens cleared out.'
);
// Test without using the clear parameter (non-existant token untouched).
$target
.
=
'[user:name]'
;
$target
.
=
'[bogus:token]'
;
$result
=
token_replace
(
$source
,
array
(
'node'
=>
$node
),
array
(
'language'
=>
$language
));
$this
->
assert
False
(
strcmp
(
$target
,
$result
)
,
'Valid tokens replaced while invalid tokens ignored.'
);
$this
->
assert
Equal
(
$target
,
$result
,
'Valid tokens replaced while invalid tokens ignored.'
);
// Check that the results of token_generate are sanitized properly. This does NOT
// test the cleanliness of every token -- just that the $sanitize flag is being
...
...
@@ -1589,10 +1589,10 @@ class TokenReplaceTestCase extends DrupalWebTestCase {
// token, [node:title].
$raw_tokens
=
array
(
'title'
=>
'[node:title]'
);
$generated
=
token_generate
(
'node'
,
$raw_tokens
,
array
(
'node'
=>
$node
));
$this
->
assert
False
(
strcmp
(
$generated
[
'[node:title]'
],
check_plain
(
$node
->
title
)
)
,
t
(
'Token sanitized.'
));
$this
->
assert
Equal
(
$generated
[
'[node:title]'
],
check_plain
(
$node
->
title
),
t
(
'Token sanitized.'
));
$generated
=
token_generate
(
'node'
,
$raw_tokens
,
array
(
'node'
=>
$node
),
array
(
'sanitize'
=>
FALSE
));
$this
->
assert
False
(
strcmp
(
$generated
[
'[node:title]'
],
$node
->
title
)
,
t
(
'Unsanitized token generated properly.'
));
$this
->
assert
Equal
(
$generated
[
'[node:title]'
],
$node
->
title
,
t
(
'Unsanitized token generated properly.'
));
}
/**
...
...
@@ -1624,7 +1624,7 @@ class TokenReplaceTestCase extends DrupalWebTestCase {
foreach
(
$tests
as
$input
=>
$expected
)
{
$output
=
token_replace
(
$input
,
array
(),
array
(
'language'
=>
$language
));
$this
->
assert
False
(
strcmp
(
$output
,
$expected
)
,
t
(
'Sanitized system site information token %token replaced.'
,
array
(
'%token'
=>
$input
)));
$this
->
assert
Equal
(
$output
,
$expected
,
t
(
'Sanitized system site information token %token replaced.'
,
array
(
'%token'
=>
$input
)));
}
// Generate and test unsanitized tokens.
...
...
@@ -1633,7 +1633,7 @@ class TokenReplaceTestCase extends DrupalWebTestCase {
foreach
(
$tests
as
$input
=>
$expected
)
{
$output
=
token_replace
(
$input
,
array
(),
array
(
'language'
=>
$language
,
'sanitize'
=>
FALSE
));
$this
->
assert
False
(
strcmp
(
$output
,
$expected
)
,
t
(
'Unsanitized system site information token %token replaced.'
,
array
(
'%token'
=>
$input
)));
$this
->
assert
Equal
(
$output
,
$expected
,
t
(
'Unsanitized system site information token %token replaced.'
,
array
(
'%token'
=>
$input
)));
}
}
...
...
@@ -1660,7 +1660,7 @@ class TokenReplaceTestCase extends DrupalWebTestCase {
foreach
(
$tests
as
$input
=>
$expected
)
{
$output
=
token_replace
(
$input
,
array
(
'date'
=>
$date
),
array
(
'language'
=>
$language
));
$this
->
assert
False
(
strcmp
(
$output
,
$expected
)
,
t
(
'Date token %token replaced.'
,
array
(
'%token'
=>
$input
)));
$this
->
assert
Equal
(
$output
,
$expected
,
t
(
'Date token %token replaced.'
,
array
(
'%token'
=>
$input
)));
}
}
}
...
...
modules/taxonomy/taxonomy.test
View file @
768208f8
...
...
@@ -1107,7 +1107,7 @@ class TaxonomyTokenReplaceTestCase extends TaxonomyWebTestCase {
foreach
(
$tests
as
$input
=>
$expected
)
{
$output
=
token_replace
(
$input
,
array
(
'term'
=>
$term1
),
array
(
'language'
=>
$language
));
$this
->
assert
False
(
strcmp
(
$output
,
$expected
)
,
t
(
'Sanitized taxonomy term token %token replaced.'
,
array
(
'%token'
=>
$input
)));
$this
->
assert
Equal
(
$output
,
$expected
,
t
(
'Sanitized taxonomy term token %token replaced.'
,
array
(
'%token'
=>
$input
)));
}
// Generate and test sanitized tokens for term2.
...
...
@@ -1127,7 +1127,7 @@ class TaxonomyTokenReplaceTestCase extends TaxonomyWebTestCase {
foreach
(
$tests
as
$input
=>
$expected
)
{
$output
=
token_replace
(
$input
,
array
(
'term'
=>
$term2
),
array
(
'language'
=>
$language
));
$this
->
assert
False
(
strcmp
(
$output
,
$expected
)
,
t
(
'Sanitized taxonomy term token %token replaced.'
,
array
(
'%token'
=>
$input
)));
$this
->
assert
Equal
(
$output
,
$expected
,
t
(
'Sanitized taxonomy term token %token replaced.'
,
array
(
'%token'
=>
$input
)));
}
// Generate and test unsanitized tokens.
...
...
@@ -1138,7 +1138,7 @@ class TaxonomyTokenReplaceTestCase extends TaxonomyWebTestCase {
foreach
(
$tests
as
$input
=>
$expected
)
{
$output
=
token_replace
(
$input
,
array
(
'term'
=>
$term2
),
array
(
'language'
=>
$language
,
'sanitize'
=>
FALSE
));
$this
->
assert
False
(
strcmp
(
$output
,
$expected
)
,
t
(
'Unsanitized taxonomy term token %token replaced.'
,
array
(
'%token'
=>
$input
)));
$this
->
assert
Equal
(
$output
,
$expected
,
t
(
'Unsanitized taxonomy term token %token replaced.'
,
array
(
'%token'
=>
$input
)));
}
// Generate and test sanitized tokens.
...
...
@@ -1154,7 +1154,7 @@ class TaxonomyTokenReplaceTestCase extends TaxonomyWebTestCase {
foreach
(
$tests
as
$input
=>
$expected
)
{
$output
=
token_replace
(
$input
,
array
(
'vocabulary'
=>
$this
->
vocabulary
),
array
(
'language'
=>
$language
));
$this
->
assert
False
(
strcmp
(
$output
,
$expected
)
,
t
(
'Sanitized taxonomy vocabulary token %token replaced.'
,
array
(
'%token'
=>
$input
)));
$this
->
assert
Equal
(
$output
,
$expected
,
t
(
'Sanitized taxonomy vocabulary token %token replaced.'
,
array
(
'%token'
=>
$input
)));
}
// Generate and test unsanitized tokens.
...
...
@@ -1163,7 +1163,7 @@ class TaxonomyTokenReplaceTestCase extends TaxonomyWebTestCase {
foreach
(
$tests
as
$input
=>
$expected
)
{
$output
=
token_replace
(
$input
,
array
(
'vocabulary'
=>
$this
->
vocabulary
),
array
(
'language'
=>
$language
,
'sanitize'
=>
FALSE
));
$this
->
assert
False
(
strcmp
(
$output
,
$expected
)
,
t
(
'Unsanitized taxonomy vocabulary token %token replaced.'
,
array
(
'%token'
=>
$input
)));
$this
->
assert
Equal
(
$output
,
$expected
,
t
(
'Unsanitized taxonomy vocabulary token %token replaced.'
,
array
(
'%token'
=>
$input
)));
}
}
}
...
...
modules/user/user.test
View file @
768208f8
...
...
@@ -1904,7 +1904,7 @@ class UserTokenReplaceTestCase extends DrupalWebTestCase {
foreach
(
$tests
as
$input
=>
$expected
)
{
$output
=
token_replace
(
$input
,
array
(
'user'
=>
$account
),
array
(
'language'
=>
$language
));
$this
->
assert
False
(
strcmp
(
$output
,
$expected
)
,
t
(
'Sanitized user token %token replaced.'
,
array
(
'%token'
=>
$input
)));
$this
->
assert
Equal
(
$output
,
$expected
,
t
(
'Sanitized user token %token replaced.'
,
array
(
'%token'
=>
$input
)));
}
// Generate and test unsanitized tokens.
...
...
@@ -1914,7 +1914,7 @@ class UserTokenReplaceTestCase extends DrupalWebTestCase {
foreach
(
$tests
as
$input
=>
$expected
)
{
$output
=
token_replace
(
$input
,
array
(
'user'
=>
$account
),
array
(
'language'
=>
$language
,
'sanitize'
=>
FALSE
));
$this
->
assert
False
(
strcmp
(
$output
,
$expected
)
,
t
(
'Unsanitized user token %token replaced.'
,
array
(
'%token'
=>
$input
)));
$this
->
assert
Equal
(
$output
,
$expected
,
t
(
'Unsanitized user token %token replaced.'
,
array
(
'%token'
=>
$input
)));
}
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment