Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
D
drupal
Manage
Activity
Members
Labels
Plan
Wiki
Custom issue tracker
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Model registry
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
project
drupal
Commits
3b6b9774
Commit
3b6b9774
authored
11 years ago
by
catch
Browse files
Options
Downloads
Patches
Plain Diff
Issue
#2197359
by xjm, alexpott: Random failure in Drupal\system\Tests\Common\RenderTest.
parent
a16b5639
Branches
Branches containing commit
No related tags found
2 merge requests
!7452
Issue #1797438. HTML5 validation is preventing form submit and not fully...
,
!789
Issue #3210310: Adjust Database API to remove deprecated Drupal 9 code in Drupal 10
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
core/modules/system/lib/Drupal/system/Tests/Common/RenderTest.php
+26
-5
26 additions, 5 deletions
...ules/system/lib/Drupal/system/Tests/Common/RenderTest.php
with
26 additions
and
5 deletions
core/modules/system/lib/Drupal/system/Tests/Common/RenderTest.php
+
26
−
5
View file @
3b6b9774
...
...
@@ -453,7 +453,7 @@ function testDrupalRenderCache() {
* Tests post-render cache callbacks functionality.
*/
function
testDrupalRenderPostRenderCache
()
{
$context
=
array
(
'foo'
=>
$this
->
random
String
());
$context
=
array
(
'foo'
=>
$this
->
random
ContextValue
());
$test_element
=
array
();
$test_element
[
'#markup'
]
=
''
;
$test_element
[
'#attached'
][
'js'
][]
=
array
(
'type'
=>
'setting'
,
'data'
=>
array
(
'foo'
=>
'bar'
));
...
...
@@ -553,9 +553,9 @@ function testDrupalRenderChildrenPostRenderCache() {
// Create an element with a child and subchild. Each element has the same
// #post_render_cache callback, but with different contexts.
drupal_static_reset
(
'_drupal_add_js'
);
$context_1
=
array
(
'foo'
=>
$this
->
random
String
());
$context_2
=
array
(
'bar'
=>
$this
->
random
String
());
$context_3
=
array
(
'baz'
=>
$this
->
random
String
());
$context_1
=
array
(
'foo'
=>
$this
->
random
ContextValue
());
$context_2
=
array
(
'bar'
=>
$this
->
random
ContextValue
());
$context_3
=
array
(
'baz'
=>
$this
->
random
ContextValue
());
$test_element
=
array
(
'#type'
=>
'details'
,
'#cache'
=>
array
(
...
...
@@ -770,7 +770,7 @@ function testDrupalRenderChildrenPostRenderCache() {
* Tests post-render cache-integrated 'render_cache_placeholder' element.
*/
function
testDrupalRenderRenderCachePlaceholder
()
{
$context
=
array
(
'bar'
=>
$this
->
random
String
());
$context
=
array
(
'bar'
=>
$this
->
random
ContextValue
());
$test_element
=
array
(
'#type'
=>
'render_cache_placeholder'
,
'#context'
=>
$context
,
...
...
@@ -846,4 +846,25 @@ protected function parseDrupalSettings($html) {
return
$parsed_settings
;
}
/**
* Generates a random context value for the post-render cache tests.
*
* The #context array used by the post-render cache callback will generally
* be used to provide metadata like entity IDs, field machine names, paths,
* etc. for JavaScript replacement of content or assets. In this test, the
* callbacks common_test_post_render_cache() and
* common_test_post_render_cache_placeholder() render the context inside test
* HTML, so using any random string would sometimes cause random test
* failures because the test output would be unparseable. Instead, we provide
* random tokens for replacement.
*
* @see common_test_post_render_cache()
* @see common_test_post_render_cache_placeholder()
* @see https://drupal.org/node/2151609
*/
protected
function
randomContextValue
()
{
$tokens
=
array
(
'llama'
,
'alpaca'
,
'camel'
,
'moose'
,
'elk'
);
return
$tokens
[
mt_rand
(
0
,
4
)];
}
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment