From 4804da2b6205360d733e63ae41d28abc7f348ae2 Mon Sep 17 00:00:00 2001 From: Cameron Date: Fri, 1 Mar 2019 16:35:15 -0800 Subject: [PATCH] test for toDB(); --- tests/unit/e_formTest.php | 2 +- tests/unit/e_parseTest.php | 98 ++++++++++++++++++++++++++++++++++++-- 2 files changed, 95 insertions(+), 5 deletions(-) diff --git a/tests/unit/e_formTest.php b/tests/unit/e_formTest.php index 9ca7a527c..be4e212a9 100644 --- a/tests/unit/e_formTest.php +++ b/tests/unit/e_formTest.php @@ -516,7 +516,7 @@ class e_formTest extends \Codeception\Test\Unit 2 => array('value' => '0', 'default'=>null, 'options'=>'nobody,public,main,admin,member,no-excludes', 'expected' => "value='0' selected"), 3 => array('value' => null, 'default'=>null, 'options'=>'nobody,public,main,admin,member,no-excludes', 'expected' => "value='255' selected"), 4 => array('value' => null, 'default'=>254, 'options'=>'nobody,public,main,admin,member,no-excludes', 'expected' => "value='254' selected"), - + 5 => array('value' => '', 'default'=>254, 'options'=>'nobody,public,main,admin,member,no-excludes', 'expected' => "value='254' selected"), ); foreach($tests as $var) diff --git a/tests/unit/e_parseTest.php b/tests/unit/e_parseTest.php index e4c245cc3..635f33d1a 100644 --- a/tests/unit/e_parseTest.php +++ b/tests/unit/e_parseTest.php @@ -240,12 +240,90 @@ TMP; { } - +*/ public function testToDB() { - } + $tests = array( + 0 => array( + 'input' => " '' + ), + 1 => array( + 'input' => "some plain text with a\nline break", + 'expected' => "some plain text with a\nline break" + ), + 2 => array( + 'input' => "some [b]text[/b] with bbcodes", + 'expected' => "some [b]text[/b] with bbcodes" + ), + 3 => array( + 'input' => 'some "quoted text" with a $ sign', + 'expected' => "some "quoted text" with a $ sign" + ), + 4 => array( + 'input' => 'some
simple html
link', + 'expected' => 'some
simple html
link' + ), + 5 => array( + 'input' => "[img]http://something.com[/img]", + 'expected' => "[img]http://something.com[/img]" + ), + 6 => array( + 'input' => "

日本語 简体中文

", + 'expected' => "

日本語 简体中文

" + ), + 7 => array( + 'input' => "", + 'expected' => "" // stripped xss + ), + 8 => array( + 'input' => '
Hi there
', + 'expected' => "
Hi there
" + ), + 9 => array( + 'input' => '', + 'expected' => "" + ), + 10 => array( + 'input' => '
', + 'expected' => '
'), + 11 => array( + 'input' => 'Test', + 'expected' => 'Test' + ), + 12 => array( + 'input' => "From here > to there", + 'expected' => "From here > to there" + ), + 13 => array( + 'input' => "[html]
Hello World!
[/html]", + 'expected' => '[html]
Hello World!
[/html]' + ), + 14 => array( + 'input' => "Something & something", + 'expected' => 'Something & something' + ), + ); + + foreach($tests as $var) + { + if(empty($var['input'])) + { + continue; + } + + $result = $this->tp->toDB($var['input']); + $this->assertEquals($var['expected'], $result); + // var_dump($result); + } + + + + + } +/* public function testHtml_truncate_old() { @@ -698,12 +776,24 @@ TMP; { } - +*/ public function testCleanHtml() { + $tests = array( + 0 => array('html' => " ''), + + + ); + + foreach($tests as $var) + { + $result = $this->tp->cleanHtml($var['html']); + var_dump($result); + } + } - +/* public function testSecureAttributeValue() {