/** * Base tests for all _useform()-based actions (GET method) * * @param string $action "action" part of URI * @param string $formClass Form name without namespace */ protected function _testUseFormGet($action, $formClass) { $preferences = new \Zend\Form\Fieldset('Preferences'); $preferences->add(new \Zend\Form\Element\Text('pref1')); $preferences->add(new \Zend\Form\Element\Text('pref2')); $formData = array('Preferences' => array('pref1' => 'value1', 'pref2' => 'value2')); $form = $this->createMock("Console\\Form\\Preferences\\{$formClass}"); $form->method('get')->willReturn($preferences); $form->expects($this->once())->method('setData')->with($formData); $form->expects($this->never())->method('getData'); $form->expects($this->never())->method('isValid'); $form->expects($this->once())->method('render')->willReturn('<form></form>'); $this->_formManager->expects($this->once())->method('get')->with("Console\\Form\\Preferences\\{$formClass}")->will($this->returnValue($form)); $this->_config->method('__get')->will($this->returnValueMap(array(array('pref1', 'value1'), array('pref2', 'value2')))); $this->_config->expects($this->never())->method('setOptions'); $this->dispatch("/console/preferences/{$action}"); $this->assertResponseStatusCode(200); $this->assertXPathQuery('//form'); }