public function testExportActionValidate() { $this->_config->expects($this->once())->method('__get')->with('validateXml')->willReturn('1'); $document = $this->createMock('\\Protocol\\Message\\InventoryRequest'); $document->expects($this->once())->method('forceValid'); $client = $this->createMock('Model\\Client\\Client'); $client->expects($this->once())->method('toDomDocument')->willReturn($document); $this->_clientManager->method('getClient')->willReturn($client); $this->dispatch('/console/client/export/?id=1'); $this->assertResponseStatusCode(200); }
public function testProcessSetInspect() { $data = array('inspect' => array('inspect' => '1'), 'existing' => array(), 'new_value' => array('name' => '', 'root_key' => 'root_key', 'subkeys' => 'subkeys', 'value' => 'value')); $resultSet = new \Zend\Db\ResultSet\ResultSet(); $resultSet->initialize(array()); $registryManager = $this->createMock('Model\\Registry\\RegistryManager'); $registryManager->expects($this->once())->method('getValueDefinitions')->willReturn($resultSet); $registryManager->expects($this->never())->method('addValueDefinition'); $registryManager->expects($this->never())->method('renameValueDefinition'); $this->_config->expects($this->once())->method('__set')->with('inspectRegistry', '1'); $form = $this->getMockBuilder('Console\\Form\\ManageRegistryValues')->setMethods(array('getData'))->setConstructorArgs(array(null, array('config' => $this->_config, 'registryManager' => $registryManager)))->getMock(); $form->expects($this->once())->method('getData')->willReturn($data); $form->init(); $form->process(); }
public function testUpdateActionGet() { $packageData = array('Name' => 'Name', 'Comment' => 'Comment', 'Platform' => 'Platform', 'DeployAction' => 'DeployAction', 'ActionParam' => 'ActionParam', 'Priority' => 'Priority', 'Warn' => 'Warn', 'WarnMessage' => 'WarnMessage', 'WarnCountdown' => 'WarnCountdown', 'WarnAllowAbort' => 'WarnAllowAbort', 'WarnAllowDelay' => 'WarnAllowDelay', 'PostInstMessage' => 'PostInstMessage'); $formData = array('Deploy' => array('Pending' => 'defaultDeployPending', 'Running' => 'defaultDeployRunning', 'Success' => 'defaultDeploySuccess', 'Error' => 'defaultDeployError', 'Groups' => 'defaultDeployGroups'), 'MaxFragmentSize' => 'defaultMaxFragmentSize'); $formData += $packageData; $this->_config->expects($this->exactly(6))->method('__get')->will($this->returnArgument(0)); $this->_updateForm->expects($this->once())->method('setData')->with($formData); $this->_updateForm->expects($this->never())->method('getData'); $this->_updateForm->expects($this->never())->method('isValid'); $this->_updateForm->expects($this->once())->method('render')->willReturn('<form></form>'); $this->_packageManager->expects($this->once())->method('getPackage')->with('oldName')->willReturn($packageData); $this->_packageManager->expects($this->never())->method('updatePackage'); $this->dispatch('/console/package/update/?name=oldName'); $this->assertResponseStatusCode(200); $this->assertXpathQuery('//form'); }
/** * Base tests for all _useform()-based actions (POST method, valid data) * * @param string $action "action" part of URI * @param string $formClass Form name without namespace */ protected function _testUseFormPostValid($action, $formClass) { $postData = array('Preferences' => array('pref1' => 'value1', 'pref2' => 'value2')); $form = $this->createMock("Console\\Form\\Preferences\\{$formClass}"); $form->expects($this->once())->method('setData')->with($postData); $form->expects($this->once())->method('getData')->willReturn($postData); $form->expects($this->once())->method('isValid')->willReturn(true); $form->expects($this->never())->method('render'); $this->_formManager->expects($this->once())->method('get')->with("Console\\Form\\Preferences\\{$formClass}")->will($this->returnValue($form)); $this->_config->expects($this->once())->method('setOptions')->with($this->callback(function ($options) { $options = iterator_to_array($options); return $options == array('pref1' => 'value1', 'pref2' => 'value2'); })); $this->dispatch("/console/preferences/{$action}", 'POST', $postData); $this->assertRedirectTo("/console/preferences/{$action}/"); }
public function testImportActionPostValidError() { $fileSpec = array('tmp_name' => 'uploaded_file'); $this->getRequest()->getFiles()->set('File', $fileSpec); $postData = array('key' => 'value'); $form = $this->_formManager->get('Console\\Form\\Import'); $form->expects($this->once())->method('isValid')->will($this->returnValue(true)); $form->expects($this->once())->method('setData')->with(array('File' => $fileSpec, 'key' => 'value')); $form->expects($this->once())->method('getData')->will($this->returnValue(array('File' => $fileSpec))); $form->expects($this->once())->method('render'); $this->_config->expects($this->once())->method('__get')->with('communicationServerUri')->will($this->returnValue('http://example.net/server')); $response = new \Zend\Http\Response(); $response->setStatusCode(500)->setReasonPhrase('reason_phrase'); $this->_inventoryUploader->expects($this->once())->method('uploadFile')->with('uploaded_file')->will($this->returnValue($response)); $this->dispatch('/console/client/import/', 'POST', $postData); $this->assertResponseStatusCode(200); $this->assertXpathQueryContentContains('//p[@class="error"]', "\nFehler beim Hochladen. Server http://example.net/server antwortete mit Fehler 500: reason_phrase\n"); $this->assertXpathQueryContentContains('//h1', "\nImport lokal erzeugter Inventardaten\n"); }
public function testDeleteInterfacesDefaultUnchecked() { $this->_config->expects($this->once())->method('__get')->with('defaultDeleteInterfaces')->willReturn(0); $this->assertFalse($this->_getForm()->get('DeleteInterfaces')->isChecked()); }
/** * Set up Config mock object */ public function setUp() { $this->_config = $this->getMockBuilder('Model\\Config')->disableOriginalconstructor()->getMock(); $this->_config->expects($this->any())->method('__get')->will($this->returnValueMap(array(array('defaultMergeCustomFields', 1), array('defaultMergeGroups', 1), array('defaultMergePackages', 0)))); parent::setUp(); }
/** * Set up Config mock object */ public function setUp() { $this->_config = $this->createMock('Model\\Config'); $this->_config->expects($this->any())->method('__get')->will($this->returnValueMap(array(array('defaultMergeCustomFields', 1), array('defaultMergeGroups', 1), array('defaultMergePackages', 0)))); parent::setUp(); }