Format = new FormatHelper(new View(null)); $this->Format->Html = new HtmlHelper(new View(null)); } /** * 2009-08-30 ms */ public function testDisabledLink() { $content = 'xyz'; $data = array( array(), array('class'=>'disabledLink', 'title'=>false), array('class'=>'helloClass', 'title'=>'helloTitle') ); foreach ($data as $key => $value) { $res = $this->Format->disabledLink($content, $value); echo ''.$res.' (\''.h($res).'\')'; $this->assertTrue(!empty($res)); } } /** * 2009-08-30 ms */ public function testWarning() { $content = 'xyz'; $data = array( true, false ); foreach ($data as $key => $value) { $res = $this->Format->warning($content.' '.(int)$value, $value); echo ''.$res.''; $this->assertTrue(!empty($res)); } } /** * 2009-08-30 ms */ public function testOk() { $content = 'xyz'; $data = array( true, false ); foreach ($data as $key => $value) { $res = $this->Format->ok($content.' '.(int)$value, $value); echo ''.$res.''; $this->assertTrue(!empty($res)); } } /** * 2009-08-30 ms */ public function testShortenText() { $data = array( 'dfssdfsdj sdkfj sdkfj ksdfj sdkf ksdfj ksdfjsd kfjsdk fjsdkfj ksdjf ksdf jsdsdf', '122 jsdf sjdkf sdfj sdf', 'ddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddd', '\';alert(String.fromCharCode(88,83,83))//\';alert(String.fromCharCode(88,83,83))//";alert(String.fromCharCode(88,83,83))//\";alert(String.fromCharCode(88,83,83))//-->">\'>' ); foreach ($data as $key => $value) { $res = $this->Format->shortenText($value, 30); echo '\''.h($value).'\' becomes \''.$res.'\''; $this->assertTrue(!empty($res)); } } /** * 2009-08-30 ms */ public function testTruncate() { $data = array( 'dfssdfsdj sdkfj sdkfj ksdfj sdkf ksdfj ksdfjsd kfjsdk fjsdkfj ksdjf ksdf jsdsdf', '122 jsdf sjdkf sdfj sdf', 'ddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddd', '\';alert(String.fromCharCode(88,83,83))//\';alert(String.fromCharCode(88,83,83))//";alert(String.fromCharCode(88,83,83))//\";alert(String.fromCharCode(88,83,83))//-->">\'>' ); foreach ($data as $key => $value) { $res = $this->Format->truncate($value, 30); echo '\''.h($value).'\' becomes \''.$res.'\''; $this->assertTrue(!empty($res)); } } /** * 2009-08-30 ms */ public function testHideEmail() { $mails = array( 'test@test.de' => 't..t@t..t.de', 'xx@yy.de' => 'x..x@y..y.de', 'erk-wf@ve-eeervdg.com' => 'e..f@v..g.com', ); foreach ($mails as $mail => $expected) { $res = $this->Format->hideEmail($mail); echo '\''.$mail.'\' becomes \''.$res.'\' - expected \''.$expected.'\''; $this->assertEquals($res, $expected); } } /** * 2009-08-30 ms */ public function testWordCensor() { $data = array( 'dfssdfsdj sdkfj sdkfj ksdfj arsch ksdfj ksdfjsd kfjsdk fjsdkfj ksdjf ksdf jsdsdf', '122 jsdf ficken Sjdkf sdfj sdf', '122 jsdf FICKEN sjdkf sdfj sdf', 'ddddddddddddddddddddddddd ARSCH dddddddddddddddddddddddddddddddddddddddddddddddddd', '\';alert(String.fromCharCode(88,83,83))//\';alert(String.fromCharCode(88,83,83))//";alert(String.fromCharCode(88,83,83))//\";alert(String.fromCharCode(88,83,83))//-->">\'>' ); foreach ($data as $key => $value) { $res = $this->Format->wordCensor($value, array('Arsch', 'Ficken')); echo '\''.h($value).'\' becomes \''.h($res).'\''; $this->assertTrue(!empty($res)); } } /** * 2009-03-11 ms */ /* public function testReverseAscii() { $is = $this->Format->reverseAscii('fés'); $expected = 'fés'; $this->assertEquals($expected, $is); $is = entDec('fés'); $expected = 'fés'; $this->assertEquals($expected, $is); $is = html_entity_decode('fés'); $expected = 'fés'; $this->assertEquals($expected, $is); #TODO: correct it + more } */ /** * 2009-03-11 ms */ /* public function testDecodeEntities() { $is = $this->Format->decodeEntities('fés'); $expected = 'fés'; $this->assertEquals($expected, $is); } */ public function testTab2space() { echo '
" . $text . ""; echo'becomes'; echo "
" . $this->Format->tab2space($text) . ""; } public function testArray2table() { echo '