Commit 19d36d65 authored by Carsten  Rose's avatar Carsten Rose
Browse files

unittests: namespace 'qfq' unified

parent beb494e7
...@@ -3,8 +3,7 @@ ...@@ -3,8 +3,7 @@
* @author Rafael Ostertag <rafael.ostertag@math.uzh.ch> * @author Rafael Ostertag <rafael.ostertag@math.uzh.ch>
*/ */
use qfq\helper; use qfq\Store;
use qfq\store;
require_once(__DIR__ . '/../../qfq/Database.php'); require_once(__DIR__ . '/../../qfq/Database.php');
require_once(__DIR__ . '/../../qfq/store/Store.php'); require_once(__DIR__ . '/../../qfq/store/Store.php');
...@@ -57,7 +56,7 @@ abstract class AbstractDatabaseTest extends PHPUnit_Framework_TestCase { ...@@ -57,7 +56,7 @@ abstract class AbstractDatabaseTest extends PHPUnit_Framework_TestCase {
protected function setUp() { protected function setUp() {
// Init the store also reads db credential configuration // Init the store also reads db credential configuration
$this->store = \qfq\store\Store::getInstance(); $this->store = Store::getInstance();
// SWITCH to TestDB // SWITCH to TestDB
$this->store->setVar(SYSTEM_DB, $this->store->getVar(SYSTEM_TESTDB, STORE_SYSTEM), STORE_SYSTEM); $this->store->setVar(SYSTEM_DB, $this->store->getVar(SYSTEM_TESTDB, STORE_SYSTEM), STORE_SYSTEM);
......
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
//namespace qfq; //namespace qfq;
//use qfq\store\Store; use qfq\Store;
//use qfq //use qfq
require_once(__DIR__ . '/AbstractDatabaseTest.php'); require_once(__DIR__ . '/AbstractDatabaseTest.php');
...@@ -144,7 +144,7 @@ class EvaluateTest extends AbstractDatabaseTest { ...@@ -144,7 +144,7 @@ class EvaluateTest extends AbstractDatabaseTest {
protected function setUp() { protected function setUp() {
$this->store = \qfq\store\Store::getInstance('form=TestFormName'); $this->store = Store::getInstance('form=TestFormName');
parent::setUp(); parent::setUp();
$this->executeSQLFile(__DIR__ . '/fixtures/Generic.sql', true); $this->executeSQLFile(__DIR__ . '/fixtures/Generic.sql', true);
......
...@@ -12,7 +12,7 @@ require_once(__DIR__ . '/../../qfq/Constants.php'); ...@@ -12,7 +12,7 @@ require_once(__DIR__ . '/../../qfq/Constants.php');
require_once(__DIR__ . '/../../qfq/Form.php'); require_once(__DIR__ . '/../../qfq/Form.php');
require_once(__DIR__ . '/../../qfq/store/Store.php'); require_once(__DIR__ . '/../../qfq/store/Store.php');
class FormTest extends PHPUnit_Framework_TestCase { class FormTest extends \PHPUnit_Framework_TestCase {
private $store; private $store;
......
<?php
/**
* Created by PhpStorm.
* User: crose
* Date: 1/26/16
* Time: 2:56 PM
*/
namespace qfq;
use qfq\HelperFormElement;
require_once(__DIR__ . '/../../qfq/helper/HelperFormElement.php');
require_once(__DIR__ . '/../../qfq/Constants.php');
class HelperFormElementTest extends \PHPUnit_Framework_TestCase {
public function testEexplodeParameter() {
$a = array();
HelperFormElement::explodeParameter($a);
$this->assertEquals(array(), $a, "Both arrays should be equal and empty");
$a = [0 => ['id' => 100, 'parameter' => "work=12\nlist=1:new,2:edit,3:delete"]];
$b = [0 => ['id' => 100, 'parameter' => "work=12\nlist=1:new,2:edit,3:delete", 'work' => 12, 'list' => '1:new,2:edit,3:delete']];
HelperFormElement::explodeParameter($a);
$this->assertEquals($b, $a, "Both arrays should be equal");
}
/**
* @expectedException \qfq\exceptions\UserException
*
*/
public function testExplodeParameterException() {
$a = [0 => ['id' => 111, 'name' => 'hello', 'collision' => 'dummy', 'parameter' => "work=12\ncollision=1:new,2:edit,3:delete"]];
HelperFormElement::explodeParameter($a);
}
}
...@@ -5,12 +5,10 @@ ...@@ -5,12 +5,10 @@
namespace qfq; namespace qfq;
use qfq; use qfq\KeyValueStringParser;
require_once(__DIR__ . '/../../qfq/Constants.php'); require_once(__DIR__ . '/../../qfq/Constants.php');
//use qfq\helper;
use qfq\helper\KeyValueStringParser;
require_once(__DIR__ . '/../../qfq/helper/KeyValueStringParser.php'); require_once(__DIR__ . '/../../qfq/helper/KeyValueStringParser.php');
......
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
* Time: 9:28 AM * Time: 9:28 AM
*/ */
namespace qfq\helper; namespace qfq;
require_once(__DIR__ . '/../../qfq/helper/OnArray.php'); require_once(__DIR__ . '/../../qfq/helper/OnArray.php');
...@@ -30,11 +30,11 @@ class OnArrayTest extends \PHPUnit_Framework_TestCase { ...@@ -30,11 +30,11 @@ class OnArrayTest extends \PHPUnit_Framework_TestCase {
]; ];
$expected = $unsorted; $expected = $unsorted;
\qfq\helper\OnArray::sortKey($expected); OnArray::sortKey($expected);
$this->assertEquals($sorted, $expected); $this->assertEquals($sorted, $expected);
$expected = array(); $expected = array();
\qfq\helper\OnArray::sortKey($expected); OnArray::sortKey($expected);
$this->assertEquals(array(), $expected); $this->assertEquals(array(), $expected);
} }
...@@ -43,6 +43,6 @@ class OnArrayTest extends \PHPUnit_Framework_TestCase { ...@@ -43,6 +43,6 @@ class OnArrayTest extends \PHPUnit_Framework_TestCase {
$raw = ['hello', '"next"', '"without trailing', 'without leading"', ' with whitespace ', '" with tick and whitespace "', '']; $raw = ['hello', '"next"', '"without trailing', 'without leading"', ' with whitespace ', '" with tick and whitespace "', ''];
$expected = ['hello', 'next', 'without trailing', 'without leading', ' with whitespace ', ' with tick and whitespace ', '']; $expected = ['hello', 'next', 'without trailing', 'without leading', ' with whitespace ', ' with tick and whitespace ', ''];
$this->assertEquals(\qfq\helper\OnArray::trimArray($raw, '"'), $expected); $this->assertEquals(OnArray::trimArray($raw, '"'), $expected);
} }
} }
<?php <?php
namespace qfq;
//use qfq\Sip;
require_once(__DIR__ . '/../../qfq/Constants.php'); require_once(__DIR__ . '/../../qfq/Constants.php');
require_once(__DIR__ . '/../../qfq/Form.php'); require_once(__DIR__ . '/../../qfq/Form.php');
require_once(__DIR__ . '/../../qfq/store/Sip.php'); require_once(__DIR__ . '/../../qfq/store/Sip.php');
...@@ -10,11 +14,11 @@ require_once(__DIR__ . '/../../qfq/store/Sip.php'); ...@@ -10,11 +14,11 @@ require_once(__DIR__ . '/../../qfq/store/Sip.php');
* Date: 1/10/16 * Date: 1/10/16
* Time: 10:55 PM * Time: 10:55 PM
*/ */
class SipTest extends PHPUnit_Framework_TestCase { class SipTest extends \PHPUnit_Framework_TestCase {
public function testUrlparamToSip() { public function testUrlparamToSip() {
$sip = new \qfq\store\Sip('fakesessionname', true); $sip = new Sip('fakesessionname', true);
$sip->sipUniqId('badcaffee1234'); $sip->sipUniqId('badcaffee1234');
$result = $sip->urlParamToSip("http://example.com/index.php?id=input&r=1&form=person", RETURN_URL); $result = $sip->urlParamToSip("http://example.com/index.php?id=input&r=1&form=person", RETURN_URL);
...@@ -57,7 +61,7 @@ class SipTest extends PHPUnit_Framework_TestCase { ...@@ -57,7 +61,7 @@ class SipTest extends PHPUnit_Framework_TestCase {
} }
public function testGetVarsFromSip() { public function testGetVarsFromSip() {
$sip = new \qfq\store\Sip('fakesessionname', true); $sip = new Sip('fakesessionname', true);
$sip->sipUniqId('badcaffee1234'); $sip->sipUniqId('badcaffee1234');
$sip2 = $sip->urlParamToSip("http://example.com/index.php?a=1&b=2&c=3", RETURN_SIP); $sip2 = $sip->urlParamToSip("http://example.com/index.php?a=1&b=2&c=3", RETURN_SIP);
...@@ -87,7 +91,7 @@ class SipTest extends PHPUnit_Framework_TestCase { ...@@ -87,7 +91,7 @@ class SipTest extends PHPUnit_Framework_TestCase {
public function testGetSipFromUrlParam() { public function testGetSipFromUrlParam() {
$sip = new \qfq\store\Sip('fakesessionname', true); $sip = new Sip('fakesessionname', true);
$sip->sipUniqId('badcaffee1234'); $sip->sipUniqId('badcaffee1234');
$result = $sip->urlParamToSip("http://example.com/index.php?id=input&r=1&form=person", RETURN_URL); $result = $sip->urlParamToSip("http://example.com/index.php?id=input&r=1&form=person", RETURN_URL);
...@@ -105,7 +109,7 @@ class SipTest extends PHPUnit_Framework_TestCase { ...@@ -105,7 +109,7 @@ class SipTest extends PHPUnit_Framework_TestCase {
} }
public function testSipUniqId() { public function testSipUniqId() {
$sip = new \qfq\store\Sip('fakesessionname', true); $sip = new Sip('fakesessionname', true);
$sip->sipUniqId('badcaffee1234'); $sip->sipUniqId('badcaffee1234');
$s = $sip->sipUniqId('badcaffee1234'); $s = $sip->sipUniqId('badcaffee1234');
......
...@@ -6,9 +6,10 @@ ...@@ -6,9 +6,10 @@
* Time: 9:16 PM * Time: 9:16 PM
*/ */
namespace qfq\store; namespace qfq;
use qfq; use qfq;
use qfq\Store;
//use qfq\exceptions\CodeException; //use qfq\exceptions\CodeException;
......
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