/**
  * @test
  * @dataProvider capabilitiesDataProvider
  * @TODO: Rewrite or move to functional suite
  */
 public function capabilitiesOfStorageObjectAreCorrectlySet(array $capabilities)
 {
     $this->markTestSkipped('This test does way to much and is mocked incomplete. Skipped for now.');
     $storageRecord = array('is_public' => $capabilities['public'], 'is_writable' => $capabilities['writable'], 'is_browsable' => $capabilities['browsable'], 'is_online' => true);
     $mockedDriver = $this->createDriverMock(array('pathType' => 'relative', 'basePath' => 'fileadmin/'), $this->subject, null);
     $this->prepareSubject(array(), false, $mockedDriver, $storageRecord);
     $this->assertEquals($capabilities['public'], $this->subject->isPublic(), 'Capability "public" is not correctly set.');
     $this->assertEquals($capabilities['writable'], $this->subject->isWritable(), 'Capability "writable" is not correctly set.');
     $this->assertEquals($capabilities['browsable'], $this->subject->isBrowsable(), 'Capability "browsable" is not correctly set.');
 }
 /**
  * @test
  * @dataProvider capabilitiesDataProvider
  */
 public function capabilitiesOfStorageObjectAreCorrectlySet(array $capabilites)
 {
     $storageRecord = array('is_public' => $capabilites['public'], 'is_writable' => $capabilites['writable'], 'is_browsable' => $capabilites['browsable'], 'is_online' => TRUE);
     $mockedDriver = $this->createDriverMock(array(), $this->fixture, array('hasCapability'));
     $mockedDriver->expects($this->any())->method('hasCapability')->will($this->returnValue(TRUE));
     $this->prepareFixture(array(), FALSE, $mockedDriver, $storageRecord);
     $this->assertEquals($capabilites['public'], $this->fixture->isPublic(), 'Capability "public" is not correctly set.');
     $this->assertEquals($capabilites['writable'], $this->fixture->isWritable(), 'Capability "writable" is not correctly set.');
     $this->assertEquals($capabilites['browsable'], $this->fixture->isBrowsable(), 'Capability "browsable" is not correctly set.');
 }
 /**
  * Generate public url for file
  *
  * @param Resource\ResourceStorage $storage
  * @param Resource\Driver\DriverInterface $driver
  * @param Resource\FileInterface $file
  * @param $relativeToCurrentScript
  * @param array $urlData
  * @return void
  */
 public function generatePublicUrl(Resource\ResourceStorage $storage, Resource\Driver\DriverInterface $driver, Resource\FileInterface $file, $relativeToCurrentScript, array $urlData)
 {
     // We only render special links for non-public files
     if ($this->enabled && !$storage->isPublic()) {
         $queryParameterArray = array('eID' => 'dumpFile', 't' => '');
         if ($file instanceof Resource\File) {
             $queryParameterArray['f'] = $file->getUid();
             $queryParameterArray['t'] = 'f';
         } elseif ($file instanceof Resource\ProcessedFile) {
             $queryParameterArray['p'] = $file->getUid();
             $queryParameterArray['t'] = 'p';
         }
         $queryParameterArray['token'] = GeneralUtility::hmac(implode('|', $queryParameterArray), 'BeResourceStorageDumpFile');
         // $urlData['publicUrl'] is passed by reference, so we can change that here and the value will be taken into account
         $urlData['publicUrl'] = BackendUtility::getAjaxUrl('FalSecuredownload::publicUrl', $queryParameterArray);
     }
 }