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
e712dce3
Commit
e712dce3
authored
Dec 19, 2018
by
Carsten Rose
Browse files
phpunit: fix problems
parent
d8f3cc35
Pipeline
#1201
passed with stage
in 1 minute and 59 seconds
Changes
4
Pipelines
1
Expand all
Hide whitespace changes
Inline
Side-by-side
extension/Source/core/store/Store.php
View file @
e712dce3
...
...
@@ -199,14 +199,14 @@ class Store {
if
(
self
::
$phpUnit
)
{
if
(
self
::
$instance
!==
null
)
{
// fake to have a clean environment for the next test.
self
::
unsetStore
(
STORE_TYPO3
);
self
::
fillStoreTypo3
(
$bodytext
);
self
::
unsetStore
(
STORE_CLIENT
);
self
::
fillStoreClient
();
}
//
if (self::$instance !== null) {
//
// fake to have a clean environment for the next test.
//
self::unsetStore(STORE_TYPO3);
//
self::fillStoreTypo3($bodytext);
//
//
self::unsetStore(STORE_CLIENT);
//
self::fillStoreClient();
//
}
// Testing different config files means initialize completely
if
(
$fileConfigIni
!=
''
)
{
...
...
@@ -254,7 +254,7 @@ class Store {
if
(
defined
(
'PHPUNIT_QFQ'
))
{
$cwd
=
getcwd
();
$pos
=
strpos
(
$cwd
,
'/typo3conf/'
);
if
(
$pos
==
false
){
if
(
$pos
==
false
)
{
throw
new
CodeException
(
"Directory component '/typo3conf/' not found in '
$cwd
'"
,
1
);
}
// this means phpUnit.
...
...
extension/Tests/unit/core/BuildFormPlainTest.php
View file @
e712dce3
...
...
@@ -13,20 +13,24 @@ require_once(__DIR__ . '/database/AbstractDatabaseTest.php');
class
BuildFormPlainTest
extends
AbstractDatabaseTest
{
/**
*
* @throws CodeException
* @throws UserFormException
* @throws UserReportException
*/
public
function
testGetProcessFilter
()
{
$build
=
new
\
qfq\
BuildFormPlain
([
F_DB_INDEX
=>
DB_INDEX_DEFAULT
],
array
(),
array
(),
$this
->
dbArray
);
$build
=
new
BuildFormPlain
([
F_DB_INDEX
=>
DB_INDEX_DEFAULT
],
array
(),
array
(),
$this
->
dbArray
);
$this
->
assertEquals
(
FORM_ELEMENTS_NATIVE
,
$build
->
getProcessFilter
());
}
/**
*
* @throws CodeException
* @throws UserFormException
* @throws UserReportException
*/
public
function
testGetFormId
()
{
$build
=
new
\
qfq\
BuildFormPlain
([
F_DB_INDEX
=>
DB_INDEX_DEFAULT
],
array
(),
array
(),
$this
->
dbArray
);
$build
=
new
BuildFormPlain
([
F_DB_INDEX
=>
DB_INDEX_DEFAULT
],
array
(),
array
(),
$this
->
dbArray
);
$formId1
=
$build
->
getFormId
();
$this
->
assertRegExp
(
'/qfq-form-[0-9a-f]{13}/'
,
$formId1
);
...
...
@@ -37,10 +41,12 @@ class BuildFormPlainTest extends AbstractDatabaseTest {
}
/**
*
* @throws CodeException
* @throws UserFormException
* @throws UserReportException
*/
public
function
testWrapItem
()
{
$build
=
new
\
qfq\
BuildFormPlain
([
F_DB_INDEX
=>
DB_INDEX_DEFAULT
],
array
(),
array
(),
$this
->
dbArray
);
$build
=
new
BuildFormPlain
([
F_DB_INDEX
=>
DB_INDEX_DEFAULT
],
array
(),
array
(),
$this
->
dbArray
);
$result
=
$build
->
wrapItem
(
WRAP_SETUP_ELEMENT
,
'Hello World'
,
false
);
$this
->
assertEquals
(
'<p>Hello World</p>'
,
$result
);
...
...
@@ -56,17 +62,21 @@ class BuildFormPlainTest extends AbstractDatabaseTest {
}
/**
*
* @throws CodeException
* @throws UserFormException
* @throws UserReportException
*/
public
function
testBuildLabel
()
{
$build
=
new
\
qfq\
BuildFormPlain
([
F_DB_INDEX
=>
DB_INDEX_DEFAULT
],
array
(),
array
(),
$this
->
dbArray
);
$build
=
new
BuildFormPlain
([
F_DB_INDEX
=>
DB_INDEX_DEFAULT
],
array
(),
array
(),
$this
->
dbArray
);
$result
=
$build
->
buildLabel
(
'myLabel:123'
,
"Hello World"
);
$this
->
assertEquals
(
'<label for="myLabel:123" class="control-label" >Hello World</label>'
,
$result
);
}
/**
*
* @throws CodeException
* @throws UserFormException
* @throws UserReportException
*/
public
function
testBuildInput
()
{
$form
=
array
();
...
...
@@ -210,7 +220,9 @@ class BuildFormPlainTest extends AbstractDatabaseTest {
}
/**
*
* @throws CodeException
* @throws UserFormException
* @throws UserReportException
*/
public
function
testGetKeyValueListFromSqlEnumSpec
()
{
$form
=
array
();
...
...
@@ -219,7 +231,7 @@ class BuildFormPlainTest extends AbstractDatabaseTest {
$this
->
templateFormNFormElement
(
$form
,
$formElement
);
$formElement
[
'name'
]
=
'deleted'
;
$build
=
new
\
qfq\
BuildFormPlain
(
$form
,
array
(),
[
$formElement
],
$this
->
dbArray
);
$build
=
new
BuildFormPlain
(
$form
,
array
(),
[
$formElement
],
$this
->
dbArray
);
$keys
=
array
();
$values
=
array
();
...
...
@@ -316,8 +328,11 @@ class BuildFormPlainTest extends AbstractDatabaseTest {
}
/**
* @expectedException
\qfq\
UserFormException
* @expectedException UserFormException
*
* @throws CodeException
* @throws UserFormException
* @throws UserReportException
*/
public
function
testGetKeyValueListFromSqlEnumSpecException
()
{
$form
=
array
();
...
...
@@ -325,7 +340,7 @@ class BuildFormPlainTest extends AbstractDatabaseTest {
$this
->
templateFormNFormElement
(
$form
,
$formElement
);
$build
=
new
\
qfq\
BuildFormPlain
(
$form
,
array
(),
[
$formElement
],
$this
->
dbArray
);
$build
=
new
BuildFormPlain
(
$form
,
array
(),
[
$formElement
],
$this
->
dbArray
);
$formElement
[
'name'
]
=
'noteInternal'
;
$keys
=
array
();
...
...
@@ -335,7 +350,10 @@ class BuildFormPlainTest extends AbstractDatabaseTest {
/**
*
* @throws CodeException
* @throws DbException
* @throws UserFormException
* @throws UserReportException
*/
public
function
testBuildSubrecord
()
{
$form
=
array
();
...
...
@@ -343,20 +361,21 @@ class BuildFormPlainTest extends AbstractDatabaseTest {
$json
=
array
();
$this
->
templateFormNFormElement
(
$form
,
$formElement
);
$formElement
=
\
qfq\
Support
::
setFeDefaults
(
$formElement
);
$formElement
=
Support
::
setFeDefaults
(
$formElement
);
// CheckType
$build
=
new
\
qfq\
BuildFormPlain
(
$form
,
array
(),
[
$formElement
],
$this
->
dbArray
);
$build
=
new
BuildFormPlain
(
$form
,
array
(),
[
$formElement
],
$this
->
dbArray
);
// id: 1, firstName: John, name: Doe
$formElement
[
'sql1'
]
=
$this
->
dbArray
[
DB_INDEX_DEFAULT
]
->
sql
(
'SELECT id, name, firstName FROM Person ORDER BY id LIMIT 2'
);
$formElement
[
SUBRECORD_PARAMETER_FORM
]
=
'Person'
;
$result
=
$build
->
buildSubrecord
(
$formElement
,
'name:1'
,
''
,
$json
);
$this
->
assertEquals
(
'Please save this record first.'
,
$result
);
$this
->
store
->
setStore
([
'id'
=>
1
],
STORE_RECORD
,
true
);
$formElement
[
SUBRECORD_PARAMETER_FORM
]
=
'Person'
;
$formElement
[
FE_SUBRECORD_OPTION
]
=
''
;
$formElement
[
SUBRECORD_PARAMETER_FORM
]
=
'Person'
;
$formElement
[
FE_SUBRECORD_OPTION
]
=
''
;
$result
=
$build
->
buildSubrecord
(
$formElement
,
'name:1'
,
''
,
$json
);
$this
->
assertEquals
(
'<table class="table table-hover qfq-subrecord-table" ><thead><tr><th>id</th><th>name</th><th>firstName</th></tr></thead><tbody ><tr class="record" ><td><span class="text-muted">1</span></td><td>Doe</td><td>John</td></tr><tr class="record" ><td><span class="text-muted">2</span></td><td>Smith</td><td>Jane</td></tr></tbody></table>'
,
$result
);
...
...
@@ -531,14 +550,6 @@ class BuildFormPlainTest extends AbstractDatabaseTest {
// }
/**
* @throws CodeException
* @throws DbException
* @throws DownloadException
* @throws UserFormException
* @throws UserReportException
* @throws \PhpOffice\PhpSpreadsheet\Exception
* @throws \PhpOffice\PhpSpreadsheet\Reader\Exception
* @throws \PhpOffice\PhpSpreadsheet\Writer\Exception
*/
protected
function
setUp
()
{
$_GET
[
'form'
]
=
'phpunit_person'
;
...
...
extension/Tests/unit/core/QuickFormQueryTest.php
View file @
e712dce3
...
...
@@ -18,12 +18,6 @@ class QuickFormQueryTest extends TestCase {
private
$store
;
public
function
testProcess
()
{
// $form = new QuickFormQuery(['bodytext' => "\n; some comment\n" . TYPO3_FORM . "=testformnameDoNotChange\n"]);
// $this->assertEquals("", $form->process());
}
//
//* FORM_LOAD:
//* Specified in T3 body text with form=<formname> Returned Store:Typo3
//* Specified in T3 body text with form={{form}} ':FSRD' Returned Store:SIP
...
...
@@ -51,7 +45,10 @@ class QuickFormQueryTest extends TestCase {
*/
public
function
testGetFormName
()
{
$store
=
Store
::
getInstance
();
// <empty> bodytext
$store
->
unsetStore
(
STORE_TYPO3
);
$t3data
[
T3DATA_BODYTEXT
]
=
"
\n
\n
\n
"
;
$t3data
[
T3DATA_UID
]
=
"123"
;
$qfq
=
new
QuickFormQuery
(
$t3data
,
true
);
...
...
@@ -59,6 +56,7 @@ class QuickFormQueryTest extends TestCase {
$this
->
assertEquals
(
''
,
$result
);
// form=
$store
->
unsetStore
(
STORE_TYPO3
);
$t3data
[
T3DATA_BODYTEXT
]
=
"
\n
\n
"
.
TYPO3_FORM
.
"=
\n
"
;
$t3data
[
T3DATA_UID
]
=
"123"
;
$qfq
=
new
QuickFormQuery
(
$t3data
,
true
);
...
...
@@ -66,6 +64,7 @@ class QuickFormQueryTest extends TestCase {
$this
->
assertEquals
(
''
,
$result
);
// form=<formname>
$store
->
unsetStore
(
STORE_TYPO3
);
$t3data
[
T3DATA_BODYTEXT
]
=
"
\n
\n
"
.
TYPO3_FORM
.
"=myForm
\n
"
;
$t3data
[
T3DATA_UID
]
=
"123"
;
$qfq
=
new
QuickFormQuery
(
$t3data
,
true
);
...
...
@@ -73,6 +72,7 @@ class QuickFormQueryTest extends TestCase {
$this
->
assertEquals
(
'myForm'
,
$result
);
// form={{SELECT 'nextForm'}}
$store
->
unsetStore
(
STORE_TYPO3
);
$t3data
[
T3DATA_BODYTEXT
]
=
"
\n
\n
"
.
TYPO3_FORM
.
"={{SELECT 'nextForm'}}
\n
"
;
$t3data
[
T3DATA_UID
]
=
"123"
;
$qfq
=
new
QuickFormQuery
(
$t3data
,
true
);
...
...
@@ -80,9 +80,11 @@ class QuickFormQueryTest extends TestCase {
$this
->
assertEquals
(
'nextForm'
,
$result
);
// form={{form:C:alnumx}}
$store
->
unsetStore
(
STORE_TYPO3
);
$store
->
setVar
(
CLIENT_FORM
,
'formNameViaGet'
,
STORE_CLIENT
);
$t3data
[
T3DATA_BODYTEXT
]
=
"
\n
\n
"
.
TYPO3_FORM
.
"=
{
{form:C:alnumx}
}
\n
"
;
$t3data
[
T3DATA_UID
]
=
"123"
;
$_SERVER
[
'form'
]
=
'formNameViaGet'
;
//
$_SERVER['form'] = 'formNameViaGet';
$qfq
=
new
QuickFormQuery
(
$t3data
,
true
);
$result
=
$qfq
->
getFormName
(
FORM_LOAD
,
$foundInStore
);
$this
->
assertEquals
(
'formNameViaGet'
,
$result
);
...
...
extension/Tests/unit/core/report/ReportTest.php
View file @
e712dce3
This diff is collapsed.
Click to expand it.
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