/** * @param \Dvs\FileBundle\Storage\Naming\NamingStrategy $namingStrategy * @param \Dvs\FileBundle\Storage\PathGenerating\FilePathStrategy $filePathStrategy * @param \Dvs\FileBundle\Interfaces\FileSystem $filesystem * @param \Dvs\FileBundle\Storage\Resource\Storageable $storageable */ public function it_should_store_resource_if_possible($namingStrategy, $filePathStrategy, $filesystem, $storageable) { // Given $fileInfo = new \SplFileInfo(__FILE__); $namingStrategy->generate($storageable)->willReturn($filename = 'filename'); $filePathStrategy->generate($filename)->willReturn($path = 'path/to/file/filename'); $filename .= '.' . $fileInfo->getExtension(); $filePathWithName = $path . DIRECTORY_SEPARATOR . $filename; $filesystem->write($filePathWithName, file_get_contents(__FILE__))->willReturn(true); // When $this->store($storageable, $fileInfo)->shouldReturn(true); $storageable->setFileName($filename)->shouldHaveBeenCalled(); }
/** * @param File $file * * @return bool */ public function has(File $file) { return $this->filesystem->has($file->getDirectories() . DIRECTORY_SEPARATOR . $file->getFilename()); }