Пример #1
0
 /**
  * {@inheritdoc}
  */
 public function generateUrl(StoredFile $storedFile)
 {
     $storageKey = $storedFile->getStorageKey();
     $storageKey .= '/' . $storedFile->getRepository()->getName();
     $storageKey .= '/' . $storedFile->getFilename();
     return $this->router->generate($this->routeName, array('storageKey' => $storageKey), RouterInterface::NETWORK_PATH);
 }
Пример #2
0
 public function test__construct()
 {
     $filename = uniqid() . '.txt';
     $filePath = sys_get_temp_dir() . DIRECTORY_SEPARATOR . $filename;
     file_put_contents($filePath, 'blah');
     $file = new File($filePath);
     $context = array('foo');
     $dummyStorageKey = 'storage-key';
     $repository = $this->createMock('Modera\\FileRepositoryBundle\\Entity\\Repository', array(), array(), '', false);
     $repository->expects($this->atLeastOnce())->method('generateStorageKey')->with($this->equalTo($file), $this->equalTo($context))->will($this->returnValue($dummyStorageKey));
     $storedFile = new StoredFile($repository, $file, $context);
     $this->assertEquals($filename, $storedFile->getFilename());
     $this->assertEquals($dummyStorageKey, $storedFile->getStorageKey());
     $this->assertEquals('txt', $storedFile->getExtension());
     $this->assertEquals('text/plain', $storedFile->getMimeType());
 }