Commit d96ee899 authored by Carsten  Rose's avatar Carsten Rose
Browse files

Fix unit tests: replace uniqid() by uniqIdQfq() which delivers a constant id...

Fix unit tests: replace uniqid() by uniqIdQfq() which delivers a constant id in case of running unit tests
parent 2eef4fe0
Pipeline #1950 passed with stages
in 2 minutes and 50 seconds
...@@ -1496,4 +1496,12 @@ class Support { ...@@ -1496,4 +1496,12 @@ class Support {
return $output; return $output;
} }
/**
* @param string $prefix
* @return string
*/
public static function uniqIdQfq($prefix) {
return $prefix . (defined('PHPUNIT_QFQ')) ? 'badcaffee1234' : uniqid();
}
} }
\ No newline at end of file
...@@ -410,7 +410,7 @@ class Link { ...@@ -410,7 +410,7 @@ class Link {
$menuEntryLinkArr = array(); $menuEntryLinkArr = array();
$tokenCollect = array(); $tokenCollect = array();
$htmlId = uniqid('dd_'); $htmlId = Support::uniqIdQfq('dd_');
$paramArr = KeyValueStringParser::explodeEscape(PARAM_DELIMITER, $str); $paramArr = KeyValueStringParser::explodeEscape(PARAM_DELIMITER, $str);
...@@ -1302,7 +1302,7 @@ class Link { ...@@ -1302,7 +1302,7 @@ class Link {
$arr = OnArray::explodeWithoutEscaped(':', $vars[NAME_QUESTION]); $arr = OnArray::explodeWithoutEscaped(':', $vars[NAME_QUESTION]);
$arr = array_merge($arr, ['', '', '', '', '', '']); $arr = array_merge($arr, ['', '', '', '', '', '']);
$id = ($this->phpUnit === true) ? '12345' : uniqid('a_'); $id = Support::uniqIdQfq('a_');
$content = Support::doAttribute('id', $id); $content = Support::doAttribute('id', $id);
$text = $arr[QUESTION_INDEX_TEXT] === '' ? DEFAULT_QUESTION_TEXT : $arr[QUESTION_INDEX_TEXT]; $text = $arr[QUESTION_INDEX_TEXT] === '' ? DEFAULT_QUESTION_TEXT : $arr[QUESTION_INDEX_TEXT];
......
...@@ -1198,12 +1198,12 @@ class LinkTest extends TestCase { ...@@ -1198,12 +1198,12 @@ class LinkTest extends TestCase {
$link = new Link($this->sip, DB_INDEX_DEFAULT, true); $link = new Link($this->sip, DB_INDEX_DEFAULT, true);
$js = <<<EOF $js = <<<EOF
id="12345" onClick="var alert = new QfqNS.Alert({ message: 'Please confirm', type: 'info', modal: true, timeout: 0, buttons: [ id="badcaffee1234" onClick="var alert = new QfqNS.Alert({ message: 'Please confirm', type: 'info', modal: true, timeout: 0, buttons: [
{ label: 'Ok', eventName: 'ok' } { label: 'Ok', eventName: 'ok' }
, { label: 'Cancel',eventName: 'cancel'} , { label: 'Cancel',eventName: 'cancel'}
] } ); ] } );
alert.on('alert.ok', function() { alert.on('alert.ok', function() {
window.location = $('#12345').attr('href'); window.location = $('#badcaffee1234').attr('href');
}); });
alert.show(); alert.show();
...@@ -1274,12 +1274,12 @@ EOF; ...@@ -1274,12 +1274,12 @@ EOF;
$link = new Link($this->sip, DB_INDEX_DEFAULT, true); $link = new Link($this->sip, DB_INDEX_DEFAULT, true);
$js = <<<EOF $js = <<<EOF
id="12345" onClick="var alert = new QfqNS.Alert({ message: 'Please confirm', type: 'info', modal: true, timeout: 0, buttons: [ id="badcaffee1234" onClick="var alert = new QfqNS.Alert({ message: 'Please confirm', type: 'info', modal: true, timeout: 0, buttons: [
{ label: 'Ok', eventName: 'ok' } { label: 'Ok', eventName: 'ok' }
] } ); ] } );
alert.on('alert.ok', function() { alert.on('alert.ok', function() {
window.location = $('#12345').attr('href'); window.location = $('#badcaffee1234').attr('href');
}); });
alert.show(); alert.show();
...@@ -1467,37 +1467,37 @@ EOF; ...@@ -1467,37 +1467,37 @@ EOF;
$link = new Link($this->sip, DB_INDEX_DEFAULT, true); $link = new Link($this->sip, DB_INDEX_DEFAULT, true);
// Empty definition // Empty definition
$expect = '<span class="dropdown"><span title="Details" data-toggle="dropdown" aria-haspopup="true" aria-expanded="true" class="dropdown-toggle" id="0.123 1234 0" ><span class="glyphicon glyphicon-option-vertical" ></span></span><ul style="max-height: 70vh; overflow-y: auto" class="dropdown-menu" aria-labelledby="0.123 1234 0"></ul></span>'; $expect = '<span class="dropdown"><span title="Details" data-toggle="dropdown" aria-haspopup="true" aria-expanded="true" class="dropdown-toggle" id="badcaffee1234" ><span class="glyphicon glyphicon-option-vertical" ></span></span><ul style="max-height: 70vh; overflow-y: auto" class="dropdown-menu" aria-labelledby="badcaffee1234"></ul></span>';
$result = $link->renderLink('z'); $result = $link->renderLink('z');
$this->assertEquals($expect, $result); $this->assertEquals($expect, $result);
// Empty definition. // Empty definition.
$expect = '<span class="dropdown"><span title="Details" data-toggle="dropdown" aria-haspopup="true" aria-expanded="true" class="dropdown-toggle" id="0.123 1234 1" ><span class="glyphicon glyphicon-option-vertical" ></span></span><ul style="max-height: 70vh; overflow-y: auto" class="dropdown-menu" aria-labelledby="0.123 1234 1"></ul></span>'; $expect = '<span class="dropdown"><span title="Details" data-toggle="dropdown" aria-haspopup="true" aria-expanded="true" class="dropdown-toggle" id="badcaffee1234" ><span class="glyphicon glyphicon-option-vertical" ></span></span><ul style="max-height: 70vh; overflow-y: auto" class="dropdown-menu" aria-labelledby="badcaffee1234"></ul></span>';
$result = $link->renderLink('z:'); $result = $link->renderLink('z:');
$this->assertEquals($expect, $result); $this->assertEquals($expect, $result);
// Dropdown menu with text, custom Glyph and a tooltip. // Dropdown menu with text, custom Glyph and a tooltip.
$expect = '<span class="dropdown"><span title="Open menu" data-toggle="dropdown" aria-haspopup="true" aria-expanded="true" class="dropdown-toggle" id="0.123 1234 2" ><span class="glyphicon glyph-icon-left" ></span> Menu</span><ul style="max-height: 70vh; overflow-y: auto" class="dropdown-menu" aria-labelledby="0.123 1234 2"></ul></span>'; $expect = '<span class="dropdown"><span title="Open menu" data-toggle="dropdown" aria-haspopup="true" aria-expanded="true" class="dropdown-toggle" id="badcaffee1234" ><span class="glyphicon glyph-icon-left" ></span> Menu</span><ul style="max-height: 70vh; overflow-y: auto" class="dropdown-menu" aria-labelledby="badcaffee1234"></ul></span>';
$result = $link->renderLink('z|t:Menu|G:glyph-icon-left|o:Open menu'); $result = $link->renderLink('z|t:Menu|G:glyph-icon-left|o:Open menu');
$this->assertEquals($expect, $result); $this->assertEquals($expect, $result);
// Dropdown menu with menu entry. // Dropdown menu with menu entry.
$expect = '<span class="dropdown"><span title="Open menu" data-toggle="dropdown" aria-haspopup="true" aria-expanded="true" class="dropdown-toggle" id="0.123 1234 3" ><span class="glyphicon glyph-icon-left" ></span> Menu</span><ul style="max-height: 70vh; overflow-y: auto" class="dropdown-menu" aria-labelledby="0.123 1234 3"><li><a href="?id=home" >Home</a></li></ul></span>'; $expect = '<span class="dropdown"><span title="Open menu" data-toggle="dropdown" aria-haspopup="true" aria-expanded="true" class="dropdown-toggle" id="badcaffee1234" ><span class="glyphicon glyph-icon-left" ></span> Menu</span><ul style="max-height: 70vh; overflow-y: auto" class="dropdown-menu" aria-labelledby="badcaffee1234"><li><a href="?id=home" >Home</a></li></ul></span>';
$result = $link->renderLink('z|t:Menu|G:glyph-icon-left|o:Open menu||p:home|t:Home'); $result = $link->renderLink('z|t:Menu|G:glyph-icon-left|o:Open menu||p:home|t:Home');
$this->assertEquals($expect, $result); $this->assertEquals($expect, $result);
// Dropdown menu disabled. // Dropdown menu disabled.
$expect = '<span class="dropdown"><span title="Open menu" data-toggle="dropdown" aria-haspopup="true" aria-expanded="true" class="dropdown-toggle disabled" id="0.123 1234 4" ><span class="glyphicon glyph-icon-left text-muted" ></span> <span class="text-muted">Menu</span></span></span>'; $expect = '<span class="dropdown"><span title="Open menu" data-toggle="dropdown" aria-haspopup="true" aria-expanded="true" class="dropdown-toggle disabled" id="badcaffee1234" ><span class="glyphicon glyph-icon-left text-muted" ></span> <span class="text-muted">Menu</span></span></span>';
$result = $link->renderLink('z|t:Menu|G:glyph-icon-left|o:Open menu|r:3||p:home|t:Home'); $result = $link->renderLink('z|t:Menu|G:glyph-icon-left|o:Open menu|r:3||p:home|t:Home');
$this->assertEquals($expect, $result); $this->assertEquals($expect, $result);
// Dropdown menu with two entries, one is SIP encoded. // Dropdown menu with two entries, one is SIP encoded.
$expect = '<span class="dropdown"><span title="Open menu" data-toggle="dropdown" aria-haspopup="true" aria-expanded="true" class="dropdown-toggle" id="0.123 1234 5" ><span class="glyphicon glyph-icon-left" ></span> Menu</span><ul style="max-height: 70vh; overflow-y: auto" class="dropdown-menu" aria-labelledby="0.123 1234 5"><li><a href="index.php?id=home&s=badcaffee1234" >Home</a></li><li><a href="?id=back" title="Navigate back" >Back</a></li></ul></span>'; $expect = '<span class="dropdown"><span title="Open menu" data-toggle="dropdown" aria-haspopup="true" aria-expanded="true" class="dropdown-toggle" id="badcaffee1234" ><span class="glyphicon glyph-icon-left" ></span> Menu</span><ul style="max-height: 70vh; overflow-y: auto" class="dropdown-menu" aria-labelledby="badcaffee1234"><li><a href="index.php?id=home&s=badcaffee1234" >Home</a></li><li><a href="?id=back" title="Navigate back" >Back</a></li></ul></span>';
$result = $link->renderLink('z|t:Menu|G:glyph-icon-left|o:Open menu||p:home|t:Home|s||p:back|t:Back|o:Navigate back'); $result = $link->renderLink('z|t:Menu|G:glyph-icon-left|o:Open menu||p:home|t:Home|s||p:back|t:Back|o:Navigate back');
$this->assertEquals($expect, $result); $this->assertEquals($expect, $result);
// Dropdown menu header, separator and disabled entry. // Dropdown menu header, separator and disabled entry.
$expect = '<span class="dropdown"><span title="Open menu" data-toggle="dropdown" aria-haspopup="true" aria-expanded="true" class="dropdown-toggle" id="0.123 1234 6" ><span class="glyphicon glyph-icon-left" ></span> Menu</span><ul style="max-height: 70vh; overflow-y: auto" class="dropdown-menu" aria-labelledby="0.123 1234 6"><li><a href="index.php?id=home&s=badcaffee1234" >Home</a></li><li><a href="?id=back" title="Navigate back" >Back</a></li><li role="separator" class="divider"></li><li class="dropdown-header">Header</li><li class="disabled"><a href="#">Disabled entry</a></li></ul></span>'; $expect = '<span class="dropdown"><span title="Open menu" data-toggle="dropdown" aria-haspopup="true" aria-expanded="true" class="dropdown-toggle" id="badcaffee1234" ><span class="glyphicon glyph-icon-left" ></span> Menu</span><ul style="max-height: 70vh; overflow-y: auto" class="dropdown-menu" aria-labelledby="badcaffee1234"><li><a href="index.php?id=home&s=badcaffee1234" >Home</a></li><li><a href="?id=back" title="Navigate back" >Back</a></li><li role="separator" class="divider"></li><li class="dropdown-header">Header</li><li class="disabled"><a href="#">Disabled entry</a></li></ul></span>';
$result = $link->renderLink('z|t:Menu|G:glyph-icon-left|o:Open menu||p:home|t:Home|s||p:back|t:Back|o:Navigate back||r:1|t:---||t:===Header|r:1||r:1|t:---Disabled entry'); $result = $link->renderLink('z|t:Menu|G:glyph-icon-left|o:Open menu||p:home|t:Home|s||p:back|t:Back|o:Navigate back||r:1|t:---||t:===Header|r:1||r:1|t:---Disabled entry');
$this->assertEquals($expect, $result); $this->assertEquals($expect, $result);
} }
......
...@@ -526,12 +526,12 @@ class ReportTest extends AbstractDatabaseTest { ...@@ -526,12 +526,12 @@ class ReportTest extends AbstractDatabaseTest {
*/ */
public function testReportPageTokenQuestion() { public function testReportPageTokenQuestion() {
$js = <<<EOF $js = <<<EOF
id="12345" onClick="var alert = new QfqNS.Alert({ message: 'Please confirm', type: 'info', modal: true, timeout: 0, buttons: [ id="badcaffee1234" onClick="var alert = new QfqNS.Alert({ message: 'Please confirm', type: 'info', modal: true, timeout: 0, buttons: [
{ label: 'Ok', eventName: 'ok' } { label: 'Ok', eventName: 'ok' }
, { label: 'Cancel',eventName: 'cancel'} , { label: 'Cancel',eventName: 'cancel'}
] } ); ] } );
alert.on('alert.ok', function() { alert.on('alert.ok', function() {
window.location = $('#12345').attr('href'); window.location = $('#badcaffee1234').attr('href');
}); });
alert.show(); alert.show();
...@@ -604,12 +604,12 @@ EOF; ...@@ -604,12 +604,12 @@ EOF;
public function testReportPageFix() { public function testReportPageFix() {
$js = <<<EOF $js = <<<EOF
id="12345" onClick="var alert = new QfqNS.Alert({ message: 'Please confirm', type: 'info', modal: true, timeout: 0, buttons: [ id="badcaffee1234" onClick="var alert = new QfqNS.Alert({ message: 'Please confirm', type: 'info', modal: true, timeout: 0, buttons: [
{ label: 'Ok', eventName: 'ok' } { label: 'Ok', eventName: 'ok' }
, { label: 'Cancel',eventName: 'cancel'} , { label: 'Cancel',eventName: 'cancel'}
] } ); ] } );
alert.on('alert.ok', function() { alert.on('alert.ok', function() {
window.location = $('#12345').attr('href'); window.location = $('#badcaffee1234').attr('href');
}); });
alert.show(); alert.show();
...@@ -699,12 +699,12 @@ EOF; ...@@ -699,12 +699,12 @@ EOF;
public function testReportPageC() { public function testReportPageC() {
$js = <<<EOF $js = <<<EOF
id="12345" onClick="var alert = new QfqNS.Alert({ message: 'Please confirm!', type: 'info', modal: true, timeout: 0, buttons: [ id="badcaffee1234" onClick="var alert = new QfqNS.Alert({ message: 'Please confirm!', type: 'info', modal: true, timeout: 0, buttons: [
{ label: 'Ok', eventName: 'ok' } { label: 'Ok', eventName: 'ok' }
, { label: 'Cancel',eventName: 'cancel'} , { label: 'Cancel',eventName: 'cancel'}
] } ); ] } );
alert.on('alert.ok', function() { alert.on('alert.ok', function() {
window.location = $('#12345').attr('href'); window.location = $('#badcaffee1234').attr('href');
}); });
alert.show(); alert.show();
...@@ -744,12 +744,12 @@ EOF; ...@@ -744,12 +744,12 @@ EOF;
public function testReportPageFixC() { public function testReportPageFixC() {
$js = <<<EOF $js = <<<EOF
id="12345" onClick="var alert = new QfqNS.Alert({ message: 'Please confirm!', type: 'info', modal: true, timeout: 0, buttons: [ id="badcaffee1234" onClick="var alert = new QfqNS.Alert({ message: 'Please confirm!', type: 'info', modal: true, timeout: 0, buttons: [
{ label: 'Ok', eventName: 'ok' } { label: 'Ok', eventName: 'ok' }
, { label: 'Cancel',eventName: 'cancel'} , { label: 'Cancel',eventName: 'cancel'}
] } ); ] } );
alert.on('alert.ok', function() { alert.on('alert.ok', function() {
window.location = $('#12345').attr('href'); window.location = $('#badcaffee1234').attr('href');
}); });
alert.show(); alert.show();
...@@ -789,12 +789,12 @@ EOF; ...@@ -789,12 +789,12 @@ EOF;
public function testReportPageD() { public function testReportPageD() {
$js = <<<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: [ id="badcaffee1234" 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: 'Ok', eventName: 'ok' }
, { label: 'Cancel',eventName: 'cancel'} , { label: 'Cancel',eventName: 'cancel'}
] } ); ] } );
alert.on('alert.ok', function() { alert.on('alert.ok', function() {
window.location = $('#12345').attr('href'); window.location = $('#badcaffee1234').attr('href');
}); });
alert.show(); alert.show();
...@@ -842,12 +842,12 @@ EOF; ...@@ -842,12 +842,12 @@ EOF;
public function testReportPageFixD() { public function testReportPageFixD() {
$js = <<<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: [ id="badcaffee1234" 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: 'Ok', eventName: 'ok' }
, { label: 'Cancel',eventName: 'cancel'} , { label: 'Cancel',eventName: 'cancel'}
] } ); ] } );
alert.on('alert.ok', function() { alert.on('alert.ok', function() {
window.location = $('#12345').attr('href'); window.location = $('#badcaffee1234').attr('href');
}); });
alert.show(); alert.show();
......
Supports Markdown
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