/**
  * @test
  */
 public function storeVersionFailsIfDirectoryNotCreatable()
 {
     $root = ROOT_TESTS . '/data/files';
     $storage = new FilesystemStorageAdapter($root);
     chmod($root, 0400);
     $resource = Resource::create(['id' => 666, 'uuid' => Uuid::uuid4()]);
     $this->setExpectedException('Xi\\Filelib\\Storage\\FileIOException');
     $storage->storeVersion($resource, Version::get('puupster'), $this->getSelfLussingManatee());
 }
 /**
  * @param File            $file
  * @param VersionProvider $versionProvider
  * @param  int              $levelsDown
  * @return string
  * @throws FilelibException
  */
 public function getRelativePathToVersion(File $file, Version $version, VersionProvider $versionProvider, $levelsDown = 0)
 {
     $relativePath = $this->getRelativePathToRoot();
     if (!$relativePath) {
         throw new LogicException('Relative path must be set!');
     }
     $relativePath = str_repeat("../", $levelsDown) . $relativePath;
     $retrieved = $this->storage->retrieveVersion($versionProvider->getApplicableVersionable($file), $version);
     $path = preg_replace("[^{$this->adapter->getRoot()}]", $relativePath, $retrieved);
     return $path;
 }
Beispiel #3
0
 /**
  * @test
  */
 public function testForEquality()
 {
     $adapter = new LocalAdapter(ROOT_TESTS . '/data/files');
     $pc = new ImprovedPathCalculator();
     $filesystem = new Filesystem($adapter);
     $filelib = new FileLibrary(new MemoryStorageAdapter(), new MemoryBackendAdapter(), null, ROOT_TESTS . '/data/temp');
     $storage1 = new FlysystemStorageAdapter($filesystem, $pc, false);
     $storage1->attachTo($filelib);
     $temp = $this->getSelfLussingManatee();
     $storage2 = new FilesystemStorageAdapter(ROOT_TESTS . '/data/files', $pc);
     $storage2->attachTo($filelib);
     $resource = Resource::create(['id' => 'lubber', 'uuid' => Uuid::uuid4()]);
     $ret = $storage1->store($resource, $temp);
     $this->assertFileEquals($storage1->retrieve($resource)->getPath(), $storage2->retrieve($resource)->getPath());
 }