phone.pa.test 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. <?php
  2. class PhonePanamanianTest extends DrupalWebTestCase {
  3. public static function getInfo() {
  4. return array(
  5. 'name' => t('Panamanian phone'),
  6. 'description' => t('Executes test suite for validating / formatting Panamanian phone number.'),
  7. 'group' => t('Phone'),
  8. );
  9. }
  10. function testValidatingPanamenianPhoneNumber() {
  11. $this->assertTrue(valid_phone_number('pa', '+507 260-4334'), '+507 260-4334 should be valid');
  12. $this->assertTrue(valid_phone_number('pa', '+507 2604334'), '+507 2604334 should be valid');
  13. $this->assertTrue(valid_phone_number('pa', '+507 260 4334'), '+507 260 4334 should be valid');
  14. $this->assertTrue(valid_phone_number('pa', '00507 2603133'), '00507 2603133 should be valid');
  15. $this->assertTrue(valid_phone_number('pa', '00507 260-3133'), '00507 260-3133 should be valid');
  16. $this->assertTrue(valid_phone_number('pa', '00507 260 4334'), '00507 260 4334 should be valid');
  17. $this->assertTrue(valid_phone_number('pa', '260 3133'), '260 3133 should be valid');
  18. $this->assertTrue(valid_phone_number('pa', '260-3133'), '260-3133 should be valid');
  19. $this->assertTrue(valid_phone_number('pa', '2603133'), '2603133 should be valid');
  20. //Cellphones
  21. $this->assertTrue(valid_phone_number('pa', '+507 6545-4345'), '+507 6545-4345 should be valid');
  22. $this->assertTrue(valid_phone_number('pa', '+507 65454345'), '+507 65454345 should be valid');
  23. $this->assertTrue(valid_phone_number('pa', '+507 6545 4345'), '+507 6545 4345 should be valid');
  24. $this->assertTrue(valid_phone_number('pa', '00507 6545-4345'), '00507 6545-4345 should be valid');
  25. $this->assertTrue(valid_phone_number('pa', '00507 6545 4345'), '00507 6545 4345 should be valid');
  26. $this->assertTrue(valid_phone_number('pa', '00507 65454345'), '00507 65454345 should be valid');
  27. $this->assertTrue(valid_phone_number('pa', '6545-4345'), '6545-4345 should be valid');
  28. $this->assertTrue(valid_phone_number('pa', '6545 4345'), '6545 4345 should be valid');
  29. $this->assertTrue(valid_phone_number('pa', '65454345'), '65454345 should be valid');
  30. //Invalid
  31. $this->assertFalse(valid_phone_number('pa', '35343'), '35343 should not be valid');
  32. $this->assertFalse(valid_phone_number('pa', '320-43'), '320-43 should not be valid');
  33. $this->assertTrue(valid_phone_number('pa', '(507) 435-3434'), '(507) 435-3434 should not be valid');
  34. }
  35. function testFormattingPanamenianPhoneNumber() {
  36. $this->assertEqual(format_phone_number('pa', '+507 260-4334'), '+507 260-4334', '+507 260-4334 format');
  37. $this->assertEqual(format_phone_number('pa', '+507 2604334'), '+507 260-4334', '+507 2604334 format');
  38. $this->assertEqual(format_phone_number('pa', '+507 260 4334'), '+507 260-4334', '+507 260 4334 format');
  39. $this->assertEqual(format_phone_number('pa', '00507 260-4334'), '+507 260-4334', '00507 260-4334 format');
  40. $this->assertEqual(format_phone_number('pa', '00507 2604334'), '+507 260-4334', '00507 2604334 format');
  41. $this->assertEqual(format_phone_number('pa', '00507 260 4334'), '+507 260-4334', '00507 260 4334 format');
  42. $this->assertEqual(format_phone_number('pa', '260-4334'), '260-4334', '260-4334 format');
  43. $this->assertEqual(format_phone_number('pa', '2604334'), '260-4334', '2604334 format');
  44. $this->assertEqual(format_phone_number('pa', '260 4334'), '260-4334', '260 4334 format');
  45. $this->assertEqual(format_phone_number('pa', '260 4334', array('phone_country_code' => 1)), '+507 260-4334', 'add +507 to 260 4334 format');
  46. //Cellphones
  47. $this->assertEqual(format_phone_number('pa', '00507 6464 4334'), '+507 6464-4334', '6464 4334 format');
  48. $this->assertEqual(format_phone_number('pa', '00507 6464-4334'), '+507 6464-4334', '00507 6464-4334 format');
  49. $this->assertEqual(format_phone_number('pa', '00507 64644334'), '+507 6464-4334', '00507 64644334 format');
  50. $this->assertEqual(format_phone_number('pa', '+507 6464 4334'), '+507 6464-4334', '+507 6464 4334 format');
  51. $this->assertEqual(format_phone_number('pa', '6464 4334'), '6464-4334', '6464 4334 format');
  52. $this->assertEqual(format_phone_number('pa', '64644334'), '6464-4334', '6464-4334 format');
  53. $this->assertEqual(format_phone_number('pa', '6464 4334', array('phone_country_code' => 1)), '+507 6464-4334', 'add +507 to 6464 4334 format');
  54. }
  55. }