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
da6a59ff
Commit
da6a59ff
authored
Jan 03, 2016
by
Carsten Rose
Browse files
Initial creation
parent
d79edba4
Changes
5
Hide whitespace changes
Inline
Side-by-side
index.php
View file @
da6a59ff
...
...
@@ -32,7 +32,7 @@
<?php
include
(
"t3/form.php"
);
load
Form
();
qfq\render
Form
();
?>
...
...
qfq/Form.php
View file @
da6a59ff
...
...
@@ -6,12 +6,16 @@
* Time: 6:33 PM
*/
namespace
qfq
;
require_once
(
__DIR__
.
'/../qfq/Store.php'
);
require_once
(
__DIR__
.
'/../qfq/Constants.php'
);
class
Form
{
protected
$config
=
null
;
//
protected $store = null;
protected
$store
=
null
;
// protected $formElements = null;
// protected $userLog = null;
...
...
@@ -31,9 +35,36 @@ class Form {
* Do all FormElements
* doActions 'After'
*/
$this
->
store
=
Store
::
getInstance
();
}
/*
*
*/
public
function
process
()
{
$this
->
loadFormDefinition
();
return
"Hello World from class Form"
;
}
public
function
toHTML
()
{
return
"Hello World from Class Form"
;
/*
*
*/
private
function
loadFormDefinition
()
{
$formName
=
$this
->
getFormName
();
echo
"--
$formName
--"
;
}
private
function
getFormName
()
{
// by bodytext
// by session
// by GET['formular']
$formName
=
$this
->
store
->
getVar
(
CLIENT_FORM
,
STORE_CLIENT
);
return
$formName
;
}
}
\ No newline at end of file
t3/form.php
View file @
da6a59ff
...
...
@@ -5,21 +5,29 @@
* Date: 12/23/15
* Time: 6:16 PM
*/
require_once
(
__DIR__
.
'/../qfq/Form.php'
);
namespace
qfq
;
use
qfq\exceptions\UserException
;
use
qfq\exceptions\CodeException
;
require_once
(
__DIR__
.
'/../qfq/Form.php'
);
require_once
(
__DIR__
.
'/../exceptions/UserException.php'
);
require_once
(
__DIR__
.
'/../exceptions/CodeException.php'
);
//TODO: unit tests fuer alle abgefangenen Exceptions
function
loadForm
()
{
/*
*
* @param string $bodytext keyvalue pairs.
*
* @return $string LOAD: the form as HTML, SAVE: success or failure message, or JS redirect to destination page.
*/
function
renderForm
(
$bodytext
=
""
)
{
try
{
$form
=
new
\
qfq\Form
();
echo
$form
->
toHTML
();
echo
$form
->
process
();
}
catch
(
UserException
$e
)
{
echo
$e
->
formatMessage
();
...
...
tests/phpunit/FormTest.php
View file @
da6a59ff
...
...
@@ -11,8 +11,9 @@ require_once(__DIR__ . '/../../qfq/Form.php');
class
FormTest
extends
PHPUnit_Framework_TestCase
{
public
function
test
ToHTML
()
{
public
function
test
Process
()
{
$form
=
new
qfq\Form
();
$this
->
assertEquals
(
"Hello World"
,
$form
->
toHTML
());
$this
->
assertEquals
(
"Hello World
from class Form
"
,
$form
->
process
());
}
}
tests/runtests.sh
0 → 100644
View file @
da6a59ff
#!/bin/bash
function
help_message
()
{
cat
<<
EOF
`basename
$0
` -p <phpunitphar> -t <testdirectory> -m <mailto> [-h]
EOF
}
while
getopts
p:t:m:h name
do
case
"
$name
"
in
h
)
help_message
exit
0
;;
p
)
PHPUNITPHAR
=
$OPTARG
;;
t
)
TESTPATH
=
$OPTARG
;;
m
)
MAILTO
=
$OPTARG
;;
esac
done
if
[
-z
"
$PHPUNITPHAR
"
-o
-z
"
$TESTPATH
"
-o
-z
"
$MAILTO
"
]
then
help_message
exit
1
fi
PHPUNITOUTPUT
=
`
php
$PHPUNITPHAR
"
$TESTPATH
/phpunit"
2>&1
`
if
[
$?
-ne
0
]
;
then
echo
"
$PHPUNITOUTPUT
"
| mailx
-s
'QFQ PHPUnit Tests Failed'
$MAILTO
fi
# if type phantomjs >/dev/null 2>&1
# then
# phantomjs "$TESTPATH/phantom.js"
# if [ -f /tmp/phantomjs.png ]
# then
# mailx -s 'PhantomJS freaked' -a /tmp/phantomjs.png $MAILTO && rm -f /tmp/phantomjs.png
# fi
# fi
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