Skip to content
GitLab
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
0eb47a8b
Commit
0eb47a8b
authored
Jan 28, 2016
by
Carsten Rose
Browse files
Evaluate, Sip, Store; new unittests
parent
3680f11f
Changes
3
Hide whitespace changes
Inline
Side-by-side
tests/phpunit/EvaluateTest.php
View file @
0eb47a8b
...
...
@@ -144,9 +144,10 @@ class EvaluateTest extends AbstractDatabaseTest {
protected
function
setUp
()
{
$this
->
store
=
Store
::
getInstance
(
'form=TestFormName'
);
$this
->
store
=
Store
::
getInstance
(
'form=TestFormName'
,
true
);
parent
::
setUp
();
$this
->
store
->
setVar
(
'form'
,
'TestFormName'
,
STORE_TYPO3
);
$this
->
executeSQLFile
(
__DIR__
.
'/fixtures/Generic.sql'
,
true
);
}
...
...
tests/phpunit/SipTest.php
View file @
0eb47a8b
...
...
@@ -21,41 +21,41 @@ class SipTest extends \PHPUnit_Framework_TestCase {
$sip
=
new
Sip
(
'fakesessionname'
,
true
);
$sip
->
sipUniqId
(
'badcaffee1234'
);
$result
=
$sip
->
urlParam
ToSip
(
"http://example.com/index.php?id=input&r=1&form=person"
,
RETURN_URL
);
$result
=
$sip
->
queryString
ToSip
(
"http://example.com/index.php?id=input&r=1&form=person"
,
RETURN_URL
);
$this
->
assertEquals
(
'http://example.com/index.php?id=input&s=badcaffee1234'
,
$result
);
$result
=
$sip
->
urlParam
ToSip
(
"http://example.com/index.php?id=input&r=1&form=person"
);
$result
=
$sip
->
queryString
ToSip
(
"http://example.com/index.php?id=input&r=1&form=person"
);
$this
->
assertEquals
(
'http://example.com/index.php?id=input&s=badcaffee1234'
,
$result
);
$result
=
$sip
->
urlParam
ToSip
(
"index.php?id=input&r=1&form=person"
,
RETURN_URL
);
$result
=
$sip
->
queryString
ToSip
(
"index.php?id=input&r=1&form=person"
,
RETURN_URL
);
$this
->
assertEquals
(
'index.php?id=input&s=badcaffee1234'
,
$result
);
$result
=
$sip
->
urlParam
ToSip
(
"?id=input&r=1&form=person"
,
RETURN_URL
);
$result
=
$sip
->
queryString
ToSip
(
"?id=input&r=1&form=person"
,
RETURN_URL
);
$this
->
assertEquals
(
'?id=input&s=badcaffee1234'
,
$result
);
$result
=
$sip
->
urlParam
ToSip
(
"id=input&r=1&form=person"
,
RETURN_URL
);
$result
=
$sip
->
queryString
ToSip
(
"id=input&r=1&form=person"
,
RETURN_URL
);
$this
->
assertEquals
(
'?id=input&s=badcaffee1234'
,
$result
);
$result
=
$sip
->
urlParam
ToSip
(
"input&r=1&form=person"
,
RETURN_URL
);
$result
=
$sip
->
queryString
ToSip
(
"input&r=1&form=person"
,
RETURN_URL
);
$this
->
assertEquals
(
'?id=input&s=badcaffee1234'
,
$result
);
$result
=
$sip
->
urlParam
ToSip
(
"id=input&r=1&form=person&keySemId=23"
,
RETURN_URL
);
$result
=
$sip
->
queryString
ToSip
(
"id=input&r=1&form=person&keySemId=23"
,
RETURN_URL
);
$this
->
assertEquals
(
'?id=input&s=badcaffee1234'
,
$result
);
$result
=
$sip
->
urlParam
ToSip
(
"id=input&r=1&form=person&type=99"
,
RETURN_URL
);
$result
=
$sip
->
queryString
ToSip
(
"id=input&r=1&form=person&type=99"
,
RETURN_URL
);
$this
->
assertEquals
(
'?id=input&type=99&s=badcaffee1234'
,
$result
);
$result
=
$sip
->
urlParam
ToSip
(
"id=input&r=1&form=person&L=1"
,
RETURN_URL
);
$result
=
$sip
->
queryString
ToSip
(
"id=input&r=1&form=person&L=1"
,
RETURN_URL
);
$this
->
assertEquals
(
'?id=input&L=1&s=badcaffee1234'
,
$result
);
$result
=
$sip
->
urlParam
ToSip
(
"id=input&r=1&L=2&form=person&type=99"
,
RETURN_URL
);
$result
=
$sip
->
queryString
ToSip
(
"id=input&r=1&L=2&form=person&type=99"
,
RETURN_URL
);
$this
->
assertEquals
(
'?id=input&L=2&type=99&s=badcaffee1234'
,
$result
);
$result
=
$sip
->
urlParam
ToSip
(
"id=input&r=1&L=2&form=person&type=99"
,
RETURN_SIP
);
$result
=
$sip
->
queryString
ToSip
(
"id=input&r=1&L=2&form=person&type=99"
,
RETURN_SIP
);
$this
->
assertEquals
(
'badcaffee1234'
,
$result
);
$sip
->
sipUniqId
(
'badcaffee0000'
);
$result
=
$sip
->
urlParam
ToSip
(
"id=input&r=10&L=2&form=person&type=99"
,
RETURN_SIP
);
$result
=
$sip
->
queryString
ToSip
(
"id=input&r=10&L=2&form=person&type=99"
,
RETURN_SIP
);
$this
->
assertEquals
(
'badcaffee0000'
,
$result
);
}
...
...
@@ -64,12 +64,12 @@ class SipTest extends \PHPUnit_Framework_TestCase {
$sip
=
new
Sip
(
'fakesessionname'
,
true
);
$sip
->
sipUniqId
(
'badcaffee1234'
);
$sip2
=
$sip
->
urlParam
ToSip
(
"http://example.com/index.php?a=1&b=2&c=3"
,
RETURN_SIP
);
$sip2
=
$sip
->
queryString
ToSip
(
"http://example.com/index.php?a=1&b=2&c=3"
,
RETURN_SIP
);
$arr
=
$sip
->
getVarsFromSip
(
$sip2
);
$this
->
assertEquals
([
'a'
=>
1
,
'b'
=>
2
,
'c'
=>
3
],
$arr
);
$this
->
assertEquals
(
'badcaffee1234'
,
$sip2
);
$sip2
=
$sip
->
urlParam
ToSip
(
"http://example.com/index.php?e=1&f=2&g=3"
,
RETURN_SIP
);
$sip2
=
$sip
->
queryString
ToSip
(
"http://example.com/index.php?e=1&f=2&g=3"
,
RETURN_SIP
);
$arr
=
$sip
->
getVarsFromSip
(
$sip2
);
$this
->
assertEquals
([
'e'
=>
1
,
'f'
=>
2
,
'g'
=>
3
],
$arr
);
$this
->
assertEquals
(
'badcaffee1234'
,
$sip2
);
...
...
@@ -78,12 +78,12 @@ class SipTest extends \PHPUnit_Framework_TestCase {
$sip2
=
$sip
->
sipUniqId
();
$this
->
assertEquals
(
'badcaffee0000'
,
$sip2
);
$sip2
=
$sip
->
urlParam
ToSip
(
"http://example.com/index.php?aa=hello&bb=world"
,
RETURN_SIP
);
$sip2
=
$sip
->
queryString
ToSip
(
"http://example.com/index.php?aa=hello&bb=world"
,
RETURN_SIP
);
$arr
=
$sip
->
getVarsFromSip
(
$sip2
);
$this
->
assertEquals
([
'aa'
=>
'hello'
,
'bb'
=>
'world'
],
$arr
);
$this
->
assertEquals
(
'badcaffee0000'
,
$sip2
);
$sip2
=
$sip
->
urlParam
ToSip
(
"aaa=Don&bbb=John"
,
RETURN_SIP
);
$sip2
=
$sip
->
queryString
ToSip
(
"aaa=Don&bbb=John"
,
RETURN_SIP
);
$arr
=
$sip
->
getVarsFromSip
(
$sip2
);
$this
->
assertEquals
([
'aaa'
=>
'Don'
,
'bbb'
=>
'John'
],
$arr
);
...
...
@@ -94,16 +94,16 @@ class SipTest extends \PHPUnit_Framework_TestCase {
$sip
=
new
Sip
(
'fakesessionname'
,
true
);
$sip
->
sipUniqId
(
'badcaffee1234'
);
$result
=
$sip
->
urlParam
ToSip
(
"http://example.com/index.php?id=input&r=1&form=person"
,
RETURN_URL
);
$s
=
$sip
->
getSipFrom
UrlParam
(
'form=person&r=1'
);
$result
=
$sip
->
queryString
ToSip
(
"http://example.com/index.php?id=input&r=1&form=person"
,
RETURN_URL
);
$s
=
$sip
->
getSipFrom
QueryString
(
'form=person&r=1'
);
$this
->
assertEquals
(
'badcaffee1234'
,
$s
);
$s
=
$sip
->
getSipFrom
UrlParam
(
'UnknwonParameter=1234'
);
$s
=
$sip
->
getSipFrom
QueryString
(
'UnknwonParameter=1234'
);
$this
->
assertFalse
(
$s
);
$sip
->
sipUniqId
(
'badcaffee1111'
);
$url
=
$sip
->
urlParam
ToSip
(
"a=1&b=2&c=3"
,
RETURN_SIP
);
$s
=
$sip
->
getSipFrom
UrlParam
(
'a=1&b=2&c=3'
);
$url
=
$sip
->
queryString
ToSip
(
"a=1&b=2&c=3"
,
RETURN_SIP
);
$s
=
$sip
->
getSipFrom
QueryString
(
'a=1&b=2&c=3'
);
$this
->
assertEquals
(
'badcaffee1111'
,
$s
);
}
...
...
@@ -114,7 +114,15 @@ class SipTest extends \PHPUnit_Framework_TestCase {
$s
=
$sip
->
sipUniqId
(
'badcaffee1234'
);
$this
->
assertEquals
(
'badcaffee1234'
,
$s
);
}
public
function
testGetQueryStringFromSip
()
{
$sip
=
new
Sip
(
'fakesessionname'
,
true
);
$sip
->
sipUniqId
(
'badcaffee1234'
);
$s
=
$sip
->
queryStringToSip
(
"http://example.com/index.php?id=input&r=1&form=person"
,
RETURN_SIP
);
$result
=
$sip
->
getQueryStringFromSip
(
$s
);
$this
->
assertEquals
(
'form=person&r=1'
,
$result
);
}
}
tests/phpunit/StoreTest.php
View file @
0eb47a8b
...
...
@@ -88,7 +88,7 @@ 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
;
return
;
# Violates SANATIZE class: sanatized string is always an empty string.
# Access are cached:
...
...
@@ -156,7 +156,33 @@ return;
//default prio FSRD
$this
->
assertEquals
(
0
,
$this
->
store
->
getVar
(
'fakename'
,
''
,
STORE_ZERO
),
"Retrieve anything from STORE_ZERO"
);
}
public
function
testUnsetStore
()
{
$this
->
store
->
unsetStore
(
STORE_RECORD
);
$this
->
store
->
setVarArray
(
array
(),
STORE_RECORD
);
$this
->
assertEquals
(
false
,
$this
->
store
->
getVar
(
'apple'
,
STORE_RECORD
),
"Retrieve a value from store."
);
}
public
function
testSetVarArray
()
{
$this
->
store
->
unsetStore
(
STORE_RECORD
);
$arr
=
[
'a'
=>
'1'
,
'apple'
=>
'green'
];
$this
->
store
->
setVarArray
(
$arr
,
STORE_RECORD
);
$this
->
assertEquals
(
'1'
,
$this
->
store
->
getVar
(
'a'
,
STORE_RECORD
),
"Retrieve a value from store 'fake'"
);
$this
->
assertEquals
(
'green'
,
$this
->
store
->
getVar
(
'apple'
,
STORE_RECORD
),
"Retrieve a value from store."
);
}
public
function
testSetVarArrayEmpty
()
{
$this
->
store
->
unsetStore
(
STORE_RECORD
);
$arr
=
array
();
$this
->
store
->
setVarArray
(
$arr
,
STORE_RECORD
);
$this
->
assertEquals
(
false
,
$this
->
store
->
getVar
(
'apple'
,
STORE_RECORD
),
"Retrieve a value from store."
);
}
public
function
testGetStore
()
{
$this
->
assertEquals
(
array
(),
$this
->
store
->
getStore
(
'unknownstore'
));
}
}
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new 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