public function testCreateServiceWillThrowExceptionWhenGetUnwantedInstanceType() { $serviceName = Application_Factory_ServiceName::PROFILE_REPOSITORY; $exceptionMessage = "{$serviceName} already registered in registry but is no instance of {$serviceName}"; $this->setExpectedException("Application_Factory_Exception", $exceptionMessage); Zend_Registry::set(Application_Factory_ServiceName::PROFILE_REPOSITORY, new stdClass()); $this->factory->createService(); }
/** * Delete existed profile * * Handler GET, POST request * @link GET /profile/delete/:id display form confirm delete profile * @link POST /profile/delete delete profile from persistent */ public function deleteAction() { $request = $this->getRequest(); /* @var $request Zend_Controller_Request_Http */ $profileRepoFactory = new Application_Factory_ProfileRepository(); $profileRepo = $profileRepoFactory->createService(); /* @var $profileRepo Application_Repository_ProfileInterface */ if ($request->isPost()) { $profileId = (int) $request->getPost('id'); if ('yes' === strtolower($request->getPost('del'))) { $profileRepo->delete($profileId); } $this->_helper->redirector('index', 'profile', 'default'); return; } try { $profileId = (int) $this->getParam('id', 0); $this->view->profile = $profileRepo->findById($profileId); } catch (Application_Repository_Exception_NotFound $e) { $this->view->profileNotFound = true; } }