Php vfsStream是否允许取消空目录的链接?
我的单元测试尝试删除一个空目录。被测试的类使用unlink(先前测试的结果)。如果我在没有vfstream的情况下编写相同的代码,则无法删除空目录 单元测试:Php vfsStream是否允许取消空目录的链接?,php,unit-testing,phpunit,unlink,rmdir,Php,Unit Testing,Phpunit,Unlink,Rmdir,我的单元测试尝试删除一个空目录。被测试的类使用unlink(先前测试的结果)。如果我在没有vfstream的情况下编写相同的代码,则无法删除空目录 单元测试: require 'vfsStream/vfsStream.php'; require '../Classes/Recursive/Delete.php'; class Recursive_Delete_Test extends PHPUnit_Framework_TestCase { // More tests! pub
require 'vfsStream/vfsStream.php';
require '../Classes/Recursive/Delete.php';
class Recursive_Delete_Test extends PHPUnit_Framework_TestCase {
// More tests!
public function testShouldRemoveAnEmptyDirectory()
{
vfsStream::setup();
vfsStreamWrapper::getRoot()->addChild(vfsStream::newDirectory('dir'));
$recursiveDelete = new Recursive_Delete(vfsStream::url('root/dir'));
$recursiveDelete->delete();
$this->assertFileNotExists(vfsStream::url('root/dir'));
}
}
生产代码:
是虫子还是我遗漏了什么?
谢谢。这是vfstream 0.10.0版本中的一个bug,它允许对目录取消链接()。该漏洞在即将发布的0.11.0版中已修复,请参阅。现在,如果在目录上应用了
unlink()
,将抛出一个警告。这是vfstream 0.10.0版本中的一个错误,它允许在目录上使用unlink()
。该漏洞在即将发布的0.11.0版中已修复,请参阅。现在,如果在目录上应用了unlink()
,将抛出一个警告
class Recursive_Delete
{
private $_file;
public function __construct($file)
{
$this->_file = $file;
}
public function delete()
{
unlink($this->_file);
}
}