Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
7
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Open sidebar
project
drupal
Commits
0fa72bde
Commit
0fa72bde
authored
Sep 11, 2017
by
catch
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Issue
#2853359
by vaplas, Lendude, tinny: Runtime debug statement in Views now prints out object
parent
e630c782
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
28 additions
and
5 deletions
+28
-5
core/modules/views/src/ViewExecutable.php
core/modules/views/src/ViewExecutable.php
+2
-1
core/modules/views/tests/src/Kernel/ViewExecutableTest.php
core/modules/views/tests/src/Kernel/ViewExecutableTest.php
+7
-2
core/modules/views_ui/src/Tests/ViewEditTest.php
core/modules/views_ui/src/Tests/ViewEditTest.php
+19
-2
No files found.
core/modules/views/src/ViewExecutable.php
View file @
0fa72bde
...
...
@@ -2,6 +2,7 @@
namespace
Drupal\views
;
use
Drupal\Component\Render\FormattableMarkup
;
use
Drupal\Component\Utility\Html
;
use
Drupal\Component\Utility\Tags
;
use
Drupal\Core\Routing\RouteProviderInterface
;
...
...
@@ -799,7 +800,7 @@ public function setDisplay($display_id = NULL) {
// Ensure the requested display exists.
if
(
!
$this
->
displayHandlers
->
has
(
$display_id
))
{
debug
(
format_string
(
'setDisplay() called with invalid display ID "@display".'
,
[
'@display'
=>
$display_id
]));
trigger_error
(
new
FormattableMarkup
(
'setDisplay() called with invalid display ID "@display".'
,
[
'@display'
=>
$display_id
])
,
E_USER_WARNING
);
return
FALSE
;
}
...
...
core/modules/views/tests/src/Kernel/ViewExecutableTest.php
View file @
0fa72bde
...
...
@@ -196,8 +196,13 @@ public function testSetDisplayWithInvalidDisplay() {
$view
->
initDisplay
();
// Error is triggered while calling the wrong display.
$this
->
setExpectedException
(
\
PHPUnit_Framework_Error
::
class
);
$view
->
setDisplay
(
'invalid'
);
try
{
$view
->
setDisplay
(
'invalid'
);
$this
->
fail
(
'Expected error, when setDisplay() called with invalid display ID'
);
}
catch
(
\
PHPUnit_Framework_Error_Warning
$e
)
{
$this
->
assertEquals
(
'setDisplay() called with invalid display ID "invalid".'
,
$e
->
getMessage
());
}
$this
->
assertEqual
(
$view
->
current_display
,
'default'
,
'If setDisplay is called with an invalid display id the default display should be used.'
);
$this
->
assertEqual
(
spl_object_hash
(
$view
->
display_handler
),
spl_object_hash
(
$view
->
displayHandlers
->
get
(
'default'
)));
...
...
core/modules/views_ui/src/Tests/ViewEditTest.php
View file @
0fa72bde
...
...
@@ -75,8 +75,13 @@ public function testOtherOptions() {
$error_text
=
t
(
'Display name must be letters, numbers, or underscores only.'
);
// Test that potential invalid display ID requests are detected
$this
->
drupalGet
(
'admin/structure/views/ajax/handler/test_view/fake_display_name/filter/title'
);
$this
->
assertText
(
'Invalid display id fake_display_name'
);
try
{
$this
->
drupalGet
(
'admin/structure/views/ajax/handler/test_view/fake_display_name/filter/title'
);
$this
->
fail
(
'Expected error, when setDisplay() called with invalid display ID'
);
}
catch
(
\
Exception
$e
)
{
$this
->
assertEqual
(
'setDisplay() called with invalid display ID "fake_display_name".'
,
$e
->
getMessage
());
}
$edit
=
[
'display_id'
=>
'test 1'
];
$this
->
drupalPostForm
(
$machine_name_edit_url
,
$edit
,
'Apply'
);
...
...
@@ -239,4 +244,16 @@ public function testRelationRepresentativeNode() {
$this
->
drupalPostForm
(
'admin/structure/views/nojs/handler/test_groupwise_term_ui/default/relationship/tid_representative'
,
$edit
,
'Apply'
);
}
/**
* Override the error method so we can test for the expected exception.
*
* @todo Remove as part of https://www.drupal.org/node/2864613
*/
protected
function
error
(
$message
=
''
,
$group
=
'Other'
,
array
$caller
=
NULL
)
{
if
(
$group
===
'User warning'
)
{
throw
new
\
Exception
(
$message
);
}
return
parent
::
error
(
$message
,
$group
,
$caller
);
}
}
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