From 197ad3cdedb641177f3ab52dafe4ca650d6887fc Mon Sep 17 00:00:00 2001
From: Carsten  Rose <carsten.rose@math.uzh.ch>
Date: Sat, 28 Jan 2017 17:17:39 +0100
Subject: [PATCH] LinkTest.php: comment link delete test - implizit delete is
 not supported anymore via link. ReportTest.php: implemented various exception
 tests for missing parameter of _paged

---
 extension/qfq/tests/phpunit/LinkTest.php   |  6 +--
 extension/qfq/tests/phpunit/ReportTest.php | 61 +++++++++++++++++++++-
 2 files changed, 63 insertions(+), 4 deletions(-)

diff --git a/extension/qfq/tests/phpunit/LinkTest.php b/extension/qfq/tests/phpunit/LinkTest.php
index 995b7231c..0382d149e 100644
--- a/extension/qfq/tests/phpunit/LinkTest.php
+++ b/extension/qfq/tests/phpunit/LinkTest.php
@@ -554,9 +554,9 @@ class LinkTest extends \PHPUnit_Framework_TestCase {
         $result = $link->renderLink('u:http://example.com|N');
         $this->assertEquals('<a href="http://example.com" class="btn btn-default" title="New" ><span class="glyphicon glyphicon-plus" ></span></a>', $result);
 
-        $result = $link->renderLink('u:http://example.com|D');
-        $this->assertEquals('<a href="http://example.com" class="btn btn-default" title="Delete" ><span class="glyphicon glyphicon-trash" ></span></a>', $result);
-
+//        $result = $link->renderLink('u:http://example.com|D');
+//        $this->assertEquals('<a href="http://example.com" class="btn btn-default" title="Delete" ><span class="glyphicon glyphicon-trash" ></span></a>', $result);
+//
         $result = $link->renderLink('u:http://example.com|H');
         $this->assertEquals('<a href="http://example.com" class="btn btn-default" title="Help" ><span class="glyphicon glyphicon glyphicon-question-sign" ></span></a>', $result);
 
diff --git a/extension/qfq/tests/phpunit/ReportTest.php b/extension/qfq/tests/phpunit/ReportTest.php
index f66ebf512..bcb0204d8 100644
--- a/extension/qfq/tests/phpunit/ReportTest.php
+++ b/extension/qfq/tests/phpunit/ReportTest.php
@@ -667,6 +667,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);
 
+        // _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);
+
         // _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);
@@ -681,7 +685,6 @@ EOF;
 
         $result = $this->report->process("10.sql = SELECT 'U:table=Person&r=123|q:Move to trash?:success:yes:no:10:0|t:click me' 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);
-
     }
 
     /**
@@ -723,6 +726,62 @@ EOF;
 
     }
 
+    /**
+     * Missing r, missing form or table
+     * @expectedException \qfq\UserReportException
+     */
+    public function testMissingPagedParameterException1() {
+        $this->report->process("10.sql = SELECT '' AS _Paged FROM Person ORDER BY id LIMIT 1");
+    }
+
+    /**
+     * Missing r, given table
+     * @expectedException \qfq\UserReportException
+     */
+    public function testMissingPagedParameterException2() {
+        $this->report->process("10.sql = SELECT 'table=Person' AS _Paged FROM Person ORDER BY id LIMIT 1");
+    }
+
+    /**
+     * Missing r, given form
+     * @expectedException \qfq\UserReportException
+     */
+    public function testMissingPagedParameterException3() {
+        $this->report->process("10.sql = SELECT 'form=Person' AS _Paged FROM Person ORDER BY id LIMIT 1");
+    }
+
+    /**
+     * missing form, missing table
+     * @expectedException \qfq\UserReportException
+     */
+    public function testMissingPagedParameterException4() {
+        $this->report->process("10.sql = SELECT 'r=123' AS _Paged FROM Person ORDER BY id LIMIT 1");
+    }
+
+    /**
+     * missng r, given table
+     * @expectedException \qfq\UserReportException
+     */
+    public function testMissingPagedParameterException5() {
+        $this->report->process("10.sql = SELECT 'table=Person&r' AS _Paged FROM Person ORDER BY id LIMIT 1");
+    }
+
+    /**
+     * missing table, given r
+     * @expectedException \qfq\UserReportException
+     */
+    public function testMissingPagedParameterException6() {
+        $this->report->process("10.sql = SELECT 'table&r=123' AS _Paged FROM Person ORDER BY id LIMIT 1");
+    }
+
+    /**
+     * missing form, given r
+     * @expectedException \qfq\UserReportException
+     */
+    public function testMissingPagedParameterException7() {
+        $this->report->process("10.sql = SELECT 'form&r=123' AS _Paged FROM Person ORDER BY id LIMIT 1");
+    }
+
     /**
      *
      */
-- 
GitLab