public function testDeleteActionMissingParams() { $this->_deviceManager->expects($this->once())->method('getDevice')->with(null)->will($this->throwException(new \Model\Network\RuntimeException())); $this->_deviceManager->expects($this->never())->method('deleteDevice'); $this->dispatch('/console/network/delete/'); $this->assertRedirectTo('/console/network/index/'); }
/** * Delete a network device type definition * * URL parameter: 'name' * @return array|\Zend\Http\Response Array(description) or redirect response */ public function deletedevicetypeAction() { if ($this->getRequest()->isPost()) { if ($this->params()->fromPost('yes')) { $this->_deviceManager->deleteType($this->params()->fromQuery('name')); } return $this->redirectToRoute('preferences', 'networkdevices'); } else { return array('description' => $this->params()->fromQuery('name')); } }
/** * Delete a network device * * Query params: macaddress * * @return array|\Zend\Http\Response array(device) or redirect response */ public function deleteAction() { $params = $this->params(); if ($this->getRequest()->isGet()) { try { $device = $this->_deviceManager->getDevice($params->fromQuery('macaddress')); return array('device' => $device); } catch (\Model\Network\RuntimeException $e) { } } else { if ($params->fromPost('yes')) { $this->_deviceManager->deleteDevice($params->fromQuery('macaddress')); } } return $this->redirectToRoute('network', 'index'); }
public function setUp() { $this->_deviceManager = $this->createMock('Model\\Network\\DeviceManager'); $this->_deviceManager->expects($this->once())->method('getTypeCounts')->willReturn(array('name0' => 0, 'name1' => 1)); parent::setUp(); }
public function testDeletedevicetypeActionPostYes() { $this->_deviceManager->expects($this->once())->method('deleteType')->with('test'); $this->dispatch('/console/preferences/deletedevicetype/?name=test', 'POST', array('yes' => 'Yes')); $this->assertRedirectTo('/console/preferences/networkdevices/'); }
public function setUp() { $this->_deviceManager = $this->getMockBuilder('Model\\Network\\DeviceManager')->disableOriginalConstructor()->getMock(); $this->_deviceManager->expects($this->once())->method('getTypeCounts')->willReturn(array('name0' => 0, 'name1' => 1)); parent::setUp(); }