Commit 4b69ce86 authored by webchick's avatar webchick

Issue #2250165 by neclimdul, cs_shadow, YesCT: Replace fake mocks with actual...

Issue #2250165 by neclimdul, cs_shadow, YesCT: Replace fake mocks with actual OpenDialogCommand stubs in AjaxCommandsTest
parent 2ec3fbcb
......@@ -24,8 +24,6 @@
use Drupal\Core\Ajax\ReplaceCommand;
use Drupal\Core\Ajax\RestripeCommand;
use Drupal\Core\Ajax\SettingsCommand;
use Drupal\Core\Ajax\OpenDialogCommand;
use Drupal\Core\Ajax\OpenModalDialogCommand;
use Drupal\Core\Ajax\CloseDialogCommand;
use Drupal\Core\Ajax\CloseModalDialogCommand;
use Drupal\Core\Ajax\SetDialogOptionCommand;
......@@ -299,10 +297,17 @@ public function testSettingsCommand() {
* Tests that OpenDialogCommand objects can be constructed and rendered.
*/
public function testOpenDialogCommand() {
$command = new TestOpenDialogCommand('#some-dialog', 'Title', '<p>Text!</p>', array(
'url' => FALSE,
'width' => 500,
));
$command = $this->getMockBuilder('Drupal\Core\Ajax\OpenDialogCommand')
->setConstructorArgs(array(
'#some-dialog', 'Title', '<p>Text!</p>', array(
'url' => FALSE,
'width' => 500,
)
))
// This method calls drupal_render which isn't available. We want it to do
// nothing so we mock it to return null.
->setMethods(array('drupalAttachLibrary'))
->getMock();
$expected = array(
'command' => 'openDialog',
......@@ -323,10 +328,17 @@ public function testOpenDialogCommand() {
* Tests that OpenModalDialogCommand objects can be constructed and rendered.
*/
public function testOpenModalDialogCommand() {
$command = new TestOpenModalDialogCommand('Title', '<p>Text!</p>', array(
'url' => 'example',
'width' => 500,
));
$command = $this->getMockBuilder('Drupal\Core\Ajax\OpenModalDialogCommand')
->setConstructorArgs(array(
'Title', '<p>Text!</p>', array(
'url' => 'example',
'width' => 500,
)
))
// This method calls drupal_render which isn't available. We want it to do
// nothing so we mock it to return null.
->setMethods(array('drupalAttachLibrary'))
->getMock();
$expected = array(
'command' => 'openDialog',
......@@ -415,27 +427,3 @@ public function testRedirectCommand() {
}
}
/**
* Wraps OpenModalDialogCommand::drupalAttachLibrary().
*
* {@inheritdoc}
*/
class TestOpenModalDialogCommand extends OpenModalDialogCommand {
protected function drupalAttachLibrary($name) {
}
}
/**
* Wraps OpenDialogCommand::drupalAttachLibrary().
*
* {@inheritdoc}
*/
class TestOpenDialogCommand extends OpenDialogCommand {
protected function drupalAttachLibrary($name) {
}
}
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