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

unittests: namespace 'qfq' unified

parent beb494e7
......@@ -3,8 +3,7 @@
* @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/store/Store.php');
......@@ -57,7 +56,7 @@ abstract class AbstractDatabaseTest extends PHPUnit_Framework_TestCase {
protected function setUp() {
// Init the store also reads db credential configuration
$this->store = \qfq\store\Store::getInstance();
$this->store = Store::getInstance();
// SWITCH to TestDB
$this->store->setVar(SYSTEM_DB, $this->store->getVar(SYSTEM_TESTDB, STORE_SYSTEM), STORE_SYSTEM);
......
......@@ -8,7 +8,7 @@
//namespace qfq;
//use qfq\store\Store;
use qfq\Store;
//use qfq
require_once(__DIR__ . '/AbstractDatabaseTest.php');
......@@ -144,7 +144,7 @@ class EvaluateTest extends AbstractDatabaseTest {
protected function setUp() {
$this->store = \qfq\store\Store::getInstance('form=TestFormName');
$this->store = Store::getInstance('form=TestFormName');
parent::setUp();
$this->executeSQLFile(__DIR__ . '/fixtures/Generic.sql', true);
......
......@@ -12,7 +12,7 @@ require_once(__DIR__ . '/../../qfq/Constants.php');
require_once(__DIR__ . '/../../qfq/Form.php');
require_once(__DIR__ . '/../../qfq/store/Store.php');
class FormTest extends PHPUnit_Framework_TestCase {
class FormTest extends \PHPUnit_Framework_TestCase {
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 @@
namespace qfq;
use qfq;
use qfq\KeyValueStringParser;
require_once(__DIR__ . '/../../qfq/Constants.php');
//use qfq\helper;
use qfq\helper\KeyValueStringParser;
require_once(__DIR__ . '/../../qfq/helper/KeyValueStringParser.php');
......
......@@ -6,7 +6,7 @@
* Time: 9:28 AM
*/
namespace qfq\helper;
namespace qfq;
require_once(__DIR__ . '/../../qfq/helper/OnArray.php');
......@@ -30,11 +30,11 @@ class OnArrayTest extends \PHPUnit_Framework_TestCase {
];
$expected = $unsorted;
\qfq\helper\OnArray::sortKey($expected);
OnArray::sortKey($expected);
$this->assertEquals($sorted, $expected);
$expected = array();
\qfq\helper\OnArray::sortKey($expected);
OnArray::sortKey($expected);
$this->assertEquals(array(), $expected);
}
......@@ -43,6 +43,6 @@ class OnArrayTest extends \PHPUnit_Framework_TestCase {
$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 ', ''];
$this->assertEquals(\qfq\helper\OnArray::trimArray($raw, '"'), $expected);
$this->assertEquals(OnArray::trimArray($raw, '"'), $expected);
}
}
<?php
namespace qfq;
//use qfq\Sip;
require_once(__DIR__ . '/../../qfq/Constants.php');
require_once(__DIR__ . '/../../qfq/Form.php');
require_once(__DIR__ . '/../../qfq/store/Sip.php');
......@@ -10,11 +14,11 @@ require_once(__DIR__ . '/../../qfq/store/Sip.php');
* Date: 1/10/16
* Time: 10:55 PM
*/
class SipTest extends PHPUnit_Framework_TestCase {
class SipTest extends \PHPUnit_Framework_TestCase {
public function testUrlparamToSip() {
$sip = new \qfq\store\Sip('fakesessionname', true);
$sip = new Sip('fakesessionname', true);
$sip->sipUniqId('badcaffee1234');
$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 {
}
public function testGetVarsFromSip() {
$sip = new \qfq\store\Sip('fakesessionname', true);
$sip = new Sip('fakesessionname', true);
$sip->sipUniqId('badcaffee1234');
$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 {
public function testGetSipFromUrlParam() {
$sip = new \qfq\store\Sip('fakesessionname', true);
$sip = new Sip('fakesessionname', true);
$sip->sipUniqId('badcaffee1234');
$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 {
}
public function testSipUniqId() {
$sip = new \qfq\store\Sip('fakesessionname', true);
$sip = new Sip('fakesessionname', true);
$sip->sipUniqId('badcaffee1234');
$s = $sip->sipUniqId('badcaffee1234');
......
......@@ -6,9 +6,10 @@
* Time: 9:16 PM
*/
namespace qfq\store;
namespace qfq;
use qfq;
use qfq\Store;
//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