public function testBaseDecode() { $test1 = 1; $test2 = 2; $this->assertEquals($test1, StringUtils::baseEncode($test1)); $this->assertEquals($test2, StringUtils::baseEncode($test2)); }
public function testBasicStripTags() { $test = <<<START <div>Lorem <span>ipsum</span> dolor <a href="test">sic</a> amet.</div> START; $this->assertEquals(strip_tags($test), StringUtils::stripTags($test)); $this->assertEquals('Lorem ipsum dolor sic amet.', StringUtils::stripTags($test)); }
public function testBasicNl2Br() { $test = <<<ST Ana are mere. ST; $this->assertEquals(nl2br($test), StringUtils::br2nl(nl2br($test))); }
public function testWTF() { $test = 'test'; $times = 3; ob_start(); StringUtils::_echo($test, $times); $output = ob_end_clean(); $this->assertEquals(strlen($test) * $times, $output); }
public function testBasicTruncate() { $string = 'test'; $this->assertEquals('t...', StringUtils::truncate($string, 1)); $this->assertEquals('te...', StringUtils::truncate($string, 2)); $this->assertEquals('tes...', StringUtils::truncate($string, 3)); $this->assertEquals('test', StringUtils::truncate($string, 4)); $this->assertEquals('test', StringUtils::truncate($string, 5)); }
public function testBasicStripScriptTags() { $test = <<<START <div>Lorem <span>ipsum</span> dolor <a href="test">sic</a> amet.</div> <script>alert('bitch');</script> START; $this->assertFalse(stristr(StringUtils::stripScriptTags($test), 'bitch')); $this->assertFalse(stristr(StringUtils::stripScriptTags($test), 'alert')); $this->assertFalse(stristr(StringUtils::stripScriptTags($test), '<script>alert(\'bitch\');</script>')); }
public function testBasicAllTrim() { $test = 'ana are mere'; $spaces = sprintf(' %s ', $test); $tabs = sprintf("\t\t%s\t\t\t", $test); $newlines = sprintf("\n\n%s\r\n\r\r", $test); $mixed = sprintf("\n\t \n \r \t%s\r\n \r\t\r", $test); $this->assertEquals($test, StringUtils::allTrim($spaces)); $this->assertEquals($test, StringUtils::allTrim($tabs)); $this->assertEquals($test, StringUtils::allTrim($newlines)); $this->assertEquals($test, StringUtils::allTrim($mixed)); }
/* @var $this \vsc\presentation\views\JsonView */ $aArray = $model->toArray(); $mEnd = end($aArray); $sEndKey = key($aArray); foreach ($aArray as $sName => $mValue) { if (is_scalar($mValue)) { StringUtils::_echo("\t", $GLOBALS['depth']); if (!is_int($sName)) { echo '"' . $sName . '": '; } echo '"' . StringUtils::stripEntities(str_replace('"', '\\"', $mValue)) . '"' . ($sName != $sEndKey ? ',' : '') . "\n"; continue; } elseif (is_array($mValue)) { $mValue = new ArrayModel($mValue); } if (ModelA::isValid($mValue)) { $this->setModel($mValue); StringUtils::_echo("\t", $GLOBALS['depth']); echo '"' . $sName . '": '; echo '{' . "\n"; $GLOBALS['depth']++; echo $this->fetch(__FILE__); StringUtils::_echo("\t", $GLOBALS['depth'] - 1); echo '}' . ($sName != $sEndKey && $mEnd != $mValue ? ',' : '') . "\n"; $GLOBALS['depth']--; continue; } StringUtils::_echo("\t", $GLOBALS['depth']); echo '"' . $sName . '" : '; echo '"' . var_export($mValue, true) . '"' . ($sName != $sEndKey ? ',' : '') . "\n"; }
public static function d() { $aRgs = func_get_args(); $output = ''; for ($i = 0; $i < ob_get_level(); $i++) { // cleaning the buffers ob_end_clean(); } if (!self::isCLi() && self::getEnv()->getHttpRequest()->accepts('application/json')) { $output = json_encode($aRgs); } elseif (self::isCLi() || self::getEnv()->getHttpRequest()->accepts('text/html')) { foreach ($aRgs as $object) { ob_start(); var_dump($object); $output .= ob_get_clean(); if (!self::isCli()) { $output .= '<hr/>' . "\n"; } } } if (!stristr($_SERVER['PHP_SELF'], 'phpunit')) { ob_start(); debug_print_backtrace(); $output .= ob_get_clean(); if (self::isCLi() || self::getEnv()->getHttpRequest()->accepts('application/json')) { echo StringUtils::stripTags(StringUtils::br2nl($output)); } elseif (self::getEnv()->getHttpRequest()->accepts('text/html')) { echo '<pre>' . $output . '</pre>'; } else { echo StringUtils::stripTags(StringUtils::br2nl($output)); } exit; } else { return $output; } }
public function testBasicStripEntities() { $test = 'test'; $this->assertEquals(htmlentities($test), StringUtils::stripEntities($test)); }
public function testReplaceAmpersands() { $test = 'ana&gigel'; $this->assertEquals(str_replace('&', '&', $test), StringUtils::formatUri($test)); }
<?php use vsc\infrastructure\StringUtils; use vsc\infrastructure\vsc; use vsc\Exception; /* @var $this \vsc\presentation\views\PlainTextView */ ?> Default TXT template This is the default txt template from the <?php echo StringUtils::stripTags(vsc::name()); ?> framework. In order to add content, you need to: - add the <?php echo $this->getViewFolder(); ?> folder in your module's template folder: <?php echo $this->getMap()->getTemplatePath(); ?> - add the default template <?php echo $this->getTemplate(); ?> These settings are defined in one of the following files: <?php foreach (get_included_files() as $sFileName) {
public function testUseless() { $sString = 'ana are mere gigel <a /> '; $this->assertEquals(htmlentities($sString, ENT_QUOTES, 'UTF-8'), StringUtils::encodeEntities($sString)); }
public function testBasicNl() { $this->assertEquals("\n", StringUtils::nl()); }