Commit 72f9e06e authored by Carsten  Rose's avatar Carsten Rose
Browse files

Fix and extend PHP Unit Tests

parent 0a7e2917
Pipeline #800 passed with stage
in 1 minute and 49 seconds
...@@ -107,6 +107,7 @@ const NAME_MONITOR = 'monitor'; ...@@ -107,6 +107,7 @@ const NAME_MONITOR = 'monitor';
const FINAL_HREF = 'finalHref'; const FINAL_HREF = 'finalHref';
const FINAL_ANCHOR = 'finalAnchor'; const FINAL_ANCHOR = 'finalAnchor';
const FINAL_CONTENT = 'finalContent'; const FINAL_CONTENT = 'finalContent';
const FINAL_CONTENT_PURE = 'finalContentPure';
const FINAL_SYMBOL = 'finalSymbol'; const FINAL_SYMBOL = 'finalSymbol';
const FINAL_TOOL_TIP = 'finalToolTip'; const FINAL_TOOL_TIP = 'finalToolTip';
const FINAL_CLASS = 'finalClass'; const FINAL_CLASS = 'finalClass';
...@@ -335,7 +336,6 @@ class Link { ...@@ -335,7 +336,6 @@ class Link {
$this->renderControl[8][0][1] = 0; $this->renderControl[8][0][1] = 0;
$this->renderControl[8][1][0] = 8; $this->renderControl[8][1][0] = 8;
$this->renderControl[8][1][1] = 8; $this->renderControl[8][1][1] = 8;
} }
/** /**
...@@ -587,12 +587,12 @@ class Link { ...@@ -587,12 +587,12 @@ class Link {
} }
// Download Link needs some extra work // Download Link needs some extra work
if ($rcTokenGiven[TOKEN_DOWNLOAD]) { if (isset($rcTokenGiven[TOKEN_DOWNLOAD]) && $rcTokenGiven[TOKEN_DOWNLOAD]) {
$vars = $this->buildDownloadLate($vars); $vars = $this->buildDownloadLate($vars);
} }
// CopyToClipboard (Download) Link needs some extra work // CopyToClipboard (Download) Link needs some extra work
if ($rcTokenGiven[TOKEN_COPY_TO_CLIPBOARD]) { if (isset($rcTokenGiven[TOKEN_COPY_TO_CLIPBOARD]) && $rcTokenGiven[TOKEN_COPY_TO_CLIPBOARD]) {
$vars = $this->buildCopyToClipboardLate($vars); $vars = $this->buildCopyToClipboardLate($vars);
} }
...@@ -763,7 +763,7 @@ class Link { ...@@ -763,7 +763,7 @@ class Link {
$vars[FINAL_CLASS] = $this->doCssClass($vars); $vars[FINAL_CLASS] = $this->doCssClass($vars);
$vars[FINAL_SYMBOL] = $this->doSymbol($vars); $vars[FINAL_SYMBOL] = $this->doSymbol($vars);
$vars[FINAL_THUMBNAIL] = $this->doThumbnail($vars); $vars[FINAL_THUMBNAIL] = $this->doThumbnail($vars);
$vars[FINAL_CONTENT] = $this->doContent($vars); // must be called after doSymbol() $vars[FINAL_CONTENT] = $this->doContent($vars, $vars[FINAL_CONTENT_PURE]); // must be called after doSymbol()
$vars[FINAL_QUESTION] = $this->doQuestion($vars); $vars[FINAL_QUESTION] = $this->doQuestion($vars);
$vars[FINAL_ANCHOR] = $this->doAnchor($vars); $vars[FINAL_ANCHOR] = $this->doAnchor($vars);
...@@ -1030,7 +1030,7 @@ class Link { ...@@ -1030,7 +1030,7 @@ class Link {
* @throws UserFormException * @throws UserFormException
* @throws UserReportException * @throws UserReportException
*/ */
private function doContent(array $vars) { private function doContent(array $vars, &$contentPure) {
$arr = array(); $arr = array();
if ($vars[NAME_MONITOR] == '1') { if ($vars[NAME_MONITOR] == '1') {
...@@ -1044,13 +1044,9 @@ class Link { ...@@ -1044,13 +1044,9 @@ class Link {
$arr[] = $vars[$key]; $arr[] = $vars[$key];
} }
} }
$content = implode(' ', $arr);
if ($vars[NAME_EXTRA_CONTENT_WRAP] != '') {
$content = Support::wrapTag($vars[NAME_EXTRA_CONTENT_WRAP], $content);
}
return $content; $contentPure = implode(' ', $arr);
return Support::wrapTag($vars[NAME_EXTRA_CONTENT_WRAP], $contentPure);
} }
/** /**
...@@ -1168,7 +1164,7 @@ EOF; ...@@ -1168,7 +1164,7 @@ EOF;
*/ */
private function getModeRender(array $vars, array $tokenGiven) { private function getModeRender(array $vars, array $tokenGiven) {
if ($tokenGiven[TOKEN_COPY_TO_CLIPBOARD]) { if (isset($tokenGiven[TOKEN_COPY_TO_CLIPBOARD]) && $tokenGiven[TOKEN_COPY_TO_CLIPBOARD]) {
if ($vars[NAME_RENDER] == '0') { if ($vars[NAME_RENDER] == '0') {
$vars[NAME_RENDER] = RENDER_MODE_1; $vars[NAME_RENDER] = RENDER_MODE_1;
} }
......
...@@ -36,6 +36,10 @@ class LinkTest extends TestCase { ...@@ -36,6 +36,10 @@ class LinkTest extends TestCase {
/** /**
* @expectedException \qfq\UserReportException * @expectedException \qfq\UserReportException
*
* @throws CodeException
* @throws UserFormException
* @throws UserReportException
*/ */
public function testUnknownTokenException1() { public function testUnknownTokenException1() {
$link = new Link($this->sip, DB_INDEX_DEFAULT, true); $link = new Link($this->sip, DB_INDEX_DEFAULT, true);
...@@ -45,6 +49,10 @@ class LinkTest extends TestCase { ...@@ -45,6 +49,10 @@ class LinkTest extends TestCase {
/** /**
* @expectedException \qfq\UserReportException * @expectedException \qfq\UserReportException
*
* @throws CodeException
* @throws UserFormException
* @throws UserReportException
*/ */
public function testUnknownTokenException2() { public function testUnknownTokenException2() {
$link = new Link($this->sip, DB_INDEX_DEFAULT, true); $link = new Link($this->sip, DB_INDEX_DEFAULT, true);
...@@ -53,6 +61,9 @@ class LinkTest extends TestCase { ...@@ -53,6 +61,9 @@ class LinkTest extends TestCase {
} }
/** /**
* @throws CodeException
* @throws UserFormException
* @throws UserReportException
*/ */
public function testLinkUrlBasic() { public function testLinkUrlBasic() {
$link = new Link($this->sip, DB_INDEX_DEFAULT, true); $link = new Link($this->sip, DB_INDEX_DEFAULT, true);
...@@ -81,6 +92,9 @@ class LinkTest extends TestCase { ...@@ -81,6 +92,9 @@ class LinkTest extends TestCase {
/** /**
* @expectedException \qfq\UserReportException * @expectedException \qfq\UserReportException
* *
* @throws CodeException
* @throws UserFormException
* @throws UserReportException
*/ */
public function testLinkUrlBasicExceptionDouble() { public function testLinkUrlBasicExceptionDouble() {
$link = new Link($this->sip, DB_INDEX_DEFAULT, true); $link = new Link($this->sip, DB_INDEX_DEFAULT, true);
...@@ -89,26 +103,9 @@ class LinkTest extends TestCase { ...@@ -89,26 +103,9 @@ class LinkTest extends TestCase {
} }
/** /**
* @expectedException \qfq\UserReportException * @throws CodeException
* * @throws UserFormException
*/ * @throws UserReportException
public function testLinkUrlBasicExceptionEmpty1() {
$link = new Link($this->sip, DB_INDEX_DEFAULT, true);
$link->renderLink('u');
}
/**
* @expectedException \qfq\UserReportException
*
*/
public function testLinkUrlBasicExceptionEmpty2() {
$link = new Link($this->sip, DB_INDEX_DEFAULT, true);
$link->renderLink('u:');
}
/**
*/ */
public function testLinkPageBasic() { public function testLinkPageBasic() {
$link = new Link($this->sip, DB_INDEX_DEFAULT, true); $link = new Link($this->sip, DB_INDEX_DEFAULT, true);
...@@ -134,6 +131,9 @@ class LinkTest extends TestCase { ...@@ -134,6 +131,9 @@ class LinkTest extends TestCase {
} }
/** /**
* @throws CodeException
* @throws UserFormException
* @throws UserReportException
*/ */
public function testLinkMailBasic() { public function testLinkMailBasic() {
$link = new Link($this->sip, DB_INDEX_DEFAULT, true); $link = new Link($this->sip, DB_INDEX_DEFAULT, true);
...@@ -145,27 +145,11 @@ class LinkTest extends TestCase { ...@@ -145,27 +145,11 @@ class LinkTest extends TestCase {
$this->assertEquals('<a href="mailto:john@doe.com" >John Doe</a>', $result); $this->assertEquals('<a href="mailto:john@doe.com" >John Doe</a>', $result);
} }
/**
* @expectedException \qfq\UserReportException
*
*/
public function testLinkMailBasicExceptionMissing1() {
$link = new Link($this->sip, DB_INDEX_DEFAULT, true);
$link->renderLink('m');
}
/**
* @expectedException \qfq\UserReportException
*
*/
public function testLinkMailBasicExceptionMissing2() {
$link = new Link($this->sip, DB_INDEX_DEFAULT, true);
$link->renderLink('m:');
}
/** /**
* @throws CodeException
* @throws UserFormException
* @throws UserReportException
*/ */
public function testMailEncryption() { public function testMailEncryption() {
$link = new Link($this->sip, DB_INDEX_DEFAULT, true); $link = new Link($this->sip, DB_INDEX_DEFAULT, true);
...@@ -398,6 +382,10 @@ class LinkTest extends TestCase { ...@@ -398,6 +382,10 @@ class LinkTest extends TestCase {
} }
/** /**
* @throws UserReportException
*
* @throws CodeException
* @throws UserFormException
* @throws UserReportException * @throws UserReportException
*/ */
public function testRenderModeMail() { public function testRenderModeMail() {
...@@ -482,6 +470,10 @@ class LinkTest extends TestCase { ...@@ -482,6 +470,10 @@ class LinkTest extends TestCase {
} }
/** /**
* @throws UserReportException
*
* @throws CodeException
* @throws UserFormException
* @throws UserReportException * @throws UserReportException
*/ */
public function testRenderModeUrlPicture() { public function testRenderModeUrlPicture() {
...@@ -567,6 +559,10 @@ class LinkTest extends TestCase { ...@@ -567,6 +559,10 @@ class LinkTest extends TestCase {
} }
/** /**
* @throws UserReportException
*
* @throws CodeException
* @throws UserFormException
* @throws UserReportException * @throws UserReportException
*/ */
public function testRenderModeUrlButton() { public function testRenderModeUrlButton() {
...@@ -650,6 +646,10 @@ class LinkTest extends TestCase { ...@@ -650,6 +646,10 @@ class LinkTest extends TestCase {
} }
/** /**
* @throws UserReportException
*
* @throws CodeException
* @throws UserFormException
* @throws UserReportException * @throws UserReportException
*/ */
public function testIcons() { public function testIcons() {
...@@ -678,6 +678,10 @@ class LinkTest extends TestCase { ...@@ -678,6 +678,10 @@ class LinkTest extends TestCase {
} }
/** /**
* @throws UserReportException
*
* @throws CodeException
* @throws UserFormException
* @throws UserReportException * @throws UserReportException
*/ */
public function testBullet() { public function testBullet() {
...@@ -709,6 +713,8 @@ class LinkTest extends TestCase { ...@@ -709,6 +713,8 @@ class LinkTest extends TestCase {
} }
/** /**
* @throws CodeException
* @throws UserFormException
* @throws UserReportException * @throws UserReportException
*/ */
public function testChecked() { public function testChecked() {
...@@ -740,6 +746,8 @@ class LinkTest extends TestCase { ...@@ -740,6 +746,8 @@ class LinkTest extends TestCase {
} }
/** /**
* @throws CodeException
* @throws UserFormException
* @throws UserReportException * @throws UserReportException
*/ */
public function testGlyph() { public function testGlyph() {
...@@ -751,6 +759,10 @@ class LinkTest extends TestCase { ...@@ -751,6 +759,10 @@ class LinkTest extends TestCase {
/** /**
* @expectedException \qfq\UserReportException * @expectedException \qfq\UserReportException
*
* @throws CodeException
* @throws UserFormException
* @throws UserReportException
*/ */
public function testGlyphException() { public function testGlyphException() {
$link = new Link($this->sip, DB_INDEX_DEFAULT, true); $link = new Link($this->sip, DB_INDEX_DEFAULT, true);
...@@ -761,6 +773,10 @@ class LinkTest extends TestCase { ...@@ -761,6 +773,10 @@ class LinkTest extends TestCase {
/** /**
* @expectedException \qfq\UserReportException * @expectedException \qfq\UserReportException
*
* @throws CodeException
* @throws UserFormException
* @throws UserReportException
*/ */
public function testPictureException1() { public function testPictureException1() {
$link = new Link($this->sip, DB_INDEX_DEFAULT, true); $link = new Link($this->sip, DB_INDEX_DEFAULT, true);
...@@ -771,6 +787,10 @@ class LinkTest extends TestCase { ...@@ -771,6 +787,10 @@ class LinkTest extends TestCase {
/** /**
* @expectedException \qfq\UserReportException * @expectedException \qfq\UserReportException
*
* @throws CodeException
* @throws UserFormException
* @throws UserReportException
*/ */
public function testPictureException2() { public function testPictureException2() {
$link = new Link($this->sip, DB_INDEX_DEFAULT, true); $link = new Link($this->sip, DB_INDEX_DEFAULT, true);
...@@ -781,6 +801,10 @@ class LinkTest extends TestCase { ...@@ -781,6 +801,10 @@ class LinkTest extends TestCase {
/** /**
* @expectedException \qfq\UserReportException * @expectedException \qfq\UserReportException
*
* @throws CodeException
* @throws UserFormException
* @throws UserReportException
*/ */
public function testPictureException3() { public function testPictureException3() {
$link = new Link($this->sip, DB_INDEX_DEFAULT, true); $link = new Link($this->sip, DB_INDEX_DEFAULT, true);
...@@ -791,6 +815,10 @@ class LinkTest extends TestCase { ...@@ -791,6 +815,10 @@ class LinkTest extends TestCase {
/** /**
* @expectedException \qfq\UserReportException * @expectedException \qfq\UserReportException
*
* @throws CodeException
* @throws UserFormException
* @throws UserReportException
*/ */
public function testPictureException4() { public function testPictureException4() {
$link = new Link($this->sip, DB_INDEX_DEFAULT, true); $link = new Link($this->sip, DB_INDEX_DEFAULT, true);
...@@ -801,6 +829,10 @@ class LinkTest extends TestCase { ...@@ -801,6 +829,10 @@ class LinkTest extends TestCase {
/** /**
* @expectedException \qfq\UserReportException * @expectedException \qfq\UserReportException
*
* @throws CodeException
* @throws UserFormException
* @throws UserReportException
*/ */
public function testGlyphExceptionDouble1() { public function testGlyphExceptionDouble1() {
$link = new Link($this->sip, DB_INDEX_DEFAULT, true); $link = new Link($this->sip, DB_INDEX_DEFAULT, true);
...@@ -811,6 +843,10 @@ class LinkTest extends TestCase { ...@@ -811,6 +843,10 @@ class LinkTest extends TestCase {
/** /**
* @expectedException \qfq\UserReportException * @expectedException \qfq\UserReportException
*
* @throws CodeException
* @throws UserFormException
* @throws UserReportException
*/ */
public function testGlyphExceptionDouble2() { public function testGlyphExceptionDouble2() {
$link = new Link($this->sip, DB_INDEX_DEFAULT, true); $link = new Link($this->sip, DB_INDEX_DEFAULT, true);
...@@ -821,6 +857,10 @@ class LinkTest extends TestCase { ...@@ -821,6 +857,10 @@ class LinkTest extends TestCase {
/** /**
* @expectedException \qfq\UserReportException * @expectedException \qfq\UserReportException
*
* @throws CodeException
* @throws UserFormException
* @throws UserReportException
*/ */
public function testGlyphExceptionDouble3() { public function testGlyphExceptionDouble3() {
$link = new Link($this->sip, DB_INDEX_DEFAULT, true); $link = new Link($this->sip, DB_INDEX_DEFAULT, true);
...@@ -831,6 +871,10 @@ class LinkTest extends TestCase { ...@@ -831,6 +871,10 @@ class LinkTest extends TestCase {
/** /**
* @expectedException \qfq\UserReportException * @expectedException \qfq\UserReportException
*
* @throws CodeException
* @throws UserFormException
* @throws UserReportException
*/ */
public function testGlyphExceptionDouble4() { public function testGlyphExceptionDouble4() {
$link = new Link($this->sip, DB_INDEX_DEFAULT, true); $link = new Link($this->sip, DB_INDEX_DEFAULT, true);
...@@ -841,6 +885,10 @@ class LinkTest extends TestCase { ...@@ -841,6 +885,10 @@ class LinkTest extends TestCase {
/** /**
* @expectedException \qfq\UserReportException * @expectedException \qfq\UserReportException
*
* @throws CodeException
* @throws UserFormException
* @throws UserReportException
*/ */
public function testGlyphExceptionDouble5() { public function testGlyphExceptionDouble5() {
$link = new Link($this->sip, DB_INDEX_DEFAULT, true); $link = new Link($this->sip, DB_INDEX_DEFAULT, true);
...@@ -851,6 +899,10 @@ class LinkTest extends TestCase { ...@@ -851,6 +899,10 @@ class LinkTest extends TestCase {
/** /**
* @expectedException \qfq\UserReportException * @expectedException \qfq\UserReportException
*
* @throws CodeException
* @throws UserFormException
* @throws UserReportException
*/ */
public function testGlyphExceptionDouble6() { public function testGlyphExceptionDouble6() {
$link = new Link($this->sip, DB_INDEX_DEFAULT, true); $link = new Link($this->sip, DB_INDEX_DEFAULT, true);
...@@ -860,6 +912,9 @@ class LinkTest extends TestCase { ...@@ -860,6 +912,9 @@ class LinkTest extends TestCase {
} }
/** /**
* @throws CodeException
* @throws UserFormException
* @throws UserReportException
*/ */
public function testLinkUrlParam() { public function testLinkUrlParam() {
$link = new Link($this->sip, DB_INDEX_DEFAULT, true); $link = new Link($this->sip, DB_INDEX_DEFAULT, true);
...@@ -902,6 +957,10 @@ class LinkTest extends TestCase { ...@@ -902,6 +957,10 @@ class LinkTest extends TestCase {
} }
/** /**
*
* @throws CodeException
* @throws UserFormException
* @throws UserReportException
*/ */
public function testTooltip() { public function testTooltip() {
$link = new Link($this->sip, DB_INDEX_DEFAULT, true); $link = new Link($this->sip, DB_INDEX_DEFAULT, true);
...@@ -932,6 +991,10 @@ class LinkTest extends TestCase { ...@@ -932,6 +991,10 @@ class LinkTest extends TestCase {
} }
/** /**
*
* @throws CodeException
* @throws UserFormException
* @throws UserReportException
*/ */
public function testAltText() { public function testAltText() {
$link = new Link($this->sip, DB_INDEX_DEFAULT, true); $link = new Link($this->sip, DB_INDEX_DEFAULT, true);
...@@ -952,6 +1015,10 @@ class LinkTest extends TestCase { ...@@ -952,6 +1015,10 @@ class LinkTest extends TestCase {
} }
/** /**
*
* @throws CodeException
* @throws UserFormException
* @throws UserReportException
*/ */
public function testClass() { public function testClass() {
$link = new Link($this->sip, DB_INDEX_DEFAULT, true); $link = new Link($this->sip, DB_INDEX_DEFAULT, true);
...@@ -978,6 +1045,10 @@ class LinkTest extends TestCase { ...@@ -978,6 +1045,10 @@ class LinkTest extends TestCase {
} }
/** /**
*
* @throws CodeException
* @throws UserFormException
* @throws UserReportException
*/ */
public function testTarget() { public function testTarget() {
$link = new Link($this->sip, DB_INDEX_DEFAULT, true); $link = new Link($this->sip, DB_INDEX_DEFAULT, true);
...@@ -1004,6 +1075,10 @@ class LinkTest extends TestCase { ...@@ -1004,6 +1075,10 @@ class LinkTest extends TestCase {
} }
/** /**
*
* @throws CodeException
* @throws UserFormException
* @throws UserReportException
*/ */
public function testRight() { public function testRight() {
$link = new Link($this->sip, DB_INDEX_DEFAULT, true); $link = new Link($this->sip, DB_INDEX_DEFAULT, true);
...@@ -1039,6 +1114,10 @@ class LinkTest extends TestCase { ...@@ -1039,6 +1114,10 @@ class LinkTest extends TestCase {
/** /**
*
* @throws CodeException
* @throws UserFormException
<