public function testResolveMetadataForLanguageLocalization() { //Test AccountsModulePluralLabel $metadata = AccountsModule::getMetadata(); AccountsModule::setMetadata($metadata); $metadata = AccountsModule::getMetadata(); $this->assertEquals("eval:Zurmo::t('AccountsModule', 'AccountsModulePluralLabel', \$translationParams)", $metadata['global']['tabMenuItems'][0]['label']); $resolveVariableName = 'translationParams'; $params = LabelUtil::getTranslationParamsForAllModules(); MetadataUtil::resolveEvaluateSubString($metadata, $resolveVariableName, $params); $this->assertEquals('Accounts', $metadata['global']['tabMenuItems'][0]['label']); }
public function testGetTranslationParamsForAllModules() { $this->assertEquals('en', Yii::app()->languageHelper->getForCurrentUser()); $params = LabelUtil::getTranslationParamsForAllModules(); $this->assertEquals('Account', $params['AccountsModuleSingularLabel']); $this->assertEquals('account', $params['AccountsModuleSingularLowerCaseLabel']); $this->assertEquals('Accounts', $params['AccountsModulePluralLabel']); $this->assertEquals('accounts', $params['AccountsModulePluralLowerCaseLabel']); $metadata = AccountsModule::getMetadata(); $metadata['global']['singularModuleLabels'] = array('en' => 'company'); $metadata['global']['pluralModuleLabels'] = array('en' => 'companies'); AccountsModule::setMetadata($metadata); Yii::app()->languageHelper->flushModuleLabelTranslationParameters(); $params = LabelUtil::getTranslationParamsForAllModules(); $this->assertEquals('Company', $params['AccountsModuleSingularLabel']); $this->assertEquals('company', $params['AccountsModuleSingularLowerCaseLabel']); $this->assertEquals('Companies', $params['AccountsModulePluralLabel']); $this->assertEquals('companies', $params['AccountsModulePluralLowerCaseLabel']); }
/** * Edit an account */ public function editAction() { $db = $this->db; $id = $this->_getParam('id'); $account = new AccountsModule($id); $form = new Account_Edit($id); if ($this->_request->isPost()) { if ($form->isValid($_POST)) { $account->edit($form->getValues()); $this->_helper->FlashMessenger('Account edited successfully'); $this->_redirect($this->view->url(array('module' => 'default', 'controller' => 'account', 'action' => 'viewdetails', 'id' => $id))); } else { $form->populate($_POST); $this->view->form = $form; } } else { $this->view->form = $form; } }
public function init() { if (AccountsModule::shouldUpdateLatestActivityDateTimeWhenATaskIsCompleted()) { $eventHandler = array($this, 'updateAccountLatestActivityDateTimeByTask'); Task::model()->attachEventHandler('onAfterSave', $eventHandler); $this->attachedEventHandlersIndexedByModelClassName['Task'] = array('onAfterSave', $eventHandler); } if (AccountsModule::shouldUpdateLatestActivityDateTimeWhenANoteIsCreated()) { $eventHandler = array($this, 'updateAccountLatestActivityDateTimeByNote'); Note::model()->attachEventHandler('onAfterSave', $eventHandler); $this->attachedEventHandlersIndexedByModelClassName['Note'] = array('onAfterSave', $eventHandler); } if (AccountsModule::shouldUpdateLatestActivityDateTimeWhenAnEmailIsSentOrArchived()) { $eventHandler = array($this, 'updateAccountLatestActivityDateTimeByEmailMessage'); EmailMessage::model()->attachEventHandler('onAfterSave', $eventHandler); $this->attachedEventHandlersIndexedByModelClassName['EmailMessage'] = array('onAfterSave', $eventHandler); } if (AccountsModule::shouldUpdateLatestActivityDateTimeWhenAMeetingIsInThePast()) { $eventHandler = array($this, 'resolveModelLatestActivityDateTimeProcessFlagByMeeting'); Meeting::model()->attachEventHandler('onBeforeSave', $eventHandler); $this->attachedEventHandlersIndexedByModelClassName['Meeting'] = array('onBeforeSave', $eventHandler); } }
/** * @depends testOfficePhoneSetsToZeroWhenClearingAndForgetting */ public function testGetModelClassNames() { $modelClassNames = AccountsModule::getModelClassNames(); $this->assertEquals(2, count($modelClassNames)); $this->assertEquals('Account', $modelClassNames[0]); $this->assertEquals('AccountSearch', $modelClassNames[1]); }
public function filters() { $modelClassName = $this->getModule()->getPrimaryModelName(); $viewClassName = $modelClassName . 'EditAndDetailsView'; return array_merge(parent::filters(), array(array(ZurmoBaseController::REQUIRED_ATTRIBUTES_FILTER_PATH . ' + create, createFromRelation, edit', 'moduleClassName' => get_class($this->getModule()), 'viewClassName' => $viewClassName), array(static::getRightsFilterPath(), 'moduleClassName' => 'AccountsModule', 'rightName' => AccountsModule::getAccessRight()), array(static::getRightsFilterPath(), 'moduleClassName' => 'ContactsModule', 'rightName' => ContactsModule::getAccessRight()))); }
public function testUpdateLatestActivityDateTimeMethods() { $value = AccountsModule::shouldUpdateLatestActivityDateTimeWhenATaskIsCompleted(); $this->assertTrue($value); $value = AccountsModule::shouldUpdateLatestActivityDateTimeWhenANoteIsCreated(); $this->assertTrue($value); $value = AccountsModule::shouldUpdateLatestActivityDateTimeWhenAnEmailIsSentOrArchived(); $this->assertTrue($value); $value = AccountsModule::shouldUpdateLatestActivityDateTimeWhenAMeetingIsInThePast(); $this->assertTrue($value); $metadata = AccountsModule::getMetadata(); $metadata['global']['updateLatestActivityDateTimeWhenATaskIsCompleted'] = false; AccountsModule::setMetadata($metadata); $value = AccountsModule::shouldUpdateLatestActivityDateTimeWhenATaskIsCompleted(); $this->assertFalse($value); $value = AccountsModule::shouldUpdateLatestActivityDateTimeWhenANoteIsCreated(); $this->assertTrue($value); $value = AccountsModule::shouldUpdateLatestActivityDateTimeWhenAnEmailIsSentOrArchived(); $this->assertTrue($value); $value = AccountsModule::shouldUpdateLatestActivityDateTimeWhenAMeetingIsInThePast(); $this->assertTrue($value); $metadata = AccountsModule::getMetadata(); $metadata['global']['updateLatestActivityDateTimeWhenANoteIsCreated'] = false; AccountsModule::setMetadata($metadata); $value = AccountsModule::shouldUpdateLatestActivityDateTimeWhenATaskIsCompleted(); $this->assertFalse($value); $value = AccountsModule::shouldUpdateLatestActivityDateTimeWhenANoteIsCreated(); $this->assertFalse($value); $value = AccountsModule::shouldUpdateLatestActivityDateTimeWhenAnEmailIsSentOrArchived(); $this->assertTrue($value); $value = AccountsModule::shouldUpdateLatestActivityDateTimeWhenAMeetingIsInThePast(); $this->assertTrue($value); $metadata = AccountsModule::getMetadata(); $metadata['global']['updateLatestActivityDateTimeWhenAnEmailIsSentOrArchived'] = false; AccountsModule::setMetadata($metadata); $value = AccountsModule::shouldUpdateLatestActivityDateTimeWhenATaskIsCompleted(); $this->assertFalse($value); $value = AccountsModule::shouldUpdateLatestActivityDateTimeWhenANoteIsCreated(); $this->assertFalse($value); $value = AccountsModule::shouldUpdateLatestActivityDateTimeWhenAnEmailIsSentOrArchived(); $this->assertFalse($value); $value = AccountsModule::shouldUpdateLatestActivityDateTimeWhenAMeetingIsInThePast(); $this->assertTrue($value); $metadata = AccountsModule::getMetadata(); $metadata['global']['updateLatestActivityDateTimeWhenAMeetingIsInThePast'] = false; AccountsModule::setMetadata($metadata); $value = AccountsModule::shouldUpdateLatestActivityDateTimeWhenATaskIsCompleted(); $this->assertFalse($value); $value = AccountsModule::shouldUpdateLatestActivityDateTimeWhenANoteIsCreated(); $this->assertFalse($value); $value = AccountsModule::shouldUpdateLatestActivityDateTimeWhenAnEmailIsSentOrArchived(); $this->assertFalse($value); $value = AccountsModule::shouldUpdateLatestActivityDateTimeWhenAMeetingIsInThePast(); $this->assertFalse($value); }
public function testResolveMenuItemsForLanguageLocalizationIsRecursive() { Yii::app()->user->userModel = User::getByUsername('super'); $metadata = AccountsModule::getMetadata(); $backupMetadata = $metadata; $metadata['global']['shortcutsCreateMenuItems'] = array(array('label' => "eval:Zurmo::t('AccountsModule', 'AccountsModulePluralLabel', \$translationParams)", 'url' => array('/accounts/default/create'), 'right' => AccountsModule::RIGHT_CREATE_ACCOUNTS, 'mobile' => true)); AccountsModule::setMetadata($metadata); $menuItems = MenuUtil::getAccessibleShortcutsCreateMenuByCurrentUser(); $compareData = array('label' => 'Create', 'url' => null, 'items' => array(array('label' => 'Accounts', 'url' => array('/accounts/default/create'), 'right' => AccountsModule::RIGHT_CREATE_ACCOUNTS, 'mobile' => true), array('label' => 'Contact', 'url' => array('/contacts/default/create'), 'right' => ContactsModule::RIGHT_CREATE_CONTACTS, 'mobile' => true), array('label' => 'Conversation', 'url' => array('/conversations/default/create'), 'right' => ConversationsModule::RIGHT_CREATE_CONVERSATIONS, 'mobile' => true), array('label' => 'Lead', 'url' => array('/leads/default/create'), 'right' => LeadsModule::RIGHT_CREATE_LEADS, 'mobile' => true), array('label' => 'Mission', 'url' => array('/missions/default/create'), 'right' => MissionsModule::RIGHT_CREATE_MISSIONS, 'mobile' => true), array('label' => 'Opportunity', 'url' => array('/opportunities/default/create'), 'right' => OpportunitiesModule::RIGHT_CREATE_OPPORTUNITIES, 'mobile' => true), array('label' => 'Report', 'url' => array('/reports/default/selectType'), 'right' => ReportsModule::RIGHT_CREATE_REPORTS, 'mobile' => false))); $this->assertEquals($compareData, $menuItems); AccountsModule::setMetadata($backupMetadata); }
/** * Action called in the event that the mass delete quantity is larger than the pageSize. * This action is called after the pageSize quantity has been delted and continues to be * called until the mass delete action is complete. For example, if there are 20 records to delete * and the pageSize is 5, then this action will be called 3 times. The first 5 are updated when * the actionMassDelete is called upon the initial form submission. */ public function actionMassDeleteProgress() { $pageSize = Yii::app()->pagination->resolveActiveForCurrentUserByType('massDeleteProgressPageSize'); $account = new Account(false); $dataProvider = $this->getDataProviderByResolvingSelectAllFromGet(new AccountsSearchForm($account), $pageSize, Yii::app()->user->userModel->id, null, 'AccountsSearchView'); $this->processMassDeleteProgress('Account', $pageSize, AccountsModule::getModuleLabelByTypeAndLanguage('Plural'), $dataProvider); }
/** * Test if all deleted items was pulled from read permission tables via API. * Please note that here we do not test if data are inserted in read permission tables correctly, that is * part of read permission subscription tests * @throws NotFoundException */ public function atestGetDeletedAccounts() { $timestamp = time(); sleep(1); $super = User::getByUsername('super'); Yii::app()->user->userModel = $super; $peter = UserTestHelper::createBasicUser('Peter'); $peter->setRight('UsersModule', UsersModule::RIGHT_LOGIN_VIA_WEB_API); $peter->setRight('AccountsModule', AccountsModule::getAccessRight()); $this->assertTrue($peter->save()); $this->deleteAllModelsAndRecordsFromReadPermissionTable('Account'); $job = new ReadPermissionSubscriptionUpdateJob(); $account1 = AccountTestHelper::createAccountByNameForOwner('Account1', $super); $account2 = AccountTestHelper::createAccountByNameForOwner('Account2', $super); $account3 = AccountTestHelper::createAccountByNameForOwner('Account3', $super); $this->assertTrue($job->run()); sleep(1); $accountId1 = $account1->id; $accountId2 = $account2->id; $accountId3 = $account3->id; $account1->delete(); $account2->delete(); $account3->delete(); $this->assertTrue($job->run()); $authenticationData = $this->login(); $headers = array('Accept: application/json', 'ZURMO_SESSION_ID: ' . $authenticationData['sessionId'], 'ZURMO_TOKEN: ' . $authenticationData['token'], 'ZURMO_API_REQUEST_TYPE: REST'); $data = array('userId' => $super->id, 'sinceTimestamp' => $timestamp, 'pagination' => array('pageSize' => 2, 'page' => 1)); $response = $this->createApiCallWithRelativeUrl('getDeletedItems/', 'POST', $headers, array('data' => $data)); $response = json_decode($response, true); $this->assertEquals(3, $response['data']['totalCount']); $this->assertEquals(2, $response['data']['pageSize']); $this->assertEquals(1, $response['data']['currentPage']); $this->assertContains($accountId1, $response['data']['items']); $this->assertContains($accountId2, $response['data']['items']); $data = array('userId' => $super->id, 'sinceTimestamp' => 0, 'pagination' => array('pageSize' => 2, 'page' => 2)); $response = $this->createApiCallWithRelativeUrl('getDeletedItems/', 'POST', $headers, array('data' => $data)); $response = json_decode($response, true); $this->assertEquals(3, $response['data']['totalCount']); $this->assertEquals(2, $response['data']['pageSize']); $this->assertEquals(2, $response['data']['currentPage']); $this->assertContains($accountId3, $response['data']['items']); // Check with owner change $this->deleteAllModelsAndRecordsFromReadPermissionTable('Account'); $account1 = AccountTestHelper::createAccountByNameForOwner('Account1', $super); $account2 = AccountTestHelper::createAccountByNameForOwner('Account2', $super); $this->assertTrue($job->run()); sleep(2); $account1->owner = $peter; $this->assertTrue($account1->save()); sleep(1); $this->assertTrue($job->run()); sleep(2); $data = array('sinceTimestamp' => $timestamp, 'pagination' => array('pageSize' => 2, 'page' => 1)); $response = $this->createApiCallWithRelativeUrl('getDeletedItems/', 'POST', $headers, array('data' => $data)); $response = json_decode($response, true); $this->assertEquals(0, $response['data']['totalCount']); $response = $this->createApiCallWithRelativeUrl('getCreatedItems/', 'POST', $headers, array('data' => $data)); $response = json_decode($response, true); $this->assertEquals(1, $response['data']['totalCount']); $authenticationData = $this->login('peter', 'peter'); $headers = array('Accept: application/json', 'ZURMO_SESSION_ID: ' . $authenticationData['sessionId'], 'ZURMO_TOKEN: ' . $authenticationData['token'], 'ZURMO_API_REQUEST_TYPE: REST'); $response = $this->createApiCallWithRelativeUrl('getDeletedItems/', 'POST', $headers, array('data' => $data)); $response = json_decode($response, true); $this->assertEquals(0, $response['data']['totalCount']); $response = $this->createApiCallWithRelativeUrl('getCreatedItems/', 'POST', $headers, array('data' => $data)); $response = json_decode($response, true); $this->assertEquals(1, $response['data']['totalCount']); }
/** * @depends testListAccounts */ public function testUnprivilegedUserViewUpdateDeleteAcounts() { Yii::app()->user->userModel = User::getByUsername('super'); $notAllowedUser = UserTestHelper::createBasicUser('Steven'); $notAllowedUser->setRight('UsersModule', UsersModule::RIGHT_LOGIN_VIA_WEB_API); $this->assertTrue($notAllowedUser->save()); // Test with unprivileged user to view, edit and delete account. $authenticationData = $this->login('steven', 'steven'); $headers = array('Accept: application/xml', 'ZURMO_SESSION_ID: ' . $authenticationData['sessionId'], 'ZURMO_TOKEN: ' . $authenticationData['token'], 'ZURMO_API_REQUEST_TYPE: REST'); $everyoneGroup = Group::getByName(Group::EVERYONE_GROUP_NAME); $this->assertTrue($everyoneGroup->save()); $accounts = Account::getByName('My Company 2'); $this->assertEquals(1, count($accounts)); $data['name'] = "My Company 3"; // Check first if user doesn't have rights. $response = ApiRestTestHelper::createXmlApiCall($this->serverUrl . '/test.php/accounts/account/api/read/' . $accounts[0]->id, 'GET', $headers); $response = XML2Array::createArray($response); $this->assertEquals(ApiResponse::STATUS_FAILURE, $response['status']); $this->assertEquals('You do not have rights to perform this action.', $response['message']); $response = ApiRestTestHelper::createXmlApiCall($this->serverUrl . '/test.php/accounts/account/api/update/' . $accounts[0]->id, 'PUT', $headers, array('data' => $data)); $response = XML2Array::createArray($response); $this->assertEquals(ApiResponse::STATUS_FAILURE, $response['status']); $this->assertEquals('You do not have rights to perform this action.', $response['message']); $response = ApiRestTestHelper::createXmlApiCall($this->serverUrl . '/test.php/accounts/account/api/delete/' . $accounts[0]->id, 'DELETE', $headers); $response = XML2Array::createArray($response); $this->assertEquals(ApiResponse::STATUS_FAILURE, $response['status']); $this->assertEquals('You do not have rights to perform this action.', $response['message']); //now check if user have rights, but no permissions. $notAllowedUser->setRight('AccountsModule', AccountsModule::getAccessRight()); $notAllowedUser->setRight('AccountsModule', AccountsModule::getCreateRight()); $notAllowedUser->setRight('AccountsModule', AccountsModule::getDeleteRight()); $saved = $notAllowedUser->save(); $this->assertTrue($saved); $response = ApiRestTestHelper::createXmlApiCall($this->serverUrl . '/test.php/accounts/account/api/read/' . $accounts[0]->id, 'GET', $headers); $response = XML2Array::createArray($response); $this->assertEquals(ApiResponse::STATUS_FAILURE, $response['status']); $this->assertEquals('You do not have permissions for this action.', $response['message']); $response = ApiRestTestHelper::createXmlApiCall($this->serverUrl . '/test.php/accounts/account/api/update/' . $accounts[0]->id, 'PUT', $headers, array('data' => $data)); $response = XML2Array::createArray($response); $this->assertEquals(ApiResponse::STATUS_FAILURE, $response['status']); $this->assertEquals('You do not have permissions for this action.', $response['message']); $response = ApiRestTestHelper::createXmlApiCall($this->serverUrl . '/test.php/accounts/account/api/delete/' . $accounts[0]->id, 'DELETE', $headers); $response = XML2Array::createArray($response); $this->assertEquals(ApiResponse::STATUS_FAILURE, $response['status']); $this->assertEquals('You do not have permissions for this action.', $response['message']); // Test with privileged user $authenticationData = $this->login(); $headers = array('Accept: application/xml', 'ZURMO_SESSION_ID: ' . $authenticationData['sessionId'], 'ZURMO_TOKEN: ' . $authenticationData['token'], 'ZURMO_API_REQUEST_TYPE: REST'); unset($data); $data['explicitReadWriteModelPermissions'] = array('type' => ExplicitReadWriteModelPermissionsUtil::MIXED_TYPE_EVERYONE_GROUP); $response = ApiRestTestHelper::createXmlApiCall($this->serverUrl . '/test.php/accounts/account/api/update/' . $accounts[0]->id, 'PUT', $headers, array('data' => $data)); $response = XML2Array::createArray($response); $this->assertEquals(ApiResponse::STATUS_SUCCESS, $response['status']); $authenticationData = $this->login('steven', 'steven'); $headers = array('Accept: application/xml', 'ZURMO_SESSION_ID: ' . $authenticationData['sessionId'], 'ZURMO_TOKEN: ' . $authenticationData['token'], 'ZURMO_API_REQUEST_TYPE: REST'); $response = ApiRestTestHelper::createXmlApiCall($this->serverUrl . '/test.php/accounts/account/api/read/' . $accounts[0]->id, 'GET', $headers); $response = XML2Array::createArray($response); $this->assertEquals(ApiResponse::STATUS_SUCCESS, $response['status']); unset($data); $data['name'] = "My Company 3"; $response = ApiRestTestHelper::createXmlApiCall($this->serverUrl . '/test.php/accounts/account/api/update/' . $accounts[0]->id, 'PUT', $headers, array('data' => $data)); $response = XML2Array::createArray($response); $this->assertEquals(ApiResponse::STATUS_SUCCESS, $response['status']); $this->assertEquals('My Company 3', $response['data']['name']); $response = ApiRestTestHelper::createXmlApiCall($this->serverUrl . '/test.php/accounts/account/api/delete/' . $accounts[0]->id, 'DELETE', $headers); $response = XML2Array::createArray($response); $this->assertEquals(ApiResponse::STATUS_FAILURE, $response['status']); $this->assertEquals('You do not have permissions for this action.', $response['message']); // Test with privileged user $authenticationData = $this->login(); $headers = array('Accept: application/xml', 'ZURMO_SESSION_ID: ' . $authenticationData['sessionId'], 'ZURMO_TOKEN: ' . $authenticationData['token'], 'ZURMO_API_REQUEST_TYPE: REST'); //Test Delete $response = ApiRestTestHelper::createXmlApiCall($this->serverUrl . '/test.php/accounts/account/api/delete/' . $accounts[0]->id, 'DELETE', $headers); $response = XML2Array::createArray($response); $this->assertEquals(ApiResponse::STATUS_SUCCESS, $response['status']); $response = ApiRestTestHelper::createXmlApiCall($this->serverUrl . '/test.php/accounts/account/api/read/' . $accounts[0]->id, 'GET', $headers); $response = XML2Array::createArray($response); $this->assertEquals(ApiResponse::STATUS_FAILURE, $response['status']); }
protected function resolveConfirmAlertInHtmlOptions($htmlOptions) { $htmlOptions['confirm'] = Zurmo::t('AccountsModule', 'Are you sure you want to delete this {modelLabel}?', array('{modelLabel}' => AccountsModule::getModuleLabelByTypeAndLanguage('SingularLowerCase'))); return $htmlOptions; }
public function testSuperUserAccountDefaultControllerActions() { $super = $this->logoutCurrentUserLoginNewUserAndGetByUsername('super'); //Default Controller actions requiring some sort of parameter via POST or GET //Load Account Modules Menu. $this->resetPostArray(); $this->setGetArray(array('moduleClassName' => 'AccountsModule')); $this->runControllerWithNoExceptionsAndGetContent('designer/default/modulesMenu'); //Load AttributesList for Account module. $this->resetPostArray(); $this->setGetArray(array('moduleClassName' => 'AccountsModule')); $this->runControllerWithNoExceptionsAndGetContent('designer/default/attributesList'); //Load ModuleLayoutsList for Account module. $this->resetPostArray(); $this->setGetArray(array('moduleClassName' => 'AccountsModule')); $this->runControllerWithNoExceptionsAndGetContent('designer/default/moduleLayoutsList'); //Load ModuleEdit view for each applicable module. $this->resetPostArray(); $this->setGetArray(array('moduleClassName' => 'AccountsModule')); $this->runControllerWithNoExceptionsAndGetContent('designer/default/moduleEdit'); //Now validate save with failed validation. $this->setGetArray(array('moduleClassName' => 'AccountsModule')); $this->setPostArray(array('ajax' => 'edit-form', 'AccountsModuleForm' => $this->createModuleEditBadValidationPostData())); $content = $this->runControllerWithExitExceptionAndGetContent('designer/default/moduleEdit'); //Now validate save with successful validation. $this->setGetArray(array('moduleClassName' => 'AccountsModule')); $this->setPostArray(array('ajax' => 'edit-form', 'AccountsModuleForm' => $this->createModuleEditGoodValidationPostData('acc new name'))); $content = $this->runControllerWithExitExceptionAndGetContent('designer/default/moduleEdit'); $this->assertEquals('[]', $content); //Now save successfully. $value = AccountsModule::shouldUpdateLatestActivityDateTimeWhenATaskIsCompleted(); $this->assertTrue($value); $value = AccountsModule::shouldUpdateLatestActivityDateTimeWhenANoteIsCreated(); $this->assertTrue($value); $value = AccountsModule::shouldUpdateLatestActivityDateTimeWhenAnEmailIsSentOrArchived(); $this->assertTrue($value); $value = AccountsModule::shouldUpdateLatestActivityDateTimeWhenAMeetingIsInThePast(); $this->assertTrue($value); $postDataForForm = $this->createModuleEditGoodValidationPostData('acc new name'); $postDataForForm['updateLatestActivityDateTimeWhenATaskIsCompleted'] = ''; $postDataForForm['updateLatestActivityDateTimeWhenANoteIsCreated'] = ''; $postDataForForm['updateLatestActivityDateTimeWhenAnEmailIsSentOrArchived'] = ''; $postDataForForm['updateLatestActivityDateTimeWhenAMeetingIsInThePast'] = ''; $this->setGetArray(array('moduleClassName' => 'AccountsModule')); $this->setPostArray(array('save' => 'Save', 'AccountsModuleForm' => $postDataForForm)); $this->runControllerWithRedirectExceptionAndGetContent('designer/default/moduleEdit'); //Now confirm everything did in fact save correctly. $this->assertEquals('Acc New Name', AccountsModule::getModuleLabelByTypeAndLanguage('Singular')); $this->assertEquals('Acc New Names', AccountsModule::getModuleLabelByTypeAndLanguage('Plural')); $this->assertEquals('acc new name', AccountsModule::getModuleLabelByTypeAndLanguage('SingularLowerCase')); $this->assertEquals('acc new names', AccountsModule::getModuleLabelByTypeAndLanguage('PluralLowerCase')); $value = AccountsModule::shouldUpdateLatestActivityDateTimeWhenATaskIsCompleted(); $this->assertFalse($value); $value = AccountsModule::shouldUpdateLatestActivityDateTimeWhenANoteIsCreated(); $this->assertFalse($value); $value = AccountsModule::shouldUpdateLatestActivityDateTimeWhenAnEmailIsSentOrArchived(); $this->assertFalse($value); $value = AccountsModule::shouldUpdateLatestActivityDateTimeWhenAMeetingIsInThePast(); $this->assertFalse($value); //Load LayoutEdit for each applicable module and applicable layout $this->resetPostArray(); $this->setGetArray(array('moduleClassName' => 'AccountsModule', 'viewClassName' => 'AccountEditAndDetailsView')); $this->runControllerWithNoExceptionsAndGetContent('designer/default/LayoutEdit'); $this->setGetArray(array('moduleClassName' => 'AccountsModule', 'viewClassName' => 'AccountsListView')); $this->runControllerWithNoExceptionsAndGetContent('designer/default/LayoutEdit'); $this->setGetArray(array('moduleClassName' => 'AccountsModule', 'viewClassName' => 'AccountsMassEditView')); $this->runControllerWithNoExceptionsAndGetContent('designer/default/LayoutEdit'); $this->setGetArray(array('moduleClassName' => 'AccountsModule', 'viewClassName' => 'AccountsModalListView')); $this->runControllerWithNoExceptionsAndGetContent('designer/default/LayoutEdit'); $this->setGetArray(array('moduleClassName' => 'AccountsModule', 'viewClassName' => 'AccountsModalSearchView')); $this->runControllerWithNoExceptionsAndGetContent('designer/default/LayoutEdit'); $this->setGetArray(array('moduleClassName' => 'AccountsModule', 'viewClassName' => 'AccountsRelatedListView')); $this->runControllerWithNoExceptionsAndGetContent('designer/default/LayoutEdit'); $this->setGetArray(array('moduleClassName' => 'AccountsModule', 'viewClassName' => 'AccountsSearchView')); $this->runControllerWithNoExceptionsAndGetContent('designer/default/LayoutEdit'); $this->setGetArray(array('moduleClassName' => 'AccountsModule', 'viewClassName' => 'AccountConvertToView')); $this->runControllerWithNoExceptionsAndGetContent('designer/default/LayoutEdit'); }
public function testResolveMenuItemsForLanguageLocalizationIsRecursive() { Yii::app()->user->userModel = User::getByUsername('super'); $metadata = AccountsModule::getMetadata(); $backupMetadata = $metadata; $metadata['global']['shortcutsCreateMenuItems'] = array(array('label' => "eval:Zurmo::t('AccountsModule', 'AccountsModulePluralLabel', \$translationParams)", 'url' => array('/accounts/default/create'), 'right' => AccountsModule::RIGHT_CREATE_ACCOUNTS, 'mobile' => true)); AccountsModule::setMetadata($metadata); $menuItems = MenuUtil::getAccessibleShortcutsCreateMenuByCurrentUser(); $taskMenu = $menuItems['items'][7]; $this->assertEquals('Task', $taskMenu['label']); unset($menuItems['items'][7]); $compareData = array('label' => 'Create', 'url' => null, 'items' => array(array('label' => 'Accounts', 'url' => array('/accounts/default/create'), 'right' => AccountsModule::RIGHT_CREATE_ACCOUNTS, 'mobile' => true), array('label' => 'Contact', 'url' => array('/contacts/default/create'), 'right' => ContactsModule::RIGHT_CREATE_CONTACTS, 'mobile' => true), array('label' => 'Conversation', 'url' => array('/conversations/default/create'), 'right' => ConversationsModule::RIGHT_CREATE_CONVERSATIONS, 'mobile' => true), array('label' => 'Lead', 'url' => array('/leads/default/create'), 'right' => LeadsModule::RIGHT_CREATE_LEADS, 'mobile' => true), array('label' => 'Mission', 'url' => array('/missions/default/create'), 'right' => MissionsModule::RIGHT_CREATE_MISSIONS, 'mobile' => true), array('label' => 'Opportunity', 'url' => array('/opportunities/default/create'), 'right' => OpportunitiesModule::RIGHT_CREATE_OPPORTUNITIES, 'mobile' => true), array('label' => 'Report', 'url' => array('/reports/default/selectType'), 'right' => ReportsModule::RIGHT_CREATE_REPORTS, 'mobile' => false), array('label' => 'Project', 'url' => array('/projects/default/create'), 'right' => ProjectsModule::RIGHT_CREATE_PROJECTS, 'mobile' => true))); // Re keying and slice the items from main array as we just unset the index 7 menuItem and we may have // items that are below that e.g. index 8, 9, 10, ... // If we don't do this the keys will mismatch and assertEquals will fail. $menuItemsReKeyedItems = array_values($menuItems['items']); unset($menuItems['items']); $compareDataReKeyedItems = array_values($compareData['items']); unset($compareData['items']); $this->assertEquals($compareData, $menuItems); $this->assertEquals($compareDataReKeyedItems, $menuItemsReKeyedItems); AccountsModule::setMetadata($backupMetadata); }