public function testGetUrl()
 {
     $media = new SimpleMedia();
     $variant = new Variant('test');
     $variant->setFilename('file.jpg');
     $this->cdn->setConfiguration(array('base_url' => 'http://cdn.example.com/'));
     $this->assertEquals('http://cdn.example.com/file.jpg', $this->cdn->getUrl($media, $variant));
 }
 public function testGetUrl()
 {
     $_SERVER['HTTP_HOST'] = 'localhost';
     $media = new SimpleMedia();
     $variant = new Variant('test');
     $variant->setFilename('file.jpg');
     $this->cdn->setConfiguration(array('path' => 'path/'));
     $this->assertEquals('path/file.jpg', $this->cdn->getUrl($media, $variant));
     $options = array('absolute' => TRUE);
     $this->assertEquals('http://localhost/path/file.jpg', $this->cdn->getUrl($media, $variant, $options));
     $options['domain'] = 'example.com';
     $this->assertEquals('http://example.com/path/file.jpg', $this->cdn->getUrl($media, $variant, $options));
     $options['protocol'] = 'https';
     $this->assertEquals('https://example.com/path/file.jpg', $this->cdn->getUrl($media, $variant, $options));
 }
示例#3
0
 /**
  * {@inheritDoc}
  */
 public static function fromArray($array)
 {
     $variant = new Variant();
     if (isset($array['name'])) {
         $variant->setName($array['name']);
     }
     if (isset($array['filename'])) {
         $variant->setFilename($array['filename']);
     }
     if (isset($array['options'])) {
         $variant->setOptions($array['options']);
     }
     if (isset($array['mode'])) {
         $variant->setMode($array['mode']);
     }
     if (isset($array['status'])) {
         $variant->setStatus($array['status']);
     }
     if (isset($array['error'])) {
         $variant->setError($array['error']);
     }
     if (isset($array['meta']) && is_array($array['meta']) && !empty($array['meta'])) {
         $variant->setMeta($array['meta']);
     }
     return $variant;
 }
 public function testSetGetFilename()
 {
     $this->object->setFilename('filename');
     $this->assertEquals('filename', $this->object->getFilename());
 }