From 2a530c90d44c7d9b718b9c6bfd45e93b1b2a5a76 Mon Sep 17 00:00:00 2001 From: Carsten Rose <carsten.rose@math.uzh.ch> Date: Sat, 28 Jan 2017 21:06:39 +0100 Subject: [PATCH] ReportTest.php: added check for paged / modeAnswer / targetUrl --- extension/qfq/tests/phpunit/LinkTest.php | 1 - extension/qfq/tests/phpunit/ReportTest.php | 10 +++++++--- extension/qfq/tests/phpunit/SipTest.php | 16 ++++++++++++++++ 3 files changed, 23 insertions(+), 4 deletions(-) diff --git a/extension/qfq/tests/phpunit/LinkTest.php b/extension/qfq/tests/phpunit/LinkTest.php index 0382d149e..e5557518a 100644 --- a/extension/qfq/tests/phpunit/LinkTest.php +++ b/extension/qfq/tests/phpunit/LinkTest.php @@ -997,7 +997,6 @@ EOF; } - /** * */ diff --git a/extension/qfq/tests/phpunit/ReportTest.php b/extension/qfq/tests/phpunit/ReportTest.php index bcb0204d8..4010ed85b 100644 --- a/extension/qfq/tests/phpunit/ReportTest.php +++ b/extension/qfq/tests/phpunit/ReportTest.php @@ -8,6 +8,7 @@ require_once(__DIR__ . '/AbstractDatabaseTest.php'); require_once(__DIR__ . '/../../qfq/report/Report.php'); require_once(__DIR__ . '/../../qfq/store/Store.php'); require_once(__DIR__ . '/../../qfq/Evaluate.php'); +require_once(__DIR__ . '/../../qfq/store/Session.php'); /** * Created by PhpStorm. @@ -667,6 +668,10 @@ EOF; $result = $this->report->process("10.sql = SELECT 'U:table=Person&r=123' AS _paged FROM Person ORDER BY id LIMIT 1"); $this->assertEquals('<a href="' . API_DIR . '/' . API_DELETE_PHP . '?s=badcaffee1234" class="btn btn-default" title="Delete" ' . $js . ' ><span class="glyphicon glyphicon-trash" ></span></a>', $result); + // Check das via '_paged' SIP_MODE_ANSWER and SIP_TARGET_URL has been set. + $result = \qfq\Session::get('badcaffee1234'); + $this->assertEquals('_modeAnswer=html&_targetUrl=localhost&r=123&table=Person', $result); + // _paged: incl. alert $result = $this->report->process("10.sql = SELECT 'U:form=Person&r=123' AS _paged FROM Person ORDER BY id LIMIT 1"); $this->assertEquals('<a href="' . API_DIR . '/' . API_DELETE_PHP . '?s=badcaffee1234" class="btn btn-default" title="Delete" ' . $js . ' ><span class="glyphicon glyphicon-trash" ></span></a>', $result); @@ -705,11 +710,11 @@ alert.show(); return false;" EOF; - // _paged: incl. alert + // _Paged: incl. alert $result = $this->report->process("10.sql = SELECT 'table=Person&r=123' AS _Paged FROM Person ORDER BY id LIMIT 1"); $this->assertEquals('<a href="' . API_DIR . '/' . API_DELETE_PHP . '?s=badcaffee1234" class="btn btn-default" title="Delete" ' . $js . ' ><span class="glyphicon glyphicon-trash" ></span></a>', $result); - // _paged: other than defaults for the alert. + // _Paged: other than defaults for the alert. $js = str_replace('Do you really want to delete the record?', 'Move to trash?', $js); $js = str_replace("type: 'info'", "type: 'success'", $js); $js = str_replace('Ok', 'yes', $js); @@ -723,7 +728,6 @@ EOF; $result = $this->report->process("10.sql = SELECT 'table=Person&r=123|click me||Move to trash?:success:yes:no:10:0' AS _Paged FROM Person ORDER BY id LIMIT 1"); $this->assertEquals('<a href="' . API_DIR . '/' . API_DELETE_PHP . '?s=badcaffee1234" class="btn btn-default" title="Delete" ' . $js . ' ><span class="glyphicon glyphicon-trash" ></span> click me</a>', $result); - } /** diff --git a/extension/qfq/tests/phpunit/SipTest.php b/extension/qfq/tests/phpunit/SipTest.php index 58c883be7..a12d8e1ca 100644 --- a/extension/qfq/tests/phpunit/SipTest.php +++ b/extension/qfq/tests/phpunit/SipTest.php @@ -56,6 +56,10 @@ class SipTest extends \PHPUnit_Framework_TestCase { } + /** + * @throws CodeException + * @throws UserFormException + */ public function testGetVarsFromSip() { $sip = new Sip('fakesessionname', true); $sip->sipUniqId('badcaffee1234'); @@ -85,6 +89,9 @@ class SipTest extends \PHPUnit_Framework_TestCase { } + /** + * + */ public function testFakeUniqId() { $sip = new Sip('fakesessionname', true); $this->assertEquals('badcaffee1234', $sip->sipUniqId('badcaffee1234')); @@ -93,6 +100,9 @@ class SipTest extends \PHPUnit_Framework_TestCase { $this->assertEquals('badcaffee5678', $sip->sipUniqId('badcaffee5678')); } + /** + * @throws CodeException + */ public function testGetSipFromUrlParam() { $sip = new Sip('fakesessionname', true); @@ -113,6 +123,9 @@ class SipTest extends \PHPUnit_Framework_TestCase { } + /** + * + */ public function testSipUniqId() { $sip = new Sip('fakesessionname', true); $sip->sipUniqId('badcaffee1234'); @@ -121,6 +134,9 @@ class SipTest extends \PHPUnit_Framework_TestCase { $this->assertEquals('badcaffee1234', $s); } + /** + * @throws CodeException + */ public function testGetQueryStringFromSip() { $sip = new Sip('fakesessionname', true); $sip->sipUniqId('badcaffee1234'); -- GitLab