Esempio n. 1
0
 /**
  * Generates an MD5 hash of the file attributes and options.
  *
  * @param File $file
  * @param array $options
  * @return string
  */
 protected function generateHash(File $file, array $options = [])
 {
     $fileSignature = ['id' => (string) $file->getKey()];
     // Add any modifications that may have run on the file.
     if (array_key_exists($this->getFileModificationKey(), $options)) {
         $fileSignature[$this->getFileModificationKey()] = $options[$this->getFileModificationKey()];
     }
     return md5(json_encode($this->recursiveKeySort($fileSignature)));
 }
 public function it_generates_a_name_for_a_file_according_to_its_attributes_and_options(FileModel $fileModel)
 {
     $fileModel->getMimeType()->willReturn('image/png');
     $fileModel->getKey()->willReturn(999);
     $fileModel->setAttribute('slot', 'profile');
     $options = ['modifications' => ['shrink' => 'run shrink filter here', 'blur' => 'run blur filter here'], 'validators' => ['image_size' => 'run image size validator']];
     $fileName = $this->fileName($fileModel, $options);
     $mixedOptions = ['validators' => ['file_size' => 'run file size validator'], 'modifications' => ['blur' => 'run blur filter here', 'shrink' => 'run shrink filter here']];
     $this->fileName($fileModel, $mixedOptions)->shouldBeEqualTo($fileName);
 }