/**
  * @param  ContainerInterface $container
  * @param string $requestedName,
  * @param null|array $options
  * @return RenameUpload
  */
 public function __invoke(ContainerInterface $container, $requestedName, array $options = null)
 {
     $filter = new RenameUpload($options);
     if ($container->has('Request')) {
         $filter->setRequest($container->get('Request'));
     }
     return $filter;
 }
 /**
  * Create a RenameUpload instance
  *
  * @param \Zend\Filter\FilterPluginManager $filters
  * @return RenameUpload
  */
 public function __invoke($filters)
 {
     $services = $filters->getServiceLocator();
     $filter = new RenameUpload($this->creationOptions);
     if ($services->has('Request')) {
         $filter->setRequest($services->get('Request'));
     }
     return $filter;
 }
 /**
  * @dataProvider uploadMethods
  */
 public function testMoveUploadedFileSucceedsOnPutAndPatchHttpRequests($method)
 {
     $target = $this->targetDir . '/uploaded.txt';
     $file = $this->createUploadFile();
     $request = new HttpRequest();
     $request->setMethod($method);
     $filter = new RenameUpload($target);
     $filter->setRequest($request);
     $result = $filter->filter($file);
     $this->assertInternalType('array', $result);
     $this->assertArrayHasKey('tmp_name', $result);
     $this->assertEquals($target, $result['tmp_name']);
     $this->assertTrue(file_exists($target));
     $this->assertFalse(file_exists($file['tmp_name']));
 }