/**
  * @test
  */
 public function usesPrefix()
 {
     $strategy = $this->prophesize(Strategy::class);
     $strategy->calculateDirectory(Argument::type(IdentifiableObj::class))->shouldBeCalled()->willReturn('tussen/lusse');
     $calc = new DirectoryCalculator($strategy->reveal(), '/tussenlusse/');
     $ret = $calc->calculateDirectory(new IdentifiableObj(1));
     $this->assertEquals('/tussenlusse/tussen/lusse', $ret);
 }
Exemplo n.º 2
0
 /**
  * Returns a link for a file
  *
  * @param  File   $file
  * @return string Link
  */
 protected function getBaseLink(File $file)
 {
     $url = array();
     $url[] = $this->directoryCalculator->calculateDirectory($file);
     $name = $this->getFileName($file);
     $url[] = $name;
     $url = implode(DIRECTORY_SEPARATOR, $url);
     return $url;
 }
Exemplo n.º 3
0
 /**
  * @param Versionable $versionable
  * @param Version $version
  * @return string
  */
 public function getPathVersion(Versionable $versionable, Version $version)
 {
     list($resource, $file) = $this->extractResourceAndFileFromVersionable($versionable);
     $path = $this->getPrefix();
     if ($file) {
         $path .= 'files/';
     } else {
         $path .= 'resources/';
     }
     $path .= $this->directoryCalculator->calculateDirectory($file ?: $resource) . '/' . $version->toString();
     $path .= '/' . ($file ? $file->getId() : $resource->getId());
     return $path;
 }