Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
D
drupal-3443915
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-3443915
Commits
2f074ce2
Commit
2f074ce2
authored
12 years ago
by
Angie Byron
Browse files
Options
Downloads
Patches
Plain Diff
Revert "Issue
#1843034
follow-up by Cottser: Tests for configurable Twig settings."
This reverts commit
3cf10751
. Tests no longer pass, so this breaks testbot.
parent
31228071
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
core/modules/system/lib/Drupal/system/Tests/Theme/TwigSettingsTest.php
+0
-110
0 additions, 110 deletions
...system/lib/Drupal/system/Tests/Theme/TwigSettingsTest.php
with
0 additions
and
110 deletions
core/modules/system/lib/Drupal/system/Tests/Theme/TwigSettingsTest.php
deleted
100644 → 0
+
0
−
110
View file @
31228071
<?php
/**
* @file
* Contains \Drupal\system\Tests\Theme\TwigSettingsTest.
*/
namespace
Drupal\system\Tests\Theme
;
use
Drupal\simpletest\WebTestBase
;
use
Drupal\Component\PhpStorage\PhpStorageFactory
;
/**
* Tests Twig engine configuration via settings.php.
*/
class
TwigSettingsTest
extends
WebTestBase
{
/**
* Modules to enable.
*
* @var array
*/
public
static
$modules
=
array
(
'theme_test'
);
public
static
function
getInfo
()
{
return
array
(
'name'
=>
'Twig Settings'
,
'description'
=>
'Tests overriding Twig engine settings via settings.php.'
,
'group'
=>
'Theme'
,
);
}
/**
* Ensures Twig template auto reload setting can be overridden.
*/
function
testTwigAutoReloadOverride
()
{
// Enable auto reload and rebuild the service container.
$this
->
settingsSet
(
'twig_auto_reload'
,
TRUE
);
$this
->
rebuildContainer
();
// Check isAutoReload() via the Twig service container.
$this
->
assertTrue
(
drupal_container
()
->
get
(
'twig'
)
->
isAutoReload
(),
'Automatic reloading of Twig templates enabled.'
);
// Disable auto reload and check the service container again.
$this
->
settingsSet
(
'twig_auto_reload'
,
FALSE
);
$this
->
rebuildContainer
();
$this
->
assertFalse
(
drupal_container
()
->
get
(
'twig'
)
->
isAutoReload
(),
'Automatic reloading of Twig templates disabled.'
);
}
/**
* Ensures Twig engine debug setting can be overridden.
*/
function
testTwigDebugOverride
()
{
// Enable debug and rebuild the service container.
$this
->
settingsSet
(
'twig_debug'
,
TRUE
);
$this
->
rebuildContainer
();
// Check isDebug() via the Twig service container.
$this
->
assertTrue
(
drupal_container
()
->
get
(
'twig'
)
->
isDebug
(),
'Twig debug enabled.'
);
$this
->
assertTrue
(
drupal_container
()
->
get
(
'twig'
)
->
isAutoReload
(),
'Twig automatic reloading is enabled when debug is enabled.'
);
// Override auto reload when debug is enabled.
$this
->
settingsSet
(
'twig_auto_reload'
,
FALSE
);
$this
->
rebuildContainer
();
$this
->
assertFalse
(
drupal_container
()
->
get
(
'twig'
)
->
isAutoReload
(),
'Twig automatic reloading can be disabled when debug is enabled.'
);
// Disable debug and check the service container again.
$this
->
settingsSet
(
'twig_debug'
,
FALSE
);
$this
->
rebuildContainer
();
$this
->
assertFalse
(
drupal_container
()
->
get
(
'twig'
)
->
isDebug
(),
'Twig debug disabled.'
);
}
/**
* Ensures Twig template cache setting can be overridden.
*/
function
testTwigCacheOverride
()
{
$extension
=
twig_extension
();
theme_enable
(
array
(
'test_theme_twig'
));
variable_set
(
'theme_default'
,
'test_theme_twig'
);
$cache
=
array
();
// Prime the theme cache.
foreach
(
module_implements
(
'theme'
)
as
$module
)
{
_theme_process_registry
(
$cache
,
$module
,
'module'
,
$module
,
drupal_get_path
(
'module'
,
$module
));
}
// Load array of Twig templates.
$templates
=
drupal_find_theme_templates
(
$cache
,
$extension
,
drupal_get_path
(
'theme'
,
'test_theme_twig'
));
// Get the template filename and the cache filename for
// theme_test.template_test.html.twig.
$template_filename
=
$templates
[
'theme_test_template_test'
][
'path'
]
.
'/'
.
$templates
[
'theme_test_template_test'
][
'template'
]
.
$extension
;
$cache_filename
=
drupal_container
()
->
get
(
'twig'
)
->
getCacheFilename
(
$template_filename
);
// Navigate to the page and make sure the template gets cached.
$this
->
drupalGet
(
'theme-test/template-test'
);
$this
->
assertTrue
(
PhpStorageFactory
::
get
(
'twig'
)
->
exists
(
$cache_filename
),
'Cached Twig template found.'
);
// Disable the Twig cache and rebuild the service container.
$this
->
settingsSet
(
'twig_cache'
,
FALSE
);
$this
->
rebuildContainer
();
// This should return false after rebuilding the service container.
$new_cache_filename
=
drupal_container
()
->
get
(
'twig'
)
->
getCacheFilename
(
$template_filename
);
$this
->
assertFalse
(
$new_cache_filename
,
'Twig environment does not return cache filename after caching is disabled.'
);
}
}
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