summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLee Rowlands2017-11-16 20:04:15 (GMT)
committerLee Rowlands2017-11-16 20:04:15 (GMT)
commit916e6ba9524d1a299e6d7aa5227785d76cf91faa (patch)
treeb794993e4e3d7bdcbb6017b5f68c9c34caeea659
parent622d5c47cf879fa080b7eb8929cb2375a898ee13 (diff)
Issue #2121119 by ACF, Sam152, BR0kEN: setDialogTitle in the OpenDialogCommand doesn't set the title
-rw-r--r--core/lib/Drupal/Core/Ajax/OpenDialogCommand.php2
-rw-r--r--core/tests/Drupal/Tests/Core/Ajax/AjaxCommandsTest.php26
2 files changed, 11 insertions, 17 deletions
diff --git a/core/lib/Drupal/Core/Ajax/OpenDialogCommand.php b/core/lib/Drupal/Core/Ajax/OpenDialogCommand.php
index 2b0fcdd..623d396 100644
--- a/core/lib/Drupal/Core/Ajax/OpenDialogCommand.php
+++ b/core/lib/Drupal/Core/Ajax/OpenDialogCommand.php
@@ -119,7 +119,7 @@ class OpenDialogCommand implements CommandInterface, CommandWithAttachedAssetsIn
* The new title of the dialog.
*/
public function setDialogTitle($title) {
- $this->setDialogOptions('title', $title);
+ $this->setDialogOption('title', $title);
}
/**
diff --git a/core/tests/Drupal/Tests/Core/Ajax/AjaxCommandsTest.php b/core/tests/Drupal/Tests/Core/Ajax/AjaxCommandsTest.php
index 4db1d02..1dd66b8 100644
--- a/core/tests/Drupal/Tests/Core/Ajax/AjaxCommandsTest.php
+++ b/core/tests/Drupal/Tests/Core/Ajax/AjaxCommandsTest.php
@@ -25,6 +25,7 @@ use Drupal\Core\Ajax\SetDialogOptionCommand;
use Drupal\Core\Ajax\SetDialogTitleCommand;
use Drupal\Core\Ajax\RedirectCommand;
use Drupal\Core\Ajax\UpdateBuildIdCommand;
+use Drupal\Core\Ajax\OpenDialogCommand;
/**
* Test coverage for various classes in the \Drupal\Core\Ajax namespace.
@@ -293,27 +294,16 @@ class AjaxCommandsTest extends UnitTestCase {
* @covers \Drupal\Core\Ajax\OpenDialogCommand
*/
public function testOpenDialogCommand() {
- $command = $this->getMockBuilder('Drupal\Core\Ajax\OpenDialogCommand')
- ->setConstructorArgs([
- '#some-dialog', 'Title', '<p>Text!</p>', [
- 'url' => FALSE,
- 'width' => 500,
- ],
- ])
- ->setMethods(['getRenderedContent'])
- ->getMock();
-
- // This method calls the render service, which isn't available. We want it
- // to do nothing so we mock it to return a known value.
- $command->expects($this->once())
- ->method('getRenderedContent')
- ->willReturn('rendered content');
+ $command = new OpenDialogCommand('#some-dialog', 'Title', '<p>Text!</p>', [
+ 'url' => FALSE,
+ 'width' => 500,
+ ]);
$expected = [
'command' => 'openDialog',
'selector' => '#some-dialog',
'settings' => NULL,
- 'data' => 'rendered content',
+ 'data' => '<p>Text!</p>',
'dialogOptions' => [
'url' => FALSE,
'width' => 500,
@@ -322,6 +312,10 @@ class AjaxCommandsTest extends UnitTestCase {
],
];
$this->assertEquals($expected, $command->render());
+
+ $command->setDialogTitle('New title');
+ $expected['dialogOptions']['title'] = 'New title';
+ $this->assertEquals($expected, $command->render());
}
/**