From 84ecb3cf16df3b28c37a0e0489f753863fd70d7f Mon Sep 17 00:00:00 2001 From: Carsten Rose <carsten.rose@math.uzh.ch> Date: Sun, 20 Jan 2019 13:22:01 +0100 Subject: [PATCH] Fix and add unit test --- .../Source/core/helper/HelperFormElement.php | 3 ++ .../Tests/unit/core/BuildFormPlainTest.php | 1 + extension/Tests/unit/core/report/LinkTest.php | 32 +++++++++++++++++-- .../Tests/unit/core/report/ReportTest.php | 24 +++++++------- 4 files changed, 46 insertions(+), 14 deletions(-) diff --git a/extension/Source/core/helper/HelperFormElement.php b/extension/Source/core/helper/HelperFormElement.php index bee39c15e..c0da9d892 100644 --- a/extension/Source/core/helper/HelperFormElement.php +++ b/extension/Source/core/helper/HelperFormElement.php @@ -35,6 +35,7 @@ class HelperFormElement { * @throws UserReportException */ public static function explodeParameterInArrayElements(array &$elements, $keyName) { + foreach ($elements AS $key => $element) { self::explodeParameter($element, $keyName); $elements[$key] = $element; @@ -50,6 +51,7 @@ class HelperFormElement { public static function formElementSetDefault(array $elements) { foreach ($elements AS $key => $element) { $elements[$key][FE_TG_INDEX] = 0; +// $elements[$key][FE_DATA_REFERENCE] = ''; } return $elements; @@ -67,6 +69,7 @@ class HelperFormElement { * @throws UserReportException */ public static function explodeParameter(array &$element, $keyName, $flagAllowOverwrite = false) { + // Something to explode? if (isset($element[$keyName]) && $element[$keyName] !== '') { // Explode diff --git a/extension/Tests/unit/core/BuildFormPlainTest.php b/extension/Tests/unit/core/BuildFormPlainTest.php index fe311f62a..7afd14c18 100644 --- a/extension/Tests/unit/core/BuildFormPlainTest.php +++ b/extension/Tests/unit/core/BuildFormPlainTest.php @@ -533,6 +533,7 @@ class BuildFormPlainTest extends AbstractDatabaseTest { FE_CHECK_PATTERN => '', FE_HTML_ID => '123', FE_HIDE_ZERO => '0', + FE_DATA_REFERENCE => '', 'tabindex' => 0, ]; diff --git a/extension/Tests/unit/core/report/LinkTest.php b/extension/Tests/unit/core/report/LinkTest.php index b1e781d5c..7fa44b249 100644 --- a/extension/Tests/unit/core/report/LinkTest.php +++ b/extension/Tests/unit/core/report/LinkTest.php @@ -1199,8 +1199,8 @@ class LinkTest extends TestCase { $js = <<<EOF id="12345" onClick="var alert = new QfqNS.Alert({ message: 'Please confirm', type: 'info', modal: true, timeout: 0, buttons: [ - { label: 'Ok', eventName: 'ok' }, - { label: 'Cancel',eventName: 'cancel'} + { label: 'Ok', eventName: 'ok' } + , { label: 'Cancel',eventName: 'cancel'} ] } ); alert.on('alert.ok', function() { window.location = $('#12345').attr('href'); @@ -1264,6 +1264,34 @@ EOF; } + /** + * + * @throws CodeException + * @throws UserFormException + * @throws UserReportException + */ + public function testQuestion2() { + $link = new Link($this->sip, DB_INDEX_DEFAULT, true); + + $js = <<<EOF +id="12345" onClick="var alert = new QfqNS.Alert({ message: 'Please confirm', type: 'info', modal: true, timeout: 0, buttons: [ + { label: 'Ok', eventName: 'ok' } + +] } ); +alert.on('alert.ok', function() { + window.location = $('#12345').attr('href'); +}); + +alert.show(); +return false;" +EOF; + + // Question: Hide 'cancel' Button + $result = $link->renderLink('p:person|c:n|q::::-'); + $this->assertEquals('<a href="?id=person" ' . $js . ' >?id=person</a>', $result); + + } + /** * @throws CodeException * @throws UserFormException diff --git a/extension/Tests/unit/core/report/ReportTest.php b/extension/Tests/unit/core/report/ReportTest.php index 0000b60d8..aa61cd52f 100644 --- a/extension/Tests/unit/core/report/ReportTest.php +++ b/extension/Tests/unit/core/report/ReportTest.php @@ -527,8 +527,8 @@ class ReportTest extends AbstractDatabaseTest { public function testReportPageTokenQuestion() { $js = <<<EOF id="12345" onClick="var alert = new QfqNS.Alert({ message: 'Please confirm', type: 'info', modal: true, timeout: 0, buttons: [ - { label: 'Ok', eventName: 'ok' }, - { label: 'Cancel',eventName: 'cancel'} + { label: 'Ok', eventName: 'ok' } + , { label: 'Cancel',eventName: 'cancel'} ] } ); alert.on('alert.ok', function() { window.location = $('#12345').attr('href'); @@ -605,8 +605,8 @@ EOF; $js = <<<EOF id="12345" onClick="var alert = new QfqNS.Alert({ message: 'Please confirm', type: 'info', modal: true, timeout: 0, buttons: [ - { label: 'Ok', eventName: 'ok' }, - { label: 'Cancel',eventName: 'cancel'} + { label: 'Ok', eventName: 'ok' } + , { label: 'Cancel',eventName: 'cancel'} ] } ); alert.on('alert.ok', function() { window.location = $('#12345').attr('href'); @@ -700,8 +700,8 @@ EOF; $js = <<<EOF id="12345" onClick="var alert = new QfqNS.Alert({ message: 'Please confirm!', type: 'info', modal: true, timeout: 0, buttons: [ - { label: 'Ok', eventName: 'ok' }, - { label: 'Cancel',eventName: 'cancel'} + { label: 'Ok', eventName: 'ok' } + , { label: 'Cancel',eventName: 'cancel'} ] } ); alert.on('alert.ok', function() { window.location = $('#12345').attr('href'); @@ -745,8 +745,8 @@ EOF; $js = <<<EOF id="12345" onClick="var alert = new QfqNS.Alert({ message: 'Please confirm!', type: 'info', modal: true, timeout: 0, buttons: [ - { label: 'Ok', eventName: 'ok' }, - { label: 'Cancel',eventName: 'cancel'} + { label: 'Ok', eventName: 'ok' } + , { label: 'Cancel',eventName: 'cancel'} ] } ); alert.on('alert.ok', function() { window.location = $('#12345').attr('href'); @@ -790,8 +790,8 @@ EOF; $js = <<<EOF id="12345" onClick="var alert = new QfqNS.Alert({ message: 'Do you really want to delete the record?', type: 'warning', modal: true, timeout: 0, buttons: [ - { label: 'Ok', eventName: 'ok' }, - { label: 'Cancel',eventName: 'cancel'} + { label: 'Ok', eventName: 'ok' } + , { label: 'Cancel',eventName: 'cancel'} ] } ); alert.on('alert.ok', function() { window.location = $('#12345').attr('href'); @@ -843,8 +843,8 @@ EOF; $js = <<<EOF id="12345" onClick="var alert = new QfqNS.Alert({ message: 'Do you really want to delete the record?', type: 'warning', modal: true, timeout: 0, buttons: [ - { label: 'Ok', eventName: 'ok' }, - { label: 'Cancel',eventName: 'cancel'} + { label: 'Ok', eventName: 'ok' } + , { label: 'Cancel',eventName: 'cancel'} ] } ); alert.on('alert.ok', function() { window.location = $('#12345').attr('href'); -- GitLab