public function AjaxCommandsTest::testOpenDialogCommand in Zircon Profile 8
Same name and namespace in other branches
- 8.0 core/tests/Drupal/Tests/Core/Ajax/AjaxCommandsTest.php \Drupal\Tests\Core\Ajax\AjaxCommandsTest::testOpenDialogCommand()
@covers \Drupal\Core\Ajax\OpenDialogCommand
File
- core/
tests/ Drupal/ Tests/ Core/ Ajax/ AjaxCommandsTest.php, line 299 - Contains \Drupal\Tests\Core\Ajax\AjaxCommandsTest.
Class
- AjaxCommandsTest
- Test coverage for various classes in the \Drupal\Core\Ajax namespace.
Namespace
Drupal\Tests\Core\AjaxCode
public function testOpenDialogCommand() {
$command = $this
->getMockBuilder('Drupal\\Core\\Ajax\\OpenDialogCommand')
->setConstructorArgs(array(
'#some-dialog',
'Title',
'<p>Text!</p>',
array(
'url' => FALSE,
'width' => 500,
),
))
->setMethods(array(
'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 = array(
'command' => 'openDialog',
'selector' => '#some-dialog',
'settings' => NULL,
'data' => 'rendered content',
'dialogOptions' => array(
'url' => FALSE,
'width' => 500,
'title' => 'Title',
'modal' => FALSE,
),
);
$this
->assertEquals($expected, $command
->render());
}