AssetManager\Resolver\MapResolver::setMap PHP Method

setMap() public method

Maps should be arrays or Traversable objects with name => path pairs
public setMap ( array | Traversabl\Traversable $map )
$map array | Traversabl\Traversable
    public function setMap($map)
    {
        if (!is_array($map) && !$map instanceof Traversable) {
            throw new Exception\InvalidArgumentException(sprintf('%s: expects an array or Traversable, received "%s"', __METHOD__, is_object($map) ? get_class($map) : gettype($map)));
        }
        if ($map instanceof Traversable) {
            $map = ArrayUtils::iteratorToArray($map);
        }
        $this->map = $map;
    }

Usage Example

 public function testResolveHttpAssetSuccess()
 {
     $resolver = new MapResolver();
     $mimeResolver = $this->getMock('AssetManager\\Service\\MimeResolver');
     $mimeResolver->expects($this->any())->method('getMimeType')->with('http://foo.bar/')->will($this->returnValue('text/foo'));
     $resolver->setMimeResolver($mimeResolver);
     $asset1 = array('bacon' => 'http://foo.bar/');
     $resolver->setMap($asset1);
     $asset = $resolver->resolve('bacon');
     $this->assertTrue($asset instanceof Asset\HttpAsset);
     $this->assertSame('text/foo', $asset->mimetype);
 }