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']); }
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); }
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); }