phone.sg.test 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. <?php
  2. class SGPhoneNumberTestCase extends DrupalWebTestCase {
  3. /**
  4. * Implementation of getInfo()
  5. *
  6. */
  7. public static function getInfo() {
  8. return array(
  9. 'name' => t('Singapore Phone number test'),
  10. 'description' => t('Tests various valid and invalid Singapore phone numbers for validity'),
  11. 'group' => t('Phone')
  12. );
  13. }
  14. public function testPhoneSGValid() {
  15. $this->assertTrue(valid_phone_number('sg', '61234567'), "'61234567' should be valid");
  16. $this->assertTrue(valid_phone_number('sg', '63829324'), "'63829324' should be valid");
  17. $this->assertTrue(valid_phone_number('sg', '67654321'), "'67654321' should be valid");
  18. $this->assertTrue(valid_phone_number('sg', '+6561234567'), "'+6561234567' should be valid");
  19. $this->assertTrue(valid_phone_number('sg', '+6581234567'), "'+6581234567' should be valid");
  20. $this->assertTrue(valid_phone_number('sg', '+6591234567'), "'+6591234567' should be valid");
  21. $this->assertTrue(valid_phone_number('sg', '+65 61234567'), "'+65 61234567' should be valid");
  22. $this->assertTrue(valid_phone_number('sg', '+65 81234567'), "'+65 81234567' should be valid");
  23. $this->assertTrue(valid_phone_number('sg', '+65 91234567'), "'+65 91234567' should be valid");
  24. $this->assertTrue(valid_phone_number('sg', '61234567'), "'61234567' should be valid");
  25. $this->assertTrue(valid_phone_number('sg', '81234567'), "'81234567' should be valid");
  26. $this->assertTrue(valid_phone_number('sg', '91234567'), "'91234567' should be valid");
  27. }
  28. public function testPhoneSGInvalid() {
  29. $this->assertFalse(valid_phone_number('sg', '6123-4567'), t('Test invalid '));
  30. $this->assertFalse(valid_phone_number('sg', '6-CALL-CPY'), t('Test invalid '));
  31. $this->assertFalse(valid_phone_number('sg', '6123abcd'), t('Test invalid '));
  32. }
  33. public function testPhoneSGFormatting() {
  34. //$this->assertEqual(format_phone_number('sg', '+6421123456', null), '+64 21 123 456', t('Check international mobile format'));
  35. }
  36. }