public function testPropertiesActionPostValid()
 {
     $postData = array('Name' => 'new_name');
     $subnet = array('Address' => 'address', 'Mask' => 'mask');
     $this->_subnetManager->expects($this->once())->method('getSubnet')->with('192.0.2.0', '255.255.255.0')->willReturn($subnet);
     $this->_subnetManager->expects($this->once())->method('saveSubnet')->with('address', 'mask', 'new_name');
     $this->_subnetForm->expects($this->once())->method('setData')->with($postData);
     $this->_subnetForm->expects($this->once())->method('isValid')->will($this->returnValue(true));
     $this->_subnetForm->expects($this->once())->method('getData')->will($this->returnValue($postData));
     $this->_subnetForm->expects($this->never())->method('render');
     $this->dispatch('/console/network/properties/?subnet=192.0.2.0&mask=255.255.255.0', 'POST', $postData);
     $this->assertRedirectTo('/console/network/index/');
 }
 /**
  * Edit a subnet's properties
  *
  * Query params: subnet, mask
  *
  * @return array|\Zend\Http\Response array(subnet, form) or redirect response
  */
 public function propertiesAction()
 {
     $params = $this->params();
     $subnet = $this->_subnetManager->getSubnet($params->fromQuery('subnet'), $params->fromQuery('mask'));
     if ($this->getRequest()->isPost()) {
         $this->_subnetForm->setData($params->fromPost());
         if ($this->_subnetForm->isValid()) {
             $data = $this->_subnetForm->getData();
             $this->_subnetManager->saveSubnet($subnet['Address'], $subnet['Mask'], $data['Name']);
             return $this->redirectToRoute('network', 'index');
         }
     } else {
         $this->_subnetForm->setData(array('Name' => $subnet['Name']));
     }
     return array('subnet' => $subnet, 'form' => $this->_subnetForm);
 }