Commit 5efd60da authored by willzyx's avatar willzyx

Issue #2705897 by willzyx, guilopes: dd function is not working for user...

Issue #2705897 by willzyx, guilopes: dd function is not working for user without 'access devel information' permission
parent ca8954d9
......@@ -101,8 +101,7 @@ class DevelDumperManager implements DevelDumperManagerInterface {
* {@inheritdoc}
*/
public function debug($input, $name = NULL, $plugin_id = NULL) {
$name = $name ? $name . ': ' : '';
$output = $this->export($input, $name, $plugin_id) . "\n";
$output = $this->createInstance($plugin_id)->export($input, $name) . "\n";
// The temp directory does vary across multiple simpletest instances.
$file = file_directory_temp() . '/drupal_debug.txt';
if (file_put_contents($file, $output, FILE_APPEND) === FALSE && $this->hasAccessToDevelInformation()) {
......
......@@ -137,8 +137,23 @@ class DevelDumperTest extends WebTestBase {
$this->assertRaw('devel_dumper_test/css/devel_dumper_test.css');
$this->assertRaw('devel_dumper_test/js/devel_dumper_test.js');
$debug_filename = file_directory_temp() . '/drupal_debug.txt';
$this->drupalGet('devel_dumper_test/debug');
$file_content = file_get_contents($debug_filename);
$expected = <<<EOF
<pre>AvailableTestDumper::export() Test output</pre>
EOF;
$this->assertEqual($file_content, $expected, 'Dumped message is present.');
// Ensures that the DevelDumperManager::debug() is not access checked and
// that the dump is written in the debug file even if the user has not the
// 'access devel information' permission.
file_put_contents($debug_filename, '');
$this->drupalLogout();
$this->drupalGet('devel_dumper_test/debug');
$file_content = file_get_contents(file_directory_temp() . '/drupal_debug.txt');
$file_content = file_get_contents($debug_filename);
$expected = <<<EOF
<pre>AvailableTestDumper::export() Test output</pre>
......
......@@ -36,4 +36,4 @@ devel_dumper_test.debug:
_controller: '\Drupal\devel_dumper_test\Controller\DumperTestController::debug'
_title: 'Devel Dumper Test'
requirements:
_permission: 'access devel information'
_access: 'TRUE'
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment