|
|
@@ -75,7 +75,30 @@ class FormatHelperTest extends MyCakeTestCase {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-
|
|
|
+ public function testPriorityIcon() {
|
|
|
+ $values = array(
|
|
|
+ array(1, array(), '<div class="prio-low" title="prioLow"> </div>'),
|
|
|
+ array(2, array(), '<div class="prio-lower" title="prioLower"> </div>'),
|
|
|
+ array(3, array(), ''),
|
|
|
+ array(3, array('normal' => true), '<div class="prio-normal" title="prioNormal"> </div>'),
|
|
|
+ array(4, array(), '<div class="prio-higher" title="prioHigher"> </div>'),
|
|
|
+ array(5, array(), '<div class="prio-high" title="prioHigh"> </div>'),
|
|
|
+ array(1, array('max' => 3), '<div class="prio-low" title="prioLow"> </div>'),
|
|
|
+ array(2, array('max' => 3), ''),
|
|
|
+ array(2, array('max' => 3, 'normal' => true), '<div class="prio-normal" title="prioNormal"> </div>'),
|
|
|
+ array(3, array('max' => 3), '<div class="prio-high" title="prioHigh"> </div>'),
|
|
|
+
|
|
|
+ array(0, array('max' => 3, 'map' => array(0 => 1, 1 => 2, 2 => 3)), '<div class="prio-low" title="prioLow"> </div>'),
|
|
|
+ array(1, array('max' => 3, 'map' => array(0 => 1, 1 => 2, 2 => 3)), ''),
|
|
|
+ array(2, array('max' => 3, 'map' => array(0 => 1, 1 => 2, 2 => 3)), '<div class="prio-high" title="prioHigh"> </div>'),
|
|
|
+ );
|
|
|
+ foreach ($values as $key => $value) {
|
|
|
+ $res = $this->Format->priorityIcon($value[0], $value[1]);
|
|
|
+ echo $key;
|
|
|
+ //debug($res, null, false); ob_flush();
|
|
|
+ $this->assertEquals($value[2], $res);
|
|
|
+ }
|
|
|
+ }
|
|
|
|
|
|
/**
|
|
|
* 2009-08-30 ms
|
|
|
@@ -101,16 +124,22 @@ class FormatHelperTest extends MyCakeTestCase {
|
|
|
*/
|
|
|
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))//--></SCRIPT>">\'><SCRIPT>alert(String.fromCharCode(88,83,83))</SCRIPT>'
|
|
|
+ 'dfssdfsdj sdkfj sdkfj ksdfj sdkf ksdfj ksdfjsd kfjsdk fjsdkfj ksdjf ksdf jsdsdf' => 'dfssdfsdj sdkfj sdkfj k…',
|
|
|
+ '122 jsdf sjdkf sdfj sdf' => '122 jsdf sjdkf sdfj sdf',
|
|
|
+ 'ddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddd' => 'ddddddddddddddddddddddd…',
|
|
|
+ 'dsfdsf hods hfoéfh oéfhoéfhoéfhoéfhoéfhiu oéfhoéfhdüf s' => 'dsfdsf hods hfoéfh oéfh…'
|
|
|
);
|
|
|
- foreach ($data as $key => $value) {
|
|
|
+ foreach ($data as $value => $expected) {
|
|
|
$res = $this->Format->truncate($value, 30);
|
|
|
|
|
|
- echo '\''.h($value).'\' becomes \''.$res.'\'';
|
|
|
- $this->assertTrue(!empty($res));
|
|
|
+ debug( '\''.h($value).'\' becomes \''.$res.'\'', null, false); ob_flush();
|
|
|
+
|
|
|
+ $res = $this->Format->truncate($value, 30, array('html' => true));
|
|
|
+
|
|
|
+ debug( '\''.h($value).'\' becomes \''.$res.'\'', null, false); ob_flush();
|
|
|
+
|
|
|
+ //$this->assertTrue(!empty($res));
|
|
|
+ $this->assertEquals($expected, $res);
|
|
|
}
|
|
|
|
|
|
}
|
|
|
@@ -128,7 +157,7 @@ class FormatHelperTest extends MyCakeTestCase {
|
|
|
$res = $this->Format->hideEmail($mail);
|
|
|
|
|
|
echo '\''.$mail.'\' becomes \''.$res.'\' - expected \''.$expected.'\'';
|
|
|
- $this->assertEquals($res, $expected);
|
|
|
+ $this->assertEquals($expected, $res);
|
|
|
}
|
|
|
|
|
|
}
|
|
|
@@ -140,17 +169,17 @@ class FormatHelperTest extends MyCakeTestCase {
|
|
|
*/
|
|
|
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))//--></SCRIPT>">\'><SCRIPT>alert(String.fromCharCode(88,83,83))</SCRIPT>'
|
|
|
+ 'dfssdfsdj sdkfj sdkfj ksdfj bitch ksdfj' => 'dfssdfsdj sdkfj sdkfj ksdfj ##### ksdfj',
|
|
|
+ '122 jsdf ficken Sjdkf sdfj sdf' => '122 jsdf ###### Sjdkf sdfj sdf',
|
|
|
+ '122 jsdf FICKEN sjdkf sdfjs sdf' => '122 jsdf ###### sjdkf sdfjs sdf',
|
|
|
+ 'dddddddddd ARSCH ddddddddddddd' => 'dddddddddd ##### ddddddddddddd',
|
|
|
+ //'\';alert(String.fromCharCode(88,83,83))//\';alert(String.fromCharCode(88,83,83))//";alert(String.fromCharCode(88,83,83))//\";alert(String.fromCharCode(88,83,83))//--></SCRIPT>">\'><SCRIPT>alert(String.fromCharCode(88,83,83))</SCRIPT>' => null
|
|
|
);
|
|
|
- foreach ($data as $key => $value) {
|
|
|
- $res = $this->Format->wordCensor($value, array('Arsch', 'Ficken'));
|
|
|
+ foreach ($data as $value => $expected) {
|
|
|
+ $res = $this->Format->wordCensor($value, array('Arsch', 'Ficken', 'Bitch'));
|
|
|
|
|
|
- echo '\''.h($value).'\' becomes \''.h($res).'\'';
|
|
|
- $this->assertTrue(!empty($res));
|
|
|
+ //debug('\''.h($value).'\' becomes \''.h($res).'\'', null, false); ob_flush();
|
|
|
+ $this->assertEquals($expected === null ? $value : $expected, $res);
|
|
|
}
|
|
|
|
|
|
}
|
|
|
@@ -162,16 +191,16 @@ class FormatHelperTest extends MyCakeTestCase {
|
|
|
/*
|
|
|
public function testReverseAscii() {
|
|
|
$is = $this->Format->reverseAscii('fés');
|
|
|
- $expected = 'fés';
|
|
|
+ $expected = 'fés';
|
|
|
$this->assertEquals($expected, $is);
|
|
|
|
|
|
|
|
|
$is = entDec('fés');
|
|
|
- $expected = 'fés';
|
|
|
+ $expected = 'fés';
|
|
|
$this->assertEquals($expected, $is);
|
|
|
|
|
|
$is = html_entity_decode('fés');
|
|
|
- $expected = 'fés';
|
|
|
+ $expected = 'fés';
|
|
|
$this->assertEquals($expected, $is);
|
|
|
|
|
|
#TODO: correct it + more
|
|
|
@@ -185,7 +214,7 @@ class FormatHelperTest extends MyCakeTestCase {
|
|
|
/*
|
|
|
public function testDecodeEntities() {
|
|
|
$is = $this->Format->decodeEntities('fés');
|
|
|
- $expected = 'fés';
|
|
|
+ $expected = 'fés';
|
|
|
$this->assertEquals($expected, $is);
|
|
|
|
|
|
}
|