PageRenderTime 43ms CodeModel.GetById 17ms RepoModel.GetById 0ms app.codeStats 1ms

/tests/include/MassUpdateTest.php

https://github.com/item/sugarcrm_dev
PHP | 72 lines | 56 code | 7 blank | 9 comment | 6 complexity | 8ffa6def3eae7f725104e6fbd5465ac7 MD5 | raw file
Possible License(s): AGPL-3.0, LGPL-2.1
  1. <?php
  2. require_once 'include/MassUpdate.php';
  3. require_once 'include/dir_inc.php';
  4. class MassUpdateTest extends Sugar_PHPUnit_Framework_TestCase
  5. {
  6. public function setUp()
  7. {
  8. $GLOBALS['current_user'] = SugarTestUserUtilities::createAnonymousUser();
  9. $GLOBALS['app_strings'] = return_application_language($GLOBALS['current_language']);
  10. }
  11. public function tearDown()
  12. {
  13. SugarTestUserUtilities::removeAllCreatedAnonymousUsers();
  14. unset($GLOBALS['current_user']);
  15. unset($GLOBALS['app_strings']);
  16. }
  17. /**
  18. * @group bug12300
  19. */
  20. public function testAdddateWorksWithMultiByteCharacters()
  21. {
  22. $mass = new MassUpdate();
  23. $displayname = "开始日期:";
  24. $varname = "date_start";
  25. $result = $mass->addDate($displayname , $varname);
  26. $pos_f = strrpos($result, $GLOBALS['app_strings']['LBL_MASSUPDATE_DATE']);
  27. $this->assertTrue((bool) $pos_f);
  28. }
  29. /**
  30. * @group bug23900
  31. */
  32. public function testAddStatus()
  33. {
  34. $mass = new MassUpdate();
  35. $options = array (
  36. '10' => 'ten',
  37. '20' => 'twenty',
  38. '30' => 'thirty',
  39. );
  40. $result = $mass->addStatus('test_dom', 'test_dom', $options);
  41. preg_match_all('/value=[\'\"].*?[\'\"]/si', $result, $matches);
  42. $this->assertTrue(isset($matches));
  43. $this->assertTrue($matches[0][0] == "value=''");
  44. $this->assertTrue($matches[0][1] == "value='10'");
  45. $this->assertTrue($matches[0][3] == "value='30'");
  46. }
  47. /**
  48. * @group bug23900
  49. */
  50. public function testAddStatusMulti()
  51. {
  52. $mass = new MassUpdate();
  53. $options = array (
  54. '10' => 'ten',
  55. '20' => 'twenty',
  56. '30' => 'thirty',
  57. );
  58. $result = $mass->addStatusMulti('test_dom', 'test_dom', $options);
  59. preg_match_all('/value=[\'\"].*?[\'\"]/si', $result, $matches);
  60. $this->assertTrue(isset($matches));
  61. $this->assertTrue($matches[0][0] == "value=''");
  62. $this->assertTrue($matches[0][1] == "value='10'");
  63. $this->assertTrue($matches[0][3] == "value='30'");
  64. }
  65. }