/**
  * @dataProvider providerStripColonSting
  * @ticket 41983
  */
 public function testStripColonString($string, $returnedString)
 {
     $langpack = new SugarTestLangPackCreator();
     $langpack->setModString('LBL_TEST_JS_ESCAPED_STRING', $string, 'Contacts');
     $langpack->save();
     $smarty = new Sugar_Smarty();
     $this->assertEquals($returnedString, smarty_function_sugar_translate(array('label' => 'LBL_TEST_JS_ESCAPED_STRING', 'module' => 'Contacts', 'trimColon' => false), $smarty));
 }
Exemplo n.º 2
0
 public function testReturnCorrectAutoRefreshOptionsWhenMinIsNotSet()
 {
     $langpack = new SugarTestLangPackCreator();
     $langpack->setAppListString('dashlet_auto_refresh_options', array('-1' => 'Never', '30' => 'Every 30 seconds', '60' => 'Every 1 minute', '180' => 'Every 3 minutes', '300' => 'Every 5 minutes', '600' => 'Every 10 minutes'));
     $langpack->save();
     $dashlet = new DashletAutoRefreshTestMock('unit_test_run');
     $options = $dashlet->getAutoRefreshOptions();
     $this->assertEquals(array('-1' => 'Never', '30' => 'Every 30 seconds', '60' => 'Every 1 minute', '180' => 'Every 3 minutes', '300' => 'Every 5 minutes', '600' => 'Every 10 minutes'), $options);
     unset($langpack);
 }
Exemplo n.º 3
0
 /**
  * @ticket 36744
  */
 public function testFormatEnumField()
 {
     $langpack = new SugarTestLangPackCreator();
     $langpack->setAppListString('case_priority_dom', array('P1' => 'High', 'P2' => 'Medium', 'P3' => 'Low'));
     $langpack->save();
     $GLOBALS['app_list_strings'] = return_app_list_strings_language($GLOBALS['current_language']);
     $fieldDef = array('name' => 'priority', 'vname' => 'LBL_PRIORITY', 'type' => 'enum', 'options' => 'case_priority_dom', 'len' => 25, 'audited' => true, 'comment' => 'The priority of the case');
     $field_value = "P2";
     require_once 'include/SugarFields/SugarFieldHandler.php';
     $sfr = SugarFieldHandler::getSugarField('enum');
     $this->assertEquals(trim($sfr->formatField($field_value, $fieldDef)), 'Medium');
 }
Exemplo n.º 4
0
 /**
  * @ticket 43080
  */
 public function testSearchGrabsMore()
 {
     $app_strings = return_application_language($GLOBALS['current_language']);
     $this->assertTrue(array_key_exists('LBL_SEARCH_MORE', $app_strings));
     $langpack = new SugarTestLangPackCreator();
     $langpack->setAppString('LBL_SEARCH_MORE', 'XXmoreXX');
     $langpack->save();
     $result = array('Foo' => array('data' => array(array('ID' => '1', 'NAME' => 'recordname')), 'pageData' => array('offsets' => array('total' => 100, 'next' => 0), 'bean' => array('moduleDir' => 'Foo'))));
     $sugarSpot = $this->getMock('SugarSpot', array('_performSearch'));
     $sugarSpot->expects($this->any())->method('_performSearch')->will($this->returnValue($result));
     $returnValue = $sugarSpot->searchAndDisplay('', '');
     $this->assertNotContains('(99 more)', $returnValue);
     $this->assertContains('(99 XXmoreXX)', $returnValue);
 }
 public function testUndoStringsChangesMade()
 {
     $langpack = new SugarTestLangPackCreator();
     $app_strings = return_application_language($GLOBALS['current_language']);
     $prevString = $app_strings['NTC_WELCOME'];
     $langpack->setAppString('NTC_WELCOME', 'stringname');
     $langpack->save();
     $app_strings = return_application_language($GLOBALS['current_language']);
     $this->assertEquals($app_strings['NTC_WELCOME'], 'stringname');
     // call the destructor directly to undo our changes
     unset($langpack);
     $app_strings = return_application_language($GLOBALS['current_language']);
     $this->assertEquals($app_strings['NTC_WELCOME'], $prevString);
 }
 /**
  * @ticket 27046
  */
 public function testRelateWithInvalidDataFormatting()
 {
     $langpack = new SugarTestLangPackCreator();
     $langpack->setAppListString('checkbox_dom', array('' => '', '1' => 'Yep', '2' => 'Nada'));
     $langpack->save();
     $GLOBALS['app_list_strings'] = return_app_list_strings_language($GLOBALS['current_language']);
     $account_name = 'test case category' . date("YmdHis");
     $focus = new Import_Bug27046_Mock();
     $vardef = array('name' => 'account_name', 'rname' => 'name', 'id_name' => 'account_id', 'vname' => 'LBL_ACCOUNT_NAME', 'join_name' => 'accounts', 'type' => 'relate', 'link' => 'accounts_link', 'table' => 'accounts', 'isnull' => 'true', 'module' => 'Import_Bug27046_Mock', 'dbType' => 'varchar', 'len' => '255', 'source' => 'non-db', 'rtype' => 'int');
     // setup
     $beanList = array();
     require 'include/modules.php';
     $beanList['Import_Bug27046_Mock'] = 'Import_Bug27046_Mock';
     $beanFiles['Import_Bug27046_Mock'] = 'modules/Accounts/Account.php';
     $GLOBALS['beanList'] = $beanList;
     $GLOBALS['beanFiles'] = $beanFiles;
     $this->assertFalse($this->_ifs->relate($account_name, $vardef, $focus), 'Should return false since field format is invalid');
     // teardown
     unset($GLOBALS['beanList']);
     $result = $GLOBALS['db']->query("SELECT id FROM accounts where name = '{$account_name}'");
     $relaterow = $focus->db->fetchByAssoc($result);
     $this->assertNull($relaterow, 'Record should not have been created');
     if ($relaterow) {
         $GLOBALS['db']->query("DELETE FROM accounts where id = '{$relaterow['id']}'");
     }
 }
Exemplo n.º 7
0
 /**
  * @group bug40999
  * Check if empty status is handled correctly
  */
 public function testCallEmptyStatusLangConfig()
 {
     $this->markTestIncomplete("This test is failing on Jenkins only.  Disabling for now");
     $langpack = new SugarTestLangPackCreator();
     $langpack->setModString('LBL_DEFAULT_STATUS', 'FAILED!', 'Calls');
     $langpack->save();
     $GLOBALS['mod_strings'] = return_module_language($GLOBALS['current_language'], 'Calls');
     $call = new Call();
     $call->field_defs['status']['default'] = 'My Call';
     $call = new Call();
     $this->callid = $call->id = create_guid();
     $call->new_with_id = 1;
     $call->save();
     // then retrieve
     $call = new Call();
     $call->retrieve($this->callid);
     $this->assertEquals('My Call', $call->status);
 }