Commit 916e6ba9 authored by larowlan's avatar larowlan

Issue #2121119 by ACF, Sam152, BR0kEN: setDialogTitle in the OpenDialogCommand...

Issue #2121119 by ACF, Sam152, BR0kEN: setDialogTitle in the OpenDialogCommand doesn't set the title
parent 622d5c47
...@@ -119,7 +119,7 @@ public function setDialogOption($key, $value) { ...@@ -119,7 +119,7 @@ public function setDialogOption($key, $value) {
* The new title of the dialog. * The new title of the dialog.
*/ */
public function setDialogTitle($title) { public function setDialogTitle($title) {
$this->setDialogOptions('title', $title); $this->setDialogOption('title', $title);
} }
/** /**
......
...@@ -25,6 +25,7 @@ ...@@ -25,6 +25,7 @@
use Drupal\Core\Ajax\SetDialogTitleCommand; use Drupal\Core\Ajax\SetDialogTitleCommand;
use Drupal\Core\Ajax\RedirectCommand; use Drupal\Core\Ajax\RedirectCommand;
use Drupal\Core\Ajax\UpdateBuildIdCommand; use Drupal\Core\Ajax\UpdateBuildIdCommand;
use Drupal\Core\Ajax\OpenDialogCommand;
/** /**
* Test coverage for various classes in the \Drupal\Core\Ajax namespace. * Test coverage for various classes in the \Drupal\Core\Ajax namespace.
...@@ -293,27 +294,16 @@ public function testSettingsCommand() { ...@@ -293,27 +294,16 @@ public function testSettingsCommand() {
* @covers \Drupal\Core\Ajax\OpenDialogCommand * @covers \Drupal\Core\Ajax\OpenDialogCommand
*/ */
public function testOpenDialogCommand() { public function testOpenDialogCommand() {
$command = $this->getMockBuilder('Drupal\Core\Ajax\OpenDialogCommand') $command = new OpenDialogCommand('#some-dialog', 'Title', '<p>Text!</p>', [
->setConstructorArgs([ 'url' => FALSE,
'#some-dialog', 'Title', '<p>Text!</p>', [ 'width' => 500,
'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');
$expected = [ $expected = [
'command' => 'openDialog', 'command' => 'openDialog',
'selector' => '#some-dialog', 'selector' => '#some-dialog',
'settings' => NULL, 'settings' => NULL,
'data' => 'rendered content', 'data' => '<p>Text!</p>',
'dialogOptions' => [ 'dialogOptions' => [
'url' => FALSE, 'url' => FALSE,
'width' => 500, 'width' => 500,
...@@ -322,6 +312,10 @@ public function testOpenDialogCommand() { ...@@ -322,6 +312,10 @@ public function testOpenDialogCommand() {
], ],
]; ];
$this->assertEquals($expected, $command->render()); $this->assertEquals($expected, $command->render());
$command->setDialogTitle('New title');
$expected['dialogOptions']['title'] = 'New title';
$this->assertEquals($expected, $command->render());
} }
/** /**
......
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