bovigo / vfsStream

vfsStream is a stream wrapper for a virtual file system that may be helpful in unit tests to mock the real file system. It can be used with any unit test framework, like PHPUnit or SimpleTest.
BSD 3-Clause "New" or "Revised" License
1.42k stars 102 forks source link

Directory should not be allowed to move to itself #255

Open mvorisek opened 3 years ago

mvorisek commented 3 years ago

Code to reproduce:

use org\bovigo\vfs\vfsStream;

$root = vfsStream::setup('x');

var_dump($root->url());
// var_dump(unlink($root->url())); // exception is thrown - correct: Operation not permitted
// var_dump(rename($root->url(), $root->url() . '/a/a')); // exception is thrown - correct: No such file or directory
var_dump(rename($root->url(), $root->url() . '/b')); // no exception, but it is wrong - directory can not be moved to itself
var_dump($root->url());
var_dump(is_dir($root->url()));

Current output:

string(7) "vfs://x"
bool(true)
string(9) "vfs://b/b"
bool(false)

Expected output:

string(7) "vfs://x"
exception