public function testUploadData()
 {
     $content = "testUploadFile\nline1\nline2\n";
     $adapter = $this->getMockBuilder('Zend\\Http\\Client\\Adapter\\Test')->setMethods(array('write'))->getMock();
     $adapter->expects($this->once())->method('write')->with('POST', 'http://example.net/server', '1.1', $this->callback(function ($headers) {
         return $headers['User-Agent'] == 'Braintacle_local_upload' and $headers['Content-Type'] == 'application/x-compress';
     }), $content);
     $uploader = new InventoryUploader('http://example.net/server', $adapter);
     $uploader->uploadData($content);
     $this->assertTrue(\PHPUnit_Framework_Assert::readAttribute($adapter, 'config')['strictredirects']);
 }
 public function testUploadData()
 {
     $content = "testUploadFile\nline1\nline2\n";
     $adapter = $this->getMockBuilder('Zend\\Http\\Client\\Adapter\\Test')->setMethods(array('write'))->getMock();
     $adapter->expects($this->once())->method('write')->with('POST', 'http://example.net/server', '1.1', $this->callback(function ($headers) {
         return $headers['User-Agent'] == 'Braintacle_local_upload' and $headers['Content-Type'] == 'application/x-compress';
     }), $content);
     $uploader = new InventoryUploader('http://example.net/server', $adapter);
     $uploader->uploadData($content);
     // No public method available to test "strictredirects" option - use reflection
     $reflectionClass = new \ReflectionClass($adapter);
     $reflectionProperty = $reflectionClass->getProperty('config');
     $reflectionProperty->setAccessible(true);
     $this->assertTrue($reflectionProperty->getValue($adapter)['strictredirects']);
 }
 /**
  * Import client via file upload
  *
  * @return array|\Zend\Http\Response array(form [, uri, response]) or redirect response
  */
 public function importAction()
 {
     $form = $this->_formManager->get('Console\\Form\\Import');
     $vars = array('form' => $form);
     if ($this->getRequest()->isPost()) {
         $form->setData($this->params()->fromFiles() + $this->params()->fromPost());
         if ($form->isValid()) {
             $data = $form->getData();
             $response = $this->_inventoryUploader->uploadFile($data['File']['tmp_name']);
             if ($response->isSuccess()) {
                 return $this->redirectToRoute('client', 'index');
             } else {
                 $vars['response'] = $response;
                 $vars['uri'] = $this->_config->communicationServerUri;
             }
         }
     }
     return $vars;
 }