mageekguy\atoum\mock\stream::setDirectorySeparator PHP Method

setDirectorySeparator() public static method

public static setDirectorySeparator ( $stream, $directorySeparator = DIRECTORY_SEPARATOR )
    public static function setDirectorySeparator($stream, $directorySeparator = DIRECTORY_SEPARATOR)
    {
        $path = str_replace($directorySeparator == '/' ? '\\' : '/', $directorySeparator, preg_replace('#^[^:]+://#', '', $stream));
        return substr($stream, 0, strlen($stream) - strlen($path)) . $path;
    }

Usage Example

Exemplo n.º 1
0
 public function testSetDirectorySeparator()
 {
     $this->string(mock\stream::setDirectorySeparator('foo/bar', '/'))->isEqualTo('foo/bar')->string(mock\stream::setDirectorySeparator('foo\\bar', '/'))->isEqualTo('foo/bar')->string(mock\stream::setDirectorySeparator('foo/bar', '\\'))->isEqualTo('foo\\bar')->string(mock\stream::setDirectorySeparator('foo\\bar', '\\'))->isEqualTo('foo\\bar')->string(mock\stream::setDirectorySeparator('foo' . DIRECTORY_SEPARATOR . 'bar'))->isEqualTo('foo' . DIRECTORY_SEPARATOR . 'bar')->string(mock\stream::setDirectorySeparator('foo' . (DIRECTORY_SEPARATOR == '/' ? '\\' : '/') . 'bar'))->isEqualTo('foo' . DIRECTORY_SEPARATOR . 'bar');
 }