EclipseReporter::escapeVal PHP Метод

escapeVal() публичный статический Метод

C style escaping.
public static escapeVal ( string $raw ) : string
$raw string String with backslashes, quotes and whitespace.
Результат string Replaced with C backslashed tokens.
    public static function escapeVal($raw)
    {
        $needle = array('\\', '"', '/', "\\b", "\f", "\n", "\r", "\t");
        $replace = array('\\\\', '\\"', '\\/', '\\b', '\\f', '\\n', '\\r', '\\t');
        return str_replace($needle, $replace, $raw);
    }

Usage Example

Пример #1
0
 function testPass()
 {
     $listener =& new MockSimpleSocket();
     $fullpath = realpath(dirname(__FILE__) . '/support/test1.php');
     $testpath = EclipseReporter::escapeVal($fullpath);
     $expected = "{status:\"pass\",message:\"pass1 at [{$testpath} line 4]\",group:\"{$testpath}\",case:\"test1\",method:\"test_pass\"}";
     //this should work...but it doesn't so the next line and the last line are the hacks
     //$listener->expectOnce('write',array($expected));
     $listener->setReturnValue('write', -1);
     $pathparts = pathinfo($fullpath);
     $filename = $pathparts['basename'];
     $test =& new TestSuite($filename);
     $test->addTestFile($fullpath);
     $test->run(new EclipseReporter(&$listener));
     $this->assertEqual($expected, $listener->output);
 }
All Usage Examples Of EclipseReporter::escapeVal