예제 #1
0
 public function testBaseDecode()
 {
     $test1 = 1;
     $test2 = 2;
     $this->assertEquals($test1, StringUtils::baseEncode($test1));
     $this->assertEquals($test2, StringUtils::baseEncode($test2));
 }
예제 #2
0
    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));
    }
예제 #3
0
    public function testBasicNl2Br()
    {
        $test = <<<ST
Ana are
mere.
ST;
        $this->assertEquals(nl2br($test), StringUtils::br2nl(nl2br($test)));
    }
예제 #4
0
 public function testWTF()
 {
     $test = 'test';
     $times = 3;
     ob_start();
     StringUtils::_echo($test, $times);
     $output = ob_end_clean();
     $this->assertEquals(strlen($test) * $times, $output);
 }
예제 #5
0
 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));
 }
예제 #6
0
    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>'));
    }
예제 #7
0
 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));
 }
예제 #8
0
파일: model.php 프로젝트: bogdananton/vsc
/* @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";
}
예제 #9
0
파일: vsc.php 프로젝트: bogdananton/vsc
 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;
     }
 }
예제 #10
0
 public function testBasicStripEntities()
 {
     $test = 'test';
     $this->assertEquals(htmlentities($test), StringUtils::stripEntities($test));
 }
예제 #11
0
 public function testReplaceAmpersands()
 {
     $test = 'ana&gigel';
     $this->assertEquals(str_replace('&', '&amp;', $test), StringUtils::formatUri($test));
 }
예제 #12
0
파일: content.php 프로젝트: bogdananton/vsc
<?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) {
예제 #13
0
 public function testUseless()
 {
     $sString = 'ana are mere gigel <a /> ';
     $this->assertEquals(htmlentities($sString, ENT_QUOTES, 'UTF-8'), StringUtils::encodeEntities($sString));
 }
예제 #14
0
파일: nlTest.php 프로젝트: bogdananton/vsc
 public function testBasicNl()
 {
     $this->assertEquals("\n", StringUtils::nl());
 }