/**
  * @covers Alchemy\Zippy\Resource\ResourceCollection::__construct
  */
 public function testConstructWithElements()
 {
     $data = array('one', 'two' => 'three');
     $collection = new ResourceCollection('supa-context', $data);
     $this->assertEquals('supa-context', $collection->getContext());
     $this->assertEquals($data, $collection->toArray());
 }
 /**
  * Handles an archival request.
  *
  * The request is an array of string|streams to compute in a context (current
  * working directory most of the time)
  * Some keys can be associative. In these cases, the key is used the target
  * for the file.
  *
  * @param String $context
  * @param Array  $request
  *
  * @return ResourceCollection
  *
  * @throws IOException In case of write failure
  */
 public function handle($context, array $request)
 {
     $collection = $this->mapper->map($context, $request);
     if (!$collection->canBeProcessedInPlace()) {
         $context = sprintf('%s/%s', sys_get_temp_dir(), uniqid('zippy_'));
         try {
             $this->filesystem->mkdir($context);
         } catch (SfIOException $e) {
             throw new IOException(sprintf('Could not create temporary folder %s', $context), $e->getCode(), $e);
         }
         foreach ($collection as $resource) {
             $this->teleporter->teleport($context, $resource);
         }
         $collection = new ResourceCollection($context, $collection->toArray(), true);
     }
     return $collection;
 }