View source
<?php
namespace Drupal\Tests\webform\Kernel\Utility;
use Drupal\KernelTests\KernelTestBase;
use Drupal\webform\Utility\WebformDialogHelper;
class WebformDialogHelperTest extends KernelTestBase {
public static $modules = [
'system',
'user',
'webform',
];
public function testGetModalDialogAttributes() {
$this
->config('webform.settings')
->set('ui.dialog_disabled', FALSE)
->save();
$this
->assertEquals(WebformDialogHelper::getModalDialogAttributes(), [
'class' => [
'webform-ajax-link',
],
'data-dialog-type' => 'modal',
'data-dialog-options' => '{"width":800,"dialogClass":"webform-ui-dialog"}',
]);
$this
->assertEquals(WebformDialogHelper::getModalDialogAttributes(400, [
'custom',
]), [
'class' => [
'custom',
'webform-ajax-link',
],
'data-dialog-type' => 'modal',
'data-dialog-options' => '{"width":400,"dialogClass":"webform-ui-dialog"}',
]);
$this
->config('webform.settings')
->set('ui.dialog_disabled', TRUE)
->save();
$this
->assertEquals(WebformDialogHelper::getModalDialogAttributes(), []);
$this
->assertEquals(WebformDialogHelper::getModalDialogAttributes(400, [
'custom',
]), [
'class' => [
'custom',
],
]);
}
}