Ejemplo n.º 1
0
 /**
  * Build a new package.
  *
  * @return \Zend\View\Model\ViewModel|\Zend\Http\Response form template or redirect response
  */
 public function buildAction()
 {
     if ($this->getRequest()->isPost()) {
         $this->_buildForm->setData($this->params()->fromPost() + $this->params()->fromFiles());
         if ($this->_buildForm->isValid()) {
             $this->_buildPackage($this->_buildForm->getData());
             return $this->redirectToRoute('package', 'index');
         }
     } else {
         $this->_buildForm->setData(array('Platform' => $this->_config->defaultPlatform, 'DeployAction' => $this->_config->defaultAction, 'ActionParam' => $this->_config->defaultActionParam, 'Priority' => $this->_config->defaultPackagePriority, 'MaxFragmentSize' => $this->_config->defaultMaxFragmentSize, 'Warn' => $this->_config->defaultWarn, 'WarnMessage' => $this->_config->defaultWarnMessage, 'WarnCountdown' => $this->_config->defaultWarnCountdown, 'WarnAllowAbort' => $this->_config->defaultWarnAllowAbort, 'WarnAllowDelay' => $this->_config->defaultWarnAllowDelay, 'PostInstMessage' => $this->_config->defaultPostInstMessage));
     }
     return $this->printForm($this->_buildForm);
 }
Ejemplo n.º 2
0
 /**
  * Build a new package.
  *
  * @return \Zend\View\Model\ViewModel|\Zend\Http\Response form template or redirect response
  */
 public function buildAction()
 {
     if ($this->getRequest()->isPost()) {
         $this->_buildForm->setData($this->params()->fromPost() + $this->params()->fromFiles());
         if ($this->_buildForm->isValid()) {
             $data = $this->_buildForm->getData();
             $data['FileName'] = $data['File']['name'];
             $data['FileLocation'] = $data['File']['tmp_name'];
             $flashMessenger = $this->flashMessenger();
             try {
                 $this->_packageManager->buildPackage($data, true);
                 $flashMessenger->addSuccessMessage(array($this->_('Package \'%s\' was successfully created.') => $data['Name']));
                 $flashMessenger->addMessage($data['Name'], 'packageName');
             } catch (\Model\Package\RuntimeException $e) {
                 $flashMessenger->addErrorMessage($e->getMessage());
             }
             return $this->redirectToRoute('package', 'index');
         }
     } else {
         $this->_buildForm->setData(array('Platform' => $this->_config->defaultPlatform, 'DeployAction' => $this->_config->defaultAction, 'ActionParam' => $this->_config->defaultActionParam, 'Priority' => $this->_config->defaultPackagePriority, 'MaxFragmentSize' => $this->_config->defaultMaxFragmentSize, 'Warn' => $this->_config->defaultWarn, 'WarnMessage' => $this->_config->defaultWarnMessage, 'WarnCountdown' => $this->_config->defaultWarnCountdown, 'WarnAllowAbort' => $this->_config->defaultWarnAllowAbort, 'WarnAllowDelay' => $this->_config->defaultWarnAllowDelay, 'PostInstMessage' => $this->_config->defaultPostInstMessage));
     }
     return $this->printForm($this->_buildForm);
 }
 public function testBuildActionPostValidSuccess()
 {
     $postData = array('Name' => 'packageName');
     $fileSpec = array('name' => 'file_name', 'tmp_name' => 'file_tmp_name', 'type' => 'file_type');
     $packageData = array('Name' => 'packageName', 'File' => array('name' => 'file_name', 'tmp_name' => 'file_tmp_name', 'type' => 'file_type'), 'FileName' => 'file_name', 'FileLocation' => 'file_tmp_name');
     $this->getRequest()->getFiles()->set('File', $fileSpec);
     $formData = $postData + array('File' => $fileSpec);
     $this->_buildForm->expects($this->once())->method('setData')->with($formData);
     $this->_buildForm->expects($this->once())->method('getData')->willReturn($formData);
     $this->_buildForm->expects($this->once())->method('isValid')->willReturn(true);
     $this->_buildForm->expects($this->never())->method('render');
     $this->_testBuildPackage('/console/package/build', $postData, $packageData, true);
     $this->assertRedirectTo('/console/package/index/');
 }
Ejemplo n.º 4
0
 public function testBuildActionPostValidError()
 {
     $postData = array('Name' => 'packageName');
     $fileSpec = array('name' => 'file_name', 'tmp_name' => 'file_tmp_name', 'type' => 'file_type');
     $packageData = array('Name' => 'packageName', 'File' => array('name' => 'file_name', 'tmp_name' => 'file_tmp_name', 'type' => 'file_type'), 'FileName' => 'file_name', 'FileLocation' => 'file_tmp_name');
     $formData = $postData + array('File' => $fileSpec);
     $this->getRequest()->getFiles()->set('File', $fileSpec);
     $this->_buildForm->expects($this->once())->method('setData')->with($formData);
     $this->_buildForm->expects($this->once())->method('getData')->willReturn($formData);
     $this->_buildForm->expects($this->once())->method('isValid')->willReturn(true);
     $this->_buildForm->expects($this->never())->method('render');
     $this->_packageManager->expects($this->once())->method('buildPackage')->with($packageData, true)->willThrowException(new \Model\Package\RuntimeException('build error'));
     $this->dispatch('/console/package/build', 'POST', $postData);
     $this->assertRedirectTo('/console/package/index/');
     $flashMessenger = $this->_getControllerPlugin('FlashMessenger');
     $this->assertEquals(array(), $flashMessenger->getCurrentSuccessMessages());
     $this->assertEquals(array('build error'), $flashMessenger->getCurrentErrorMessages());
     $this->assertEquals(array(), $flashMessenger->getCurrentMessagesFromNamespace('packageName'));
 }