Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
D
drupal-3485117
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-3485117
Commits
852b0bab
Commit
852b0bab
authored
10 years ago
by
Alex Pott
Browse files
Options
Downloads
Patches
Plain Diff
Issue
#2417733
by joelpittet, martin107: Drupal 8 breaks Twig's round filter
parent
a32a88cb
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/tests/Drupal/Tests/Core/Theme/TwigEngineTest.php
+59
-0
59 additions, 0 deletions
core/tests/Drupal/Tests/Core/Theme/TwigEngineTest.php
core/themes/engines/twig/twig.engine
+4
-4
4 additions, 4 deletions
core/themes/engines/twig/twig.engine
with
63 additions
and
4 deletions
core/tests/Drupal/Tests/Core/Theme/TwigEngineTest.php
0 → 100644
+
59
−
0
View file @
852b0bab
<?php
/**
* @file
* Contains \Drupal\Tests\Core\Theme\TwigEngineTest.
*/
namespace
Drupal\Tests\Core\Theme
;
use
Drupal\Tests\UnitTestCase
;
/**
* Test coverage for the file core/themes/engines/twig/twig.engine.
*
* @group Theme
*/
class
TwigEngineTest
extends
UnitTestCase
{
/**
* The mocked Twig environment.
*
* @var \Twig_Environment|\PHPUnit_Framework_MockObject_MockObject
*/
protected
$twigEnvironment
;
/**
* {@inheritdoc}
*/
protected
function
setUp
()
{
parent
::
setUp
();
// Ensure that twig.engine is loaded, it is needed to access
// twig_drupal_escape_filter().
require_once
$this
->
root
.
'/core/themes/engines/twig/twig.engine'
;
$this
->
twigEnvironment
=
$this
->
getMock
(
'\Twig_Environment'
);
}
/**
* Tests output of integer and double 0 values of twig_render_var().
*
* @see https://www.drupal.org/node/2417733
*/
public
function
testsRenderZeroValue
()
{
$this
->
assertSame
(
twig_render_var
(
0
),
0
,
'twig_render_var() renders zero correctly when provided as an integer.'
);
$this
->
assertSame
(
twig_render_var
(
0.0
),
0
,
'twig_render_var() renders zero correctly when provided as a double.'
);
}
/**
* Tests output of integer and double 0 values of twig_drupal_escape_filter().
*
* @see https://www.drupal.org/node/2417733
*/
public
function
testsRenderEscapedZeroValue
()
{
$this
->
assertSame
(
twig_drupal_escape_filter
(
$this
->
twigEnvironment
,
0
),
0
,
'twig_escape_filter() returns zero correctly when provided as an integer.'
);
$this
->
assertSame
(
twig_drupal_escape_filter
(
$this
->
twigEnvironment
,
0.0
),
0
,
'twig_escape_filter() returns zero correctly when provided as a double.'
);
}
}
This diff is collapsed.
Click to expand it.
core/themes/engines/twig/twig.engine
+
4
−
4
View file @
852b0bab
...
...
@@ -127,8 +127,8 @@ function twig_render_template($template_file, array $variables) {
* @see TwigNodeVisitor
*/
function
twig_render_var
(
$arg
)
{
// Check for numeric zero.
if
(
$arg
===
0
)
{
// Check for
a
numeric zero
int or float
.
if
(
$arg
===
0
||
$arg
===
0.0
)
{
return
0
;
}
...
...
@@ -213,8 +213,8 @@ function twig_without($element) {
* The escaped, rendered output, or NULL if there is no valid output.
*/
function
twig_drupal_escape_filter
(
\Twig_Environment
$env
,
$string
,
$strategy
=
'html'
,
$charset
=
NULL
,
$autoescape
=
FALSE
)
{
// Check for a numeric zero.
if
(
$string
===
0
)
{
// Check for a numeric zero
int or float
.
if
(
$string
===
0
||
$string
===
0.0
)
{
return
0
;
}
...
...
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