public function testUpdateActionPostValidReconstructionError() { $postData = array('Name' => 'newName'); $this->_updateForm->expects($this->never())->method('setData'); $this->_updateForm->expects($this->never())->method('getData'); $this->_updateForm->expects($this->never())->method('isValid'); $this->_updateForm->expects($this->never())->method('render'); $this->_packageManager->expects($this->once())->method('getPackage')->with('oldName')->will($this->throwException(new \Model\Package\RuntimeException('getPackage() error'))); $this->_packageManager->expects($this->never())->method('updatePackage'); $this->dispatch('/console/package/update/?name=oldName', 'POST', $postData); $this->assertRedirectTo('/console/package/index/'); $this->assertEquals(array('getPackage() error'), $this->_getControllerPlugin('FlashMessenger')->getCurrentErrorMessages()); }
/** * Common tests for actions invoking _deletePackage() * * @param string $url URL to dispatch to * @param array $postData $POST data * @param string $name Package name * @param bool $success Deletion success to test */ protected function _testDeletePackage($url, $postData, $name, $success) { $flashMessenger = $this->_getControllerPlugin('FlashMessenger'); $errors = array(array('format1' => array('arg1', 'arg2')), array('format2' => array('arg3', 'arg4'))); if ($success) { $this->_packageManager->expects($this->once())->method('delete')->with($name); } else { $this->_packageManager->expects($this->once())->method('delete')->with($name)->will($this->throwException(new \Model\Package\RuntimeException('delete error'))); } $this->dispatch($url, 'POST', $postData); if ($success) { $this->assertContains(array('Package \'%s\' was successfully deleted.' => $name), $flashMessenger->getCurrentSuccessMessages()); $this->assertEquals(array(), $flashMessenger->getCurrentErrorMessages()); } else { $this->assertEquals(array(), $flashMessenger->getCurrentSuccessMessages()); $this->assertEquals(array('delete error'), $flashMessenger->getCurrentErrorMessages()); } }