phpunit不';如果调用不存在的函数,则不会产生错误
我正在努力学习phpunit,因为我在做一个项目,这个项目需要复制一些文件,所以我想我应该使用vfstream来模拟文件系统进行单元测试 事实证明,每当我包含并使用vfstreamwrapper类时,phpunit似乎并不关心调用不存在的函数或任何其他输出 下面的函数是我从一个示例中复制过来的,我将调用的第二个函数更改为我确定不存在的函数:phpunit不';如果调用不存在的函数,则不会产生错误,phpunit,Phpunit,我正在努力学习phpunit,因为我在做一个项目,这个项目需要复制一些文件,所以我想我应该使用vfstream来模拟文件系统进行单元测试 事实证明,每当我包含并使用vfstreamwrapper类时,phpunit似乎并不关心调用不存在的函数或任何其他输出 下面的函数是我从一个示例中复制过来的,我将调用的第二个函数更改为我确定不存在的函数: protected function setUp() { vfsStreamWrapper::register(); vfsStreamWr
protected function setUp()
{
vfsStreamWrapper::register();
vfsStreamWrapper::yowkes(array('Core' => array('AbstractFactory' => array('test.php' => 'some text content',
'other.php' => 'Some more text content',
'Invalid.csv' => 'Something else',
),
'AnEmptyFolder' => array(),
'badlocation.php' => 'some bad content',
)
));
}
phpunit只打印以下输出:
塞巴斯蒂安·伯格曼的PHPUnit 3.7.21
我正在vragant盒上通过ssh从终端运行phpunit
感谢您的帮助
编辑:
你们有实际的测试吗?我的意思是,除了setUp()函数是的,我有一个测试,我试过这个,有没有实际的测试(一个应该通过,一个应该失败),但结果还是一样的,没有输出或错误提示您可以显示更多代码吗?我编辑了问题并添加了实际测试代码的一个版本
phpunit所做的就是打印以下输出:…
这真的是所有的输出吗?
public function testFilesAreCopiedCorrectly() {
$remoteDirectory = 'files/remoteFiles/';
$correctFilePaths = array('20130627-1830-01.xml',
'20130627-1830-02.xml',
'20130627-1830-03.xml',
'20130627-1830-04.xml',
'20130627-1830-05.xml',
'20130627-1830-06.xml',
'20130627-1830-07.xml',
'20130627-1830-08.xml',
'20130627-1830-09.xml',
);
$remoteImportFileGetter = new RemoteImportFileGetter($remoteDirectory,
$correctFilePaths,
vfsStream::url('localDir'));
$remoteImportFileGetter->copyFilesToLocalDirectory();
$localFiles = $this->root->getChildren();
$this->assertCount(9, $localFiles);
$this->assertEquals($correctFilePaths, $localFiles);
$i = 0;
foreach($correctFilePaths as $remoteFile){
$this->assertEquals(file_get_contents($remoteFile), file_get_contents($localFiles[$i]));
$i++;
}
}