Commit ca8329d4 authored by Carsten  Rose's avatar Carsten Rose
Browse files

Fixed unit tests for new !!<sanitize>!!

parent 4c2801d3
......@@ -256,7 +256,7 @@ class EvaluateTest extends \AbstractDatabaseTest {
// Sanatize Class: text
$this->store->setVar('a', 'Hello world @-_.,;: /()', STORE_FORM, true);
$this->assertEquals('', $eval->substitute('a:F:digit', $foundInStore));
$this->assertEquals('!!digit!!', $eval->substitute('a:F:digit', $foundInStore));
$this->assertEquals(STORE_FORM, $foundInStore);
$this->assertEquals('Hello world @-_.,;: /()', $eval->substitute('a:F:alnumx', $foundInStore));
......
......@@ -26,8 +26,8 @@ class SanitizeTest extends \PHPUnit_Framework_TestCase {
# Check ''
$this->assertEquals('', Sanitize::sanitize('', SANITIZE_ALLOW_ALNUMX), "SANITIZE_ALNUMX fails");
$this->assertEquals('', Sanitize::sanitize('', SANITIZE_ALLOW_DIGIT), "SANITIZE_DIGIT fails");
$this->assertEquals('', Sanitize::sanitize('', SANITIZE_ALLOW_MIN_MAX, '1|2'), "SANITIZE_MIN_MAX fails");
$this->assertEquals('', Sanitize::sanitize('', SANITIZE_ALLOW_EMAIL), "SANITIZE_EMAIL fails");
$this->assertEquals('!!min|max!!', Sanitize::sanitize('', SANITIZE_ALLOW_MIN_MAX, '1|2'), "SANITIZE_MIN_MAX fails");
$this->assertEquals('!!email!!', Sanitize::sanitize('', SANITIZE_ALLOW_EMAIL), "SANITIZE_EMAIL fails");
$this->assertEquals('', Sanitize::sanitize('', SANITIZE_ALLOW_PATTERN, '.*'), "SANITIZE_PATTERN fails");
$this->assertEquals('', Sanitize::sanitize('', SANITIZE_ALLOW_ALL), "SANITIZE_ALL fails");
$this->assertEquals('', Sanitize::sanitize('', SANITIZE_ALLOW_ALLBUT), "SANITIZE_ALLBUT fails");
......@@ -36,25 +36,25 @@ class SanitizeTest extends \PHPUnit_Framework_TestCase {
$this->assertEquals('1', Sanitize::sanitize('1', SANITIZE_ALLOW_ALNUMX), "SANITIZE_ALNUMX fails");
$this->assertEquals('1', Sanitize::sanitize('1', SANITIZE_ALLOW_DIGIT), "SANITIZE_DIGIT fails");
$this->assertEquals('1', Sanitize::sanitize('1', SANITIZE_ALLOW_MIN_MAX, '1|2'), "SANITIZE_MIN_MAX fails");
$this->assertEquals('', Sanitize::sanitize('1', SANITIZE_ALLOW_EMAIL), "SANITIZE_EMAIL fails");
$this->assertEquals('!!email!!', Sanitize::sanitize('1', SANITIZE_ALLOW_EMAIL), "SANITIZE_EMAIL fails");
$this->assertEquals('1', Sanitize::sanitize('1', SANITIZE_ALLOW_PATTERN, '.*'), "SANITIZE_PATTERN fails");
$this->assertEquals('1', Sanitize::sanitize('1', SANITIZE_ALLOW_ALL), "SANITIZE_ALL fails");
$this->assertEquals('1', Sanitize::sanitize('1', SANITIZE_ALLOW_ALLBUT), "SANITIZE_ALLBUT fails");
# Check '-3'
$this->assertEquals('-3', Sanitize::sanitize('-3', SANITIZE_ALLOW_ALNUMX), "SANITIZE_ALNUMX fails");
$this->assertEquals('', Sanitize::sanitize('-3', SANITIZE_ALLOW_DIGIT), "SANITIZE_DIGIT fails");
$this->assertEquals('!!digit!!', Sanitize::sanitize('-3', SANITIZE_ALLOW_DIGIT), "SANITIZE_DIGIT fails");
$this->assertEquals('-3', Sanitize::sanitize('-3', SANITIZE_ALLOW_MIN_MAX, '-5|2'), "SANITIZE_MIN_MAX fails");
$this->assertEquals('', Sanitize::sanitize('-3', SANITIZE_ALLOW_EMAIL), "SANITIZE_EMAIL fails");
$this->assertEquals('!!email!!', Sanitize::sanitize('-3', SANITIZE_ALLOW_EMAIL), "SANITIZE_EMAIL fails");
$this->assertEquals('-3', Sanitize::sanitize('-3', SANITIZE_ALLOW_PATTERN, '.*'), "SANITIZE_PATTERN fails");
$this->assertEquals('-3', Sanitize::sanitize('-3', SANITIZE_ALLOW_ALL), "SANITIZE_ALL fails");
$this->assertEquals('-3', Sanitize::sanitize('-3', SANITIZE_ALLOW_ALLBUT), "SANITIZE_ALLBUT fails");
# Check 'a'
$this->assertEquals('a', Sanitize::sanitize('a', SANITIZE_ALLOW_ALNUMX), "SANITIZE_ALNUMX fails");
$this->assertEquals('', Sanitize::sanitize('a', SANITIZE_ALLOW_DIGIT), "SANITIZE_DIGIT fails");
$this->assertEquals('', Sanitize::sanitize('a', SANITIZE_ALLOW_MIN_MAX, '-5|2'), "SANITIZE_MIN_MAX fails");
$this->assertEquals('', Sanitize::sanitize('a', SANITIZE_ALLOW_EMAIL), "SANITIZE_EMAIL fails");
$this->assertEquals('!!digit!!', Sanitize::sanitize('a', SANITIZE_ALLOW_DIGIT), "SANITIZE_DIGIT fails");
$this->assertEquals('!!min|max!!', Sanitize::sanitize('a', SANITIZE_ALLOW_MIN_MAX, '-5|2'), "SANITIZE_MIN_MAX fails");
$this->assertEquals('!!email!!', Sanitize::sanitize('a', SANITIZE_ALLOW_EMAIL), "SANITIZE_EMAIL fails");
$this->assertEquals('a', Sanitize::sanitize('a', SANITIZE_ALLOW_PATTERN, '.*'), "SANITIZE_PATTERN fails");
$this->assertEquals('a', Sanitize::sanitize('a', SANITIZE_ALLOW_ALL), "SANITIZE_ALL fails");
$this->assertEquals('a', Sanitize::sanitize('a', SANITIZE_ALLOW_ALLBUT), "SANITIZE_ALLBUT fails");
......@@ -63,19 +63,19 @@ class SanitizeTest extends \PHPUnit_Framework_TestCase {
# Check 'a@-_.,;Z09'
$val = 'a@-_.,;Z09';
$this->assertEquals($val, Sanitize::sanitize($val, SANITIZE_ALLOW_ALNUMX), "SANITIZE_ALNUMX fails");
$this->assertEquals('', Sanitize::sanitize($val, SANITIZE_ALLOW_DIGIT), "SANITIZE_DIGIT fails");
$this->assertEquals('', Sanitize::sanitize($val, SANITIZE_ALLOW_MIN_MAX, '-5|2'), "SANITIZE_MIN_MAX fails");
$this->assertEquals('', Sanitize::sanitize($val, SANITIZE_ALLOW_EMAIL), "SANITIZE_EMAIL fails");
$this->assertEquals('!!digit!!', Sanitize::sanitize($val, SANITIZE_ALLOW_DIGIT), "SANITIZE_DIGIT fails");
$this->assertEquals('!!min|max!!', Sanitize::sanitize($val, SANITIZE_ALLOW_MIN_MAX, '-5|2'), "SANITIZE_MIN_MAX fails");
$this->assertEquals('!!email!!', Sanitize::sanitize($val, SANITIZE_ALLOW_EMAIL), "SANITIZE_EMAIL fails");
$this->assertEquals($val, Sanitize::sanitize($val, SANITIZE_ALLOW_PATTERN, '.*'), "SANITIZE_PATTERN fails");
$this->assertEquals($val, Sanitize::sanitize($val, SANITIZE_ALLOW_ALL), "SANITIZE_ALL fails");
$this->assertEquals($val, Sanitize::sanitize($val, SANITIZE_ALLOW_ALLBUT), "SANITIZE_ALLBUT fails");
# Check 'a+Z09'
$val = 'a+Z09';
$this->assertEquals('', Sanitize::sanitize($val, SANITIZE_ALLOW_ALNUMX), "SANITIZE_ALNUMX fails");
$this->assertEquals('', Sanitize::sanitize($val, SANITIZE_ALLOW_DIGIT), "SANITIZE_DIGIT fails");
$this->assertEquals('', Sanitize::sanitize($val, SANITIZE_ALLOW_MIN_MAX, '-5|2'), "SANITIZE_MIN_MAX fails");
$this->assertEquals('', Sanitize::sanitize($val, SANITIZE_ALLOW_EMAIL), "SANITIZE_EMAIL fails");
$this->assertEquals('!!alnumx!!', Sanitize::sanitize($val, SANITIZE_ALLOW_ALNUMX), "SANITIZE_ALNUMX fails");
$this->assertEquals('!!digit!!', Sanitize::sanitize($val, SANITIZE_ALLOW_DIGIT), "SANITIZE_DIGIT fails");
$this->assertEquals('!!min|max!!', Sanitize::sanitize($val, SANITIZE_ALLOW_MIN_MAX, '-5|2'), "SANITIZE_MIN_MAX fails");
$this->assertEquals('!!email!!', Sanitize::sanitize($val, SANITIZE_ALLOW_EMAIL), "SANITIZE_EMAIL fails");
$this->assertEquals($val, Sanitize::sanitize($val, SANITIZE_ALLOW_PATTERN, '.*'), "SANITIZE_PATTERN fails");
$this->assertEquals($val, Sanitize::sanitize($val, SANITIZE_ALLOW_ALL), "SANITIZE_ALL fails");
$this->assertEquals($val, Sanitize::sanitize($val, SANITIZE_ALLOW_ALLBUT), "SANITIZE_ALLBUT fails");
......@@ -83,9 +83,9 @@ class SanitizeTest extends \PHPUnit_Framework_TestCase {
# Check 'ÀÈÌÒÙàèìòùÁÉÍÓÚÝáéíóúýÂÊÎÔÛâêîôûÃÑÕãñõÄËÏÖÜŸäëïöüÿ'
$val = 'ÀÈÌÒÙàèìòùÁÉÍÓÚÝáéíóúýÂÊÎÔÛâêîôûÃÑÕãñõÄËÏÖÜŸäëïöüÿ';
$this->assertEquals($val, Sanitize::sanitize($val, SANITIZE_ALLOW_ALNUMX), "SANITIZE_ALNUMX fails");
$this->assertEquals('', Sanitize::sanitize($val, SANITIZE_ALLOW_DIGIT), "SANITIZE_DIGIT fails");
$this->assertEquals('', Sanitize::sanitize($val, SANITIZE_ALLOW_MIN_MAX, '-5|2'), "SANITIZE_MIN_MAX fails");
$this->assertEquals('', Sanitize::sanitize($val, SANITIZE_ALLOW_EMAIL), "SANITIZE_EMAIL fails");
$this->assertEquals('!!digit!!', Sanitize::sanitize($val, SANITIZE_ALLOW_DIGIT), "SANITIZE_DIGIT fails");
$this->assertEquals('!!min|max!!', Sanitize::sanitize($val, SANITIZE_ALLOW_MIN_MAX, '-5|2'), "SANITIZE_MIN_MAX fails");
$this->assertEquals('!!email!!', Sanitize::sanitize($val, SANITIZE_ALLOW_EMAIL), "SANITIZE_EMAIL fails");
$this->assertEquals($val, Sanitize::sanitize($val, SANITIZE_ALLOW_PATTERN, '.*'), "SANITIZE_PATTERN fails");
$this->assertEquals($val, Sanitize::sanitize($val, SANITIZE_ALLOW_ALL), "SANITIZE_ALL fails");
$this->assertEquals($val, Sanitize::sanitize($val, SANITIZE_ALLOW_ALLBUT), "SANITIZE_ALLBUT fails");
......@@ -100,11 +100,11 @@ class SanitizeTest extends \PHPUnit_Framework_TestCase {
# Check min|max
$val = 56;
$this->assertEquals('', Sanitize::sanitize($val, SANITIZE_ALLOW_MIN_MAX, '0|2'), "SANITIZE_MIN_MAX fails");
$this->assertEquals('!!min|max!!', Sanitize::sanitize($val, SANITIZE_ALLOW_MIN_MAX, '0|2'), "SANITIZE_MIN_MAX fails");
$this->assertEquals($val, Sanitize::sanitize($val, SANITIZE_ALLOW_MIN_MAX, '0|200'), "SANITIZE_MIN_MAX fails");
$this->assertEquals($val, Sanitize::sanitize($val, SANITIZE_ALLOW_MIN_MAX, '-100|200'), "SANITIZE_MIN_MAX fails");
$val = -56;
$this->assertEquals('', Sanitize::sanitize($val, SANITIZE_ALLOW_MIN_MAX, '0|2'), "SANITIZE_MIN_MAX fails");
$this->assertEquals('!!min|max!!', Sanitize::sanitize($val, SANITIZE_ALLOW_MIN_MAX, '0|2'), "SANITIZE_MIN_MAX fails");
$this->assertEquals($val, Sanitize::sanitize($val, SANITIZE_ALLOW_MIN_MAX, '-100|0'), "SANITIZE_MIN_MAX fails");
$this->assertEquals($val, Sanitize::sanitize($val, SANITIZE_ALLOW_MIN_MAX, '-100|200'), "SANITIZE_MIN_MAX fails");
}
......@@ -117,26 +117,26 @@ class SanitizeTest extends \PHPUnit_Framework_TestCase {
# Check min|max
$val = '15.04.2016';
$this->assertEquals('', Sanitize::sanitize($val, SANITIZE_ALLOW_MIN_MAX_DATE, '01.06.2016|31.12.2016'), "SANITIZE_ALLOW_MIN_MAX_DATE fails");
$this->assertEquals('', Sanitize::sanitize($val, SANITIZE_ALLOW_MIN_MAX_DATE, '01.01.2016|31.01.2016'), "SANITIZE_ALLOW_MIN_MAX_DATE fails");
$this->assertEquals('!!min|max date!!', Sanitize::sanitize($val, SANITIZE_ALLOW_MIN_MAX_DATE, '01.06.2016|31.12.2016'), "SANITIZE_ALLOW_MIN_MAX_DATE fails");
$this->assertEquals('!!min|max date!!', Sanitize::sanitize($val, SANITIZE_ALLOW_MIN_MAX_DATE, '01.01.2016|31.01.2016'), "SANITIZE_ALLOW_MIN_MAX_DATE fails");
$this->assertEquals($val, Sanitize::sanitize($val, SANITIZE_ALLOW_MIN_MAX_DATE, '01.01.2016|31.12.2016'), "SANITIZE_ALLOW_MIN_MAX_DATE fails");
# Check min|max
$val = '15.04.16';
$this->assertEquals('', Sanitize::sanitize($val, SANITIZE_ALLOW_MIN_MAX_DATE, '01.06.16|31.12.16'), "SANITIZE_ALLOW_MIN_MAX_DATE fails");
$this->assertEquals('', Sanitize::sanitize($val, SANITIZE_ALLOW_MIN_MAX_DATE, '01.01.16|31.01.16'), "SANITIZE_ALLOW_MIN_MAX_DATE fails");
$this->assertEquals('!!min|max date!!', Sanitize::sanitize($val, SANITIZE_ALLOW_MIN_MAX_DATE, '01.06.16|31.12.16'), "SANITIZE_ALLOW_MIN_MAX_DATE fails");
$this->assertEquals('!!min|max date!!', Sanitize::sanitize($val, SANITIZE_ALLOW_MIN_MAX_DATE, '01.01.16|31.01.16'), "SANITIZE_ALLOW_MIN_MAX_DATE fails");
$this->assertEquals($val, Sanitize::sanitize($val, SANITIZE_ALLOW_MIN_MAX_DATE, '01.01.16|31.12.16'), "SANITIZE_ALLOW_MIN_MAX_DATE fails");
# Check min|max
$val = '15.4.16';
$this->assertEquals('', Sanitize::sanitize($val, SANITIZE_ALLOW_MIN_MAX_DATE, '1.6.16|31.12.16'), "SANITIZE_ALLOW_MIN_MAX_DATE fails");
$this->assertEquals('', Sanitize::sanitize($val, SANITIZE_ALLOW_MIN_MAX_DATE, '1.1.16|31.1.16'), "SANITIZE_ALLOW_MIN_MAX_DATE fails");
$this->assertEquals('!!min|max date!!', Sanitize::sanitize($val, SANITIZE_ALLOW_MIN_MAX_DATE, '1.6.16|31.12.16'), "SANITIZE_ALLOW_MIN_MAX_DATE fails");
$this->assertEquals('!!min|max date!!', Sanitize::sanitize($val, SANITIZE_ALLOW_MIN_MAX_DATE, '1.1.16|31.1.16'), "SANITIZE_ALLOW_MIN_MAX_DATE fails");
$this->assertEquals($val, Sanitize::sanitize($val, SANITIZE_ALLOW_MIN_MAX_DATE, '1.1.16|31.12.16'), "SANITIZE_ALLOW_MIN_MAX_DATE fails");
# Check min|max
$val = '15.4.16';
$this->assertEquals('', Sanitize::sanitize($val, SANITIZE_ALLOW_MIN_MAX_DATE, '01.06.2016|31.12.2016'), "SANITIZE_ALLOW_MIN_MAX_DATE fails");
$this->assertEquals('', Sanitize::sanitize($val, SANITIZE_ALLOW_MIN_MAX_DATE, '01.01.2016|31.01.2016'), "SANITIZE_ALLOW_MIN_MAX_DATE fails");
$this->assertEquals('!!min|max date!!', Sanitize::sanitize($val, SANITIZE_ALLOW_MIN_MAX_DATE, '01.06.2016|31.12.2016'), "SANITIZE_ALLOW_MIN_MAX_DATE fails");
$this->assertEquals('!!min|max date!!', Sanitize::sanitize($val, SANITIZE_ALLOW_MIN_MAX_DATE, '01.01.2016|31.01.2016'), "SANITIZE_ALLOW_MIN_MAX_DATE fails");
$this->assertEquals($val, Sanitize::sanitize($val, SANITIZE_ALLOW_MIN_MAX_DATE, '01.01.2016|31.12.2016'), "SANITIZE_ALLOW_MIN_MAX_DATE fails");
}
......@@ -149,37 +149,37 @@ class SanitizeTest extends \PHPUnit_Framework_TestCase {
# Check
$val = 'john';
$this->assertEquals('', Sanitize::sanitize($val, SANITIZE_ALLOW_EMAIL), "SANITIZE_ALLOW_EMAIL fails");
$this->assertEquals('!!email!!', Sanitize::sanitize($val, SANITIZE_ALLOW_EMAIL), "SANITIZE_ALLOW_EMAIL fails");
$val = 'john@';
$this->assertEquals('', Sanitize::sanitize($val, SANITIZE_ALLOW_EMAIL), "SANITIZE_ALLOW_EMAIL fails");
$this->assertEquals('!!email!!', Sanitize::sanitize($val, SANITIZE_ALLOW_EMAIL), "SANITIZE_ALLOW_EMAIL fails");
$val = 'john@doe';
$this->assertEquals('', Sanitize::sanitize($val, SANITIZE_ALLOW_EMAIL), "SANITIZE_ALLOW_EMAIL fails");
$this->assertEquals('!!email!!', Sanitize::sanitize($val, SANITIZE_ALLOW_EMAIL), "SANITIZE_ALLOW_EMAIL fails");
$val = 'john@doe.com';
$this->assertEquals($val, Sanitize::sanitize($val, SANITIZE_ALLOW_EMAIL), "SANITIZE_ALLOW_EMAIL fails");
$val = 'john@ doe.com';
$this->assertEquals('', Sanitize::sanitize($val, SANITIZE_ALLOW_EMAIL), "SANITIZE_ALLOW_EMAIL fails");
$this->assertEquals('!!email!!', Sanitize::sanitize($val, SANITIZE_ALLOW_EMAIL), "SANITIZE_ALLOW_EMAIL fails");
$val = '<john@doe.com>';
$this->assertEquals('', Sanitize::sanitize($val, SANITIZE_ALLOW_EMAIL), "SANITIZE_ALLOW_EMAIL fails");
$this->assertEquals('!!email!!', Sanitize::sanitize($val, SANITIZE_ALLOW_EMAIL), "SANITIZE_ALLOW_EMAIL fails");
$val = 'John Doe <john@doe.com>';
$this->assertEquals('', Sanitize::sanitize($val, SANITIZE_ALLOW_EMAIL), "SANITIZE_ALLOW_EMAIL fails");
$this->assertEquals('!!email!!', Sanitize::sanitize($val, SANITIZE_ALLOW_EMAIL), "SANITIZE_ALLOW_EMAIL fails");
$val = '_john@doe.com';
$this->assertEquals($val, Sanitize::sanitize($val, SANITIZE_ALLOW_EMAIL), "SANITIZE_ALLOW_EMAIL fails");
$val = 'jo*hn@doe.com';
$this->assertEquals('', Sanitize::sanitize($val, SANITIZE_ALLOW_EMAIL), "SANITIZE_ALLOW_EMAIL fails");
$this->assertEquals('!!email!!', Sanitize::sanitize($val, SANITIZE_ALLOW_EMAIL), "SANITIZE_ALLOW_EMAIL fails");
$val = 'jo[hn@doe.com';
$this->assertEquals('', Sanitize::sanitize($val, SANITIZE_ALLOW_EMAIL), "SANITIZE_ALLOW_EMAIL fails");
$this->assertEquals('!!email!!', Sanitize::sanitize($val, SANITIZE_ALLOW_EMAIL), "SANITIZE_ALLOW_EMAIL fails");
$val = 'jo\hn@doe.com';
$this->assertEquals('', Sanitize::sanitize($val, SANITIZE_ALLOW_EMAIL), "SANITIZE_ALLOW_EMAIL fails");
$this->assertEquals('!!email!!', Sanitize::sanitize($val, SANITIZE_ALLOW_EMAIL), "SANITIZE_ALLOW_EMAIL fails");
$val = 'jo%hn@doe.com';
$this->assertEquals('jo%hn@doe.com', Sanitize::sanitize($val, SANITIZE_ALLOW_EMAIL), "SANITIZE_ALLOW_EMAIL fails");
......@@ -193,8 +193,8 @@ class SanitizeTest extends \PHPUnit_Framework_TestCase {
# Check
$val = 'john';
$this->assertEquals('', Sanitize::sanitize($val, SANITIZE_ALLOW_PATTERN, '\d'), "SANITIZE_ALLOW_PATTERN fails");
$this->assertEquals('', Sanitize::sanitize($val, SANITIZE_ALLOW_PATTERN, '\s'), "SANITIZE_ALLOW_PATTERN fails");
$this->assertEquals('!!pattern!!', Sanitize::sanitize($val, SANITIZE_ALLOW_PATTERN, '\d'), "SANITIZE_ALLOW_PATTERN fails");
$this->assertEquals('!!pattern!!', Sanitize::sanitize($val, SANITIZE_ALLOW_PATTERN, '\s'), "SANITIZE_ALLOW_PATTERN fails");
$this->assertEquals($val, Sanitize::sanitize($val, SANITIZE_ALLOW_PATTERN, 'john'), "SANITIZE_ALLOW_PATTERN fails");
$this->assertEquals($val, Sanitize::sanitize($val, SANITIZE_ALLOW_PATTERN, '(john)?'), "SANITIZE_ALLOW_PATTERN fails");
$this->assertEquals($val, Sanitize::sanitize($val, SANITIZE_ALLOW_PATTERN, '(john)*'), "SANITIZE_ALLOW_PATTERN fails");
......@@ -209,13 +209,13 @@ class SanitizeTest extends \PHPUnit_Framework_TestCase {
$good = 'abCD01`~!@$^*()_+=-|":;.,<>/?\'';
// Single
$this->assertEquals('', Sanitize::sanitize('[', SANITIZE_ALLOW_ALLBUT), "SANITIZE_ALLOW_ALLBUT fails");
$this->assertEquals('!!allbut!!', Sanitize::sanitize('[', SANITIZE_ALLOW_ALLBUT), "SANITIZE_ALLOW_ALLBUT fails");
$this->assertEquals('a', Sanitize::sanitize('a', SANITIZE_ALLOW_ALLBUT), "SANITIZE_ALLOW_ALLBUT fails");
for ($i = 0; $i < strlen($bad); $i++) {
$str = '-' . substr($bad, $i, 1) . '-';
$this->assertEquals('', Sanitize::sanitize($str, SANITIZE_ALLOW_ALLBUT), "SANITIZE_ALLOW_ALLBUT fails");
$this->assertEquals('!!allbut!!', Sanitize::sanitize($str, SANITIZE_ALLOW_ALLBUT), "SANITIZE_ALLOW_ALLBUT fails");
}
for ($i = 0; $i < strlen($good); $i++) {
......
......@@ -110,7 +110,7 @@ class StoreTest extends \PHPUnit_Framework_TestCase {
$this->assertFalse($this->store->getVar('keyUnknown2', STORE_CLIENT), "Param: unknown from cache");
// Test overwrite default sanitize class
$this->assertEquals('', $this->store->getVar(CLIENT_FORM, STORE_CLIENT, SANITIZE_ALLOW_DIGIT), "Param: overwrite default sanitize class");
$this->assertEquals('!!digit!!', $this->store->getVar(CLIENT_FORM, STORE_CLIENT, SANITIZE_ALLOW_DIGIT), "Param: overwrite default sanitize class");
// Test: POST higher priority than GET
$this->assertEquals('5678', $this->store->getVar('key04', STORE_CLIENT), "Param: POST higher priority than GET");
......@@ -143,7 +143,7 @@ class StoreTest extends \PHPUnit_Framework_TestCase {
$this->assertEquals('apple', $this->store->getVar('fruit'), "Retrieve 'fruit' from STORE_RECORD");
$this->store->setVar('color', 'green', STORE_FORM);
$this->assertEquals(false, $this->store->getVar('color'), "Retrieve 'color' from STORE_FORM");
$this->assertEquals('!!digit!!', $this->store->getVar('color'), "Retrieve 'color' from STORE_FORM");
$this->assertEquals('green', $this->store->getVar('color', '', SANITIZE_ALLOW_ALNUMX), "Retrieve 'color' from STORE_FORM");
}
......
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