示例#1
0
 /**
  * {@inheritDoc}
  */
 public function getVariantInstance($variantName)
 {
     if (!array_key_exists($variantName, $this->variants)) {
         throw new InvalidArgumentException(sprintf('media "%s" has no variant named "%s" ', $this, $variantName));
     }
     return Variant::fromArray($this->variants[$variantName]);
 }
 public function testFromArray()
 {
     $data = array('name' => 'foo', 'filename' => 'bar', 'options' => array('foo' => 'bar'), 'mode' => Variant::MODE_INSTANT, 'status' => Variant::STATUS_ERROR, 'error' => 'test', 'meta' => array('a' => 'b', 'c' => 'd'));
     $variant = Variant::fromArray($data);
     foreach ($data as $name => $value) {
         $getter = 'get' . ucwords($name);
         $this->assertEquals($value, $variant->{$getter}());
     }
 }