Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
D
drupal-3402990
Manage
Activity
Members
Labels
Plan
Custom issue tracker
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
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
Issue forks
drupal-3402990
Commits
0349bb14
Commit
0349bb14
authored
8 years ago
by
catch
Browse files
Options
Downloads
Patches
Plain Diff
Issue
#2751875
by klausi: BrowserTestBase must enable cache tags in responses
(cherry picked from commit
a055d6a9
)
parent
889f48de
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
core/modules/simpletest/tests/src/Functional/BrowserTestBaseTest.php
+3
-0
3 additions, 0 deletions
...s/simpletest/tests/src/Functional/BrowserTestBaseTest.php
core/tests/Drupal/Tests/BrowserTestBase.php
+34
-3
34 additions, 3 deletions
core/tests/Drupal/Tests/BrowserTestBase.php
with
37 additions
and
3 deletions
core/modules/simpletest/tests/src/Functional/BrowserTestBaseTest.php
+
3
−
0
View file @
0349bb14
...
...
@@ -33,6 +33,9 @@ public function testGoTo() {
// Test page contains some text.
$this
->
assertSession
()
->
pageTextContains
(
'Test page text.'
);
// Response includes cache tags that we can assert.
$this
->
assertSession
()
->
responseHeaderEquals
(
'X-Drupal-Cache-Tags'
,
'rendered'
);
// Test drupalGet with a url object.
$url
=
Url
::
fromRoute
(
'test_page_test.render_title'
);
$this
->
drupalGet
(
$url
);
...
...
This diff is collapsed.
Click to expand it.
core/tests/Drupal/Tests/BrowserTestBase.php
+
34
−
3
View file @
0349bb14
...
...
@@ -6,6 +6,8 @@
use
Behat\Mink\Element\Element
;
use
Behat\Mink\Mink
;
use
Behat\Mink\Session
;
use
Drupal\Component\FileCache\FileCacheFactory
;
use
Drupal\Component\Serialization\Yaml
;
use
Drupal\Component\Utility\Html
;
use
Drupal\Component\Utility\SafeMarkup
;
use
Drupal\Component\Utility\UrlHelper
;
...
...
@@ -1071,11 +1073,14 @@ public function installDrupal() {
// testing specific overrides.
file_put_contents
(
$directory
.
'/settings.php'
,
"
\n\$
test_class = '"
.
get_class
(
$this
)
.
"';
\n
"
.
'include DRUPAL_ROOT . \'/\' . $site_path . \'/settings.testing.php\';'
.
"
\n
"
,
FILE_APPEND
);
}
$settings_services_file
=
DRUPAL_ROOT
.
'/'
.
$this
->
originalSiteDirectory
.
'/testing.services.yml'
;
if
(
file_exists
(
$settings_services_file
))
{
//
Copy the testing-specific service
overrides
in place
.
copy
(
$settings_services_file
,
$directory
.
'/
services.yml'
)
;
if
(
!
file_exists
(
$settings_services_file
))
{
//
Otherwise, use the default services as a starting point for
overrides.
$settings_services_file
=
DRUPAL_ROOT
.
'/sites/default/default.
services.yml'
;
}
// Copy the testing-specific service overrides in place.
copy
(
$settings_services_file
,
$directory
.
'/services.yml'
);
// Since Drupal is bootstrapped already, install_begin_request() will not
// bootstrap into DRUPAL_BOOTSTRAP_CONFIGURATION (again). Hence, we have to
...
...
@@ -1100,6 +1105,10 @@ public function installDrupal() {
// using File API; a potential error must trigger a PHP warning.
chmod
(
$directory
,
0777
);
// During tests, cacheable responses should get the debugging cacheability
// headers by default.
$this
->
setContainerParameter
(
'http.response.debug_cacheability_headers'
,
TRUE
);
$request
=
\Drupal
::
request
();
$this
->
kernel
=
DrupalKernel
::
createFromRequest
(
$request
,
$this
->
classLoader
,
'prod'
,
TRUE
);
$this
->
kernel
->
prepareLegacyRequest
(
$request
);
...
...
@@ -1501,6 +1510,7 @@ protected function resetAll() {
*/
protected
function
refreshVariables
()
{
// Clear the tag cache.
$this
->
container
->
get
(
'cache_tags.invalidator'
)
->
resetChecksums
();
// @todo Replace drupal_static() usage within classes and provide a
// proper interface for invoking reset() on a cache backend:
// https://www.drupal.org/node/2311945.
...
...
@@ -1775,4 +1785,25 @@ public static function assertEquals($expected, $actual, $message = '', $delta =
parent
::
assertEquals
(
$expected
,
$actual
,
$message
,
$delta
,
$maxDepth
,
$canonicalize
,
$ignoreCase
);
}
/**
* Changes parameters in the services.yml file.
*
* @param string $name
* The name of the parameter.
* @param mixed $value
* The value of the parameter.
*/
protected
function
setContainerParameter
(
$name
,
$value
)
{
$filename
=
$this
->
siteDirectory
.
'/services.yml'
;
chmod
(
$filename
,
0666
);
$services
=
Yaml
::
decode
(
file_get_contents
(
$filename
));
$services
[
'parameters'
][
$name
]
=
$value
;
file_put_contents
(
$filename
,
Yaml
::
encode
(
$services
));
// Ensure that the cache is deleted for the yaml file loader.
$file_cache
=
FileCacheFactory
::
get
(
'container_yaml_loader'
);
$file_cache
->
delete
(
$filename
);
}
}
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