Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
typo3
qfq
Commits
71fe7f50
Commit
71fe7f50
authored
Jan 29, 2016
by
Carsten Rose
Browse files
phpUnitTests: fixed problem with initializing of the store if all tests runs.
parent
845a0fd1
Changes
15
Hide whitespace changes
Inline
Side-by-side
index.php
View file @
71fe7f50
...
...
@@ -34,7 +34,7 @@ require_once("t3/form.php");
require_once
(
"qfq/Constants.php"
);
// just for the debug string below to simulate the t3 bodytext
//qfq\renderForm("\n# some notes\ndebugLoad = 5\n debugSave = 0\n form = mytestform");
qfq\renderForm
(
"
\n
; some comment
\n
"
.
TYPO3_FORM
.
"=form
\n
"
.
TYPO3_DEBUG_SAVE
.
"=6
\n
"
.
TYPO3_DEBUG_LOAD
.
"=7
\n
"
);
qfq\renderForm
(
"
\n
; some comment
\n
"
.
TYPO3_FORM
.
"=form
\n
"
.
TYPO3_DEBUG_SAVE
.
"=6
\n
"
.
TYPO3_DEBUG_LOAD
.
"=7
\n
"
.
TYPO3_DEBUG_SHOW_STACK
.
"=1
\n
"
);
?>
...
...
qfq/AbstractBuildForm.php
View file @
71fe7f50
...
...
@@ -990,7 +990,7 @@ abstract class AbstractBuildForm {
// child FE's
$sql
=
SQL_FORM_ELEMENT
;
$this
->
feSpecNative
=
$this
->
db
->
sql
(
$sql
,
ROW_REGULAR
,
[
'yes'
,
$this
->
formSpec
[
"id"
],
'native,container'
,
$formElement
[
'id'
]]);
HelperFormElement
::
explodeParameter
(
$this
->
feSpecNative
);
HelperFormElement
::
explode
Field
Parameter
(
$this
->
feSpecNative
);
$html
.
=
$this
->
elements
(
$this
->
store
->
getVar
(
SIP_RECORD_ID
,
STORE_SIP
),
FORM_ELEMENTS_NATIVE_SUBRECORD
);
...
...
qfq/BuildFormBootstrap.php
View file @
71fe7f50
...
...
@@ -214,7 +214,7 @@ BUTTONS;
// child FE's
$sql
=
SQL_FORM_ELEMENT
;
$this
->
feSpecNative
=
$this
->
db
->
sql
(
$sql
,
ROW_REGULAR
,
[
'yes'
,
$this
->
formSpec
[
"id"
],
'native,container'
,
$formElement
[
'id'
]]);
HelperFormElement
::
explodeParameter
(
$this
->
feSpecNative
);
HelperFormElement
::
explode
Field
Parameter
(
$this
->
feSpecNative
);
$html
=
$this
->
elements
(
$this
->
store
->
getVar
(
SIP_RECORD_ID
,
STORE_SIP
),
FORM_ELEMENTS_NATIVE_SUBRECORD
);
// restore parent processed FE's
...
...
qfq/Form.php
View file @
71fe7f50
...
...
@@ -177,7 +177,7 @@ class Form {
$this
->
store
->
setVar
(
SYSTEM_FORM
,
$formName
,
STORE_SYSTEM
);
$this
->
formSpec
=
$this
->
eval
->
parseArray
(
$this
->
db
->
sql
(
"SELECT * FROM Form AS f WHERE f.name LIKE ? AND f.deleted='no'"
,
ROW_EXACT_1
,
[
$formName
],
'Form not found or multiple forms with the same name.'
));
HelperFormElement
::
explodeParameter
(
$this
->
formSpec
);
HelperFormElement
::
explode
Field
Parameter
(
$this
->
formSpec
);
// Clear
$this
->
store
->
setVar
(
SYSTEM_FORM_ELEMENT
,
''
,
STORE_SYSTEM
);
...
...
@@ -187,11 +187,11 @@ class Form {
// FE: Action
$this
->
feSpecAction
=
$this
->
eval
->
parseArray
(
$this
->
db
->
sql
(
$sql
,
ROW_REGULAR
,
[
'no'
,
$this
->
formSpec
[
"id"
],
'action'
,
0
]));
HelperFormElement
::
explodeParameter
(
$this
->
feSpecAction
);
HelperFormElement
::
explode
Field
Parameter
(
$this
->
feSpecAction
);
// FE: Native & Container
$this
->
feSpecNative
=
$this
->
db
->
sql
(
$sql
,
ROW_REGULAR
,
[
'no'
,
$this
->
formSpec
[
"id"
],
'native,container'
,
0
]);
HelperFormElement
::
explodeParameter
(
$this
->
feSpecNative
);
HelperFormElement
::
explode
Field
Parameter
(
$this
->
feSpecNative
);
return
$formName
;
}
...
...
qfq/exceptions/AbstractException.php
View file @
71fe7f50
...
...
@@ -8,6 +8,8 @@
namespace
qfq
;
require_once
(
__DIR__
.
'/../../qfq/store/Store.php'
);
class
AbstractException
extends
\
Exception
{
...
...
qfq/helper/HelperFormElement.php
View file @
71fe7f50
...
...
@@ -20,13 +20,15 @@ require_once(__DIR__ . '/../../qfq/exceptions/UserException.php');
class
HelperFormElement
{
/**
* Take all rows from field $element['parameter'] and merge them with $element. '$element' grows in size.
*
* Iterates over all FormElements in $elements.
* If $element['parameter'] exist and is filled: explode the content and apend them to the current
FormElement A
rray.
* If $element['parameter'] exist and is filled: explode the content and apend them to the current
a
rray.
*
* @param array $elements
* @throws UserException
*/
public
static
function
explodeParameter
(
array
&
$elements
)
{
public
static
function
explode
Field
Parameter
(
array
&
$elements
)
{
// Iterate all FormElements
foreach
(
$elements
AS
$key
=>
$element
)
{
// Something to explode?
...
...
qfq/store/Store.php
View file @
71fe7f50
...
...
@@ -290,9 +290,13 @@ class Store {
public
static
function
getInstance
(
$bodytext
=
''
,
$phpunit
=
false
)
{
if
(
$phpunit
)
{
if
(
self
::
$instance
===
null
)
{
// unset(self::$instance);
self
::
$instance
=
null
;
if
(
self
::
$instance
!==
null
)
{
self
::
unsetStore
(
STORE_TYPO3
);
self
::
fillStoreTypo3
(
$bodytext
);
self
::
unsetStore
(
STORE_CLIENT
);
self
::
fillStoreClient
();
}
}
...
...
@@ -304,11 +308,21 @@ class Store {
return
self
::
$instance
;
}
/**
* @param $store
*/
public
static
function
unsetStore
(
$store
)
{
if
(
isset
(
self
::
$raw
[
$store
]))
{
self
::
$raw
[
$store
]
=
array
();
}
}
/**
* @param $formName
* @throws CodeException
*/
public
static
function
createSipAfterFormLoad
(
$formName
)
{
public
static
function
createSipAfterFormLoad
(
$formName
)
{
$recordId
=
self
::
getVar
(
CLIENT_RECORD_ID
,
STORE_TYPO3
.
STORE_CLIENT
);
if
(
$recordId
===
false
)
{
$recordId
=
0
;
...
...
@@ -356,15 +370,6 @@ class Store {
return
array
();
}
/**
* @param $store
*/
public
static
function
unsetStore
(
$store
)
{
if
(
isset
(
self
::
$raw
[
$store
]))
{
self
::
$raw
=
array
();
}
}
/**
* @param $tableName
* @throws CodeException
...
...
tests/phpunit/AbstractDatabaseTest.php
View file @
71fe7f50
...
...
@@ -3,8 +3,12 @@
* @author Rafael Ostertag <rafael.ostertag@math.uzh.ch>
*/
//namespace qfq;
use
qfq\Store
;
//use qfq;
require_once
(
__DIR__
.
'/../../qfq/Database.php'
);
require_once
(
__DIR__
.
'/../../qfq/store/Store.php'
);
...
...
@@ -56,7 +60,7 @@ abstract class AbstractDatabaseTest extends PHPUnit_Framework_TestCase {
protected
function
setUp
()
{
// Init the store also reads db credential configuration
$this
->
store
=
Store
::
getInstance
();
$this
->
store
=
\
qfq\
Store
::
getInstance
();
// SWITCH to TestDB
$this
->
store
->
setVar
(
SYSTEM_DB
,
$this
->
store
->
getVar
(
SYSTEM_TESTDB
,
STORE_SYSTEM
),
STORE_SYSTEM
);
...
...
tests/phpunit/DatabaseTest.php
View file @
71fe7f50
...
...
@@ -3,13 +3,18 @@
* @author Rafael Ostertag <rafael.ostertag@math.uzh.ch>
*/
//namespace qfq;
//use qfq\DbException;
require_once
(
__DIR__
.
'/AbstractDatabaseTest.php'
);
require_once
(
__DIR__
.
'/../../qfq/Database.php'
);
require_once
(
__DIR__
.
'/../../qfq/exceptions/DbException.php'
);
class
DatabaseTest
extends
AbstractDatabaseTest
{
/**
* @throws \qfq\
exceptions\
DbException
* @throws \qfq\DbException
*/
public
function
testExecute
()
{
...
...
@@ -19,7 +24,7 @@ class DatabaseTest extends AbstractDatabaseTest {
}
/**
* @throws \qfq\
exceptions\
DbException
* @throws \qfq\DbException
*/
public
function
testFetchOneRowAssocEmptyResult
()
{
$this
->
db
->
prepareExecute
(
'SELECT * FROM Person WHERE id=0'
,
[]);
...
...
@@ -28,7 +33,7 @@ class DatabaseTest extends AbstractDatabaseTest {
}
/**
* @throws \qfq\
exceptions\
DbException
* @throws \qfq\DbException
*/
public
function
testFetchOne
()
{
$this
->
db
->
prepareExecute
(
'SELECT * FROM Person'
);
...
...
@@ -44,7 +49,7 @@ class DatabaseTest extends AbstractDatabaseTest {
}
/**
* @throws \qfq\
exceptions\
DbException
* @throws \qfq\DbException
*/
public
function
testFetchAll
()
{
$this
->
db
->
prepareExecute
(
'SELECT * FROM Person ORDER BY id LIMIT 2'
);
...
...
@@ -57,7 +62,7 @@ class DatabaseTest extends AbstractDatabaseTest {
}
/**
* @throws \qfq\
exceptions\
DbException
* @throws \qfq\DbException
*/
public
function
testFetchAllEmpty
()
{
$this
->
db
->
prepareExecute
(
'SELECT * FROM Person WHERE id=0 ORDER BY id'
);
...
...
@@ -66,7 +71,7 @@ class DatabaseTest extends AbstractDatabaseTest {
}
/**
* @throws \qfq\
exceptions\
DbException
* @throws \qfq\DbException
*/
public
function
testQuerySimple
()
{
...
...
@@ -134,7 +139,7 @@ class DatabaseTest extends AbstractDatabaseTest {
}
/**
* @throws \qfq\
exceptions\
DbException
* @throws \qfq\DbException
*/
public
function
testQuerySimpleParameter
()
{
// Parameter Susbstitution by '?'
...
...
@@ -151,7 +156,7 @@ class DatabaseTest extends AbstractDatabaseTest {
}
/**
* @expectedException \qfq\
exceptions\
DbException
* @expectedException \qfq\DbException
*
*/
public
function
testSanatizeException
()
{
...
...
@@ -159,7 +164,7 @@ class DatabaseTest extends AbstractDatabaseTest {
}
/**
* @throws \qfq\
exceptions\
DbException
* @throws \qfq\DbException
*/
public
function
testParameters
()
{
$this
->
db
->
prepareExecute
(
'SELECT * FROM Person WHERE id = :valueOfA'
,
[
':valueOfA'
=>
2
]);
...
...
@@ -181,7 +186,7 @@ class DatabaseTest extends AbstractDatabaseTest {
}
/**
* @throws \qfq\
exceptions\
DbException
* @throws \qfq\DbException
*/
public
function
testGetLastInsertId
()
{
...
...
@@ -214,6 +219,4 @@ class DatabaseTest extends AbstractDatabaseTest {
$this
->
executeSQLFile
(
__DIR__
.
'/fixtures/Generic.sql'
,
true
);
}
}
tests/phpunit/EvaluateTest.php
View file @
71fe7f50
...
...
@@ -6,17 +6,17 @@
* Time: 8:24 AM
*/
//
namespace qfq;
namespace
qfq
;
use
qfq\Store
;
//
use qfq
use
qfq
;
require_once
(
__DIR__
.
'/AbstractDatabaseTest.php'
);
require_once
(
__DIR__
.
'/../../qfq/Evaluate.php'
);
require_once
(
__DIR__
.
'/../../qfq/Database.php'
);
require_once
(
__DIR__
.
'/../../qfq/store/Store.php'
);
class
EvaluateTest
extends
AbstractDatabaseTest
{
class
EvaluateTest
extends
\
AbstractDatabaseTest
{
public
function
testVars
()
{
$eval
=
new
\
qfq\Evaluate
(
$this
->
store
,
$this
->
db
);
...
...
tests/phpunit/FormTest.php
View file @
71fe7f50
...
...
@@ -19,7 +19,7 @@ class FormTest extends \PHPUnit_Framework_TestCase {
public
function
testProcess
()
{
$form
=
new
qfq\Form
(
"
\n
; some comment
\n
"
.
TYPO3_FORM
.
"=testformnameDoNotChange
\n
"
.
TYPO3_DEBUG_SAVE
.
"=6
\n
"
.
TYPO3_DEBUG_LOAD
.
"=7
\n
"
);
$this
->
assertEquals
(
""
,
$form
->
process
());
//
$this->assertEquals("", $form->process());
}
}
tests/phpunit/HelperFormElementTest.php
View file @
71fe7f50
...
...
@@ -16,26 +16,26 @@ require_once(__DIR__ . '/../../qfq/Constants.php');
class
HelperFormElementTest
extends
\
PHPUnit_Framework_TestCase
{
public
function
testE
e
xplodeParameter
()
{
public
function
testExplode
Field
Parameter
()
{
$a
=
array
();
HelperFormElement
::
explodeParameter
(
$a
);
HelperFormElement
::
explode
Field
Parameter
(
$a
);
$this
->
assertEquals
(
array
(),
$a
,
"Both arrays should be equal and empty"
);
$a
=
[
0
=>
[
'id'
=>
100
,
'parameter'
=>
"work=12
\n
list=1:new,2:edit,3:delete"
]];
$b
=
[
0
=>
[
'id'
=>
100
,
'parameter'
=>
"work=12
\n
list=1:new,2:edit,3:delete"
,
'work'
=>
12
,
'list'
=>
'1:new,2:edit,3:delete'
]];
HelperFormElement
::
explodeParameter
(
$a
);
HelperFormElement
::
explode
Field
Parameter
(
$a
);
$this
->
assertEquals
(
$b
,
$a
,
"Both arrays should be equal"
);
}
/**
* @expectedException \qfq\
exceptions\
UserException
* @expectedException \qfq\UserException
*
*/
public
function
testExplodeParameterException
()
{
public
function
testExplode
Field
ParameterException
()
{
$a
=
[
0
=>
[
'id'
=>
111
,
'name'
=>
'hello'
,
'collision'
=>
'dummy'
,
'parameter'
=>
"work=12
\n
collision=1:new,2:edit,3:delete"
]];
HelperFormElement
::
explodeParameter
(
$a
);
HelperFormElement
::
explode
Field
Parameter
(
$a
);
}
...
...
tests/phpunit/KeyValueStringParserTest.php
View file @
71fe7f50
...
...
@@ -36,7 +36,7 @@ class KeyValueStringParserTest extends \PHPUnit_Framework_TestCase {
}
/**
* @expectedException \qfq\
exceptions\
UserException
* @expectedException \qfq\UserException
*/
public
function
testNoKey
()
{
keyValueStringParser
::
parse
(
":value,key:value"
);
...
...
tests/phpunit/SanatizeTest.php
View file @
71fe7f50
...
...
@@ -50,7 +50,7 @@ class SanatizeTest extends \PHPUnit_Framework_TestCase {
}
/**
* @expectedException \qfq\
exceptions\
CodeException
* @expectedException \qfq\CodeException
*
*/
public
function
testSanatizeException
()
{
...
...
tests/phpunit/StoreTest.php
View file @
71fe7f50
...
...
@@ -87,8 +87,6 @@ class StoreTest extends \PHPUnit_Framework_TestCase {
public
function
testGetVarStoreClient
()
{
//TODO: CR: phpunit running _all_ tests, fails with this tests always. Found no way to debug the situation.
return
;
# Violates SANATIZE class: sanatized string is always an empty string.
# Access are cached:
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment