【发布时间】:2016-03-03 11:43:13
【问题描述】:
我在测试使用 Filesystem 组件访问 Symfony 2 应用程序中的文件系统,然后使用 Finder 组件访问目录中的文件列表时收到以下错误。
Call to undefined method Prophecy\Prophecy\MethodProphecy::in()
这是我正在测试的方法的 sn-p:
$finder = new Finder();
if ($filesystem->exists($imageImportPath)) {
$finder->files()->in($imageImportPath);
foreach ($finder as $image) {
// ...do some stuff in here with uploading images and creating an entity...
$this->entityManager->persist($entity);
$this->entityManager->flush($entity);
}
}
这是我对助手类的规范:
function it_imports_image_assets(
Filesystem $filesystem,
EntityManager $entityManager,
Finder $finder
) {
$imageImportPath = '/var/www/crmpicco/app/files/images/rfc-1872/';
$filesystem->exists($imageImportPath)->willReturn(true);
$finder->files()->in($imageImportPath)->shouldHaveCount(2);
$this->importImageAssets($imageImportPath)->shouldReturn([]);
}
【问题讨论】:
标签: php symfony tdd php-5.6 phpspec