/** * Deletes the given user */ public function deleteAction() { // Try to load the chosen user $id = $this->getRequest()->getParam('id'); $sim = $this->_simSrv->load($id, \App::getOrgUserLogged()); if (empty($sim)) { throw new NotFoundException('Sim ' . $id . ' not found', 404); } // Check permissions $this->_helper->allowed('delete', $sim); // Remove the user try { $this->_simSrv->delete($id); } catch (Exception $e) { throw new InvalidArgumentException($e->getMessage(), null, $e); } $this->view->data = true; }
/** * @group EricssonPreinvetoryInt */ public function testDelete() { $fileName = __DIR__ . '/xml/StockTestingList.xml'; $mimeType = new finfo(FILEINFO_MIME_TYPE); $data = $this->_service->getData($fileName, $mimeType->file($fileName)); $this->assertEquals('sim', $data['_type']); $this->_service->createSim($data, $this->_user->getOrganizationId()); $result = $this->_service->listAll(null, array(), null, $this->_user->getOrganization()); $resultItems = $result->getItems(); try { foreach ($resultItems as $sim) { $this->_service->delete($sim); } } catch (Exception $e) { $this->fail('An exception has been raised: ' . $e->getMessage()); } $result = $this->_service->listAll(null, array(), null, $this->_user->getOrganization()); $this->assertEmpty(0, $result->getItems()); }