I get the following error when testing accessing the file system in my Symfony 2 application with the Filesystem
component and then accessing the list of files in a directory with the Finder
component.
Call to undefined method Prophecy\Prophecy\MethodProphecy::in()
This is a snippet of my method which I am testing:
$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);
}
}
This is my spec for the helper class:
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([]);
}