/** * Open files */ function it_open_files(Filesystem $filesystem, FileFactoryContract $fileFactory, File $file) { $filesystem->read($path = 'MyFile.php')->willReturn($contents = 'Foo contents')->shouldBeCalled(); $fileFactory->build($contents)->willReturn($file)->shouldBeCalled(); $this->open($path)->shouldReturn($file); }
/** * @param string $path * * @return File */ public function open($path) { $contents = $this->filesystem->read($path); return $this->fileFactory->build($contents); }