phone.cn.test 1.7 KB

123456789101112131415161718192021222324252627282930313233343536
  1. <?php
  2. class CNPhoneNumberTestCase extends DrupalWebTestCase {
  3. /**
  4. * Implementation of getInfo()
  5. *
  6. */
  7. public static function getInfo() {
  8. return array(
  9. 'name' => t('China People\'s Republic Phone number test'),
  10. 'description' => t('Tests various valid and invalid Chinese People\'s Republic phone numbers for validity'),
  11. 'group' => t('Phone')
  12. );
  13. }
  14. public function testPhoneCNValid() {
  15. $this->assertTrue(valid_phone_number('cn', '86-755-83998006'), t('Test valid - 86-755-83998006'));
  16. $this->assertTrue(valid_phone_number('cn', '86-10-5851 6688'), t('Test valid - 86-10-5851 6688'));
  17. $this->assertTrue(valid_phone_number('cn', '86-10-6512 4940'), t('Test valid - 86-10-6512 4940'));
  18. $this->assertTrue(valid_phone_number('cn', '+86 21 6103 2200'), t('Test valid - +86 21 6103 2200'));
  19. $this->assertTrue(valid_phone_number('cn', '+86 10.85.32.83.23'), t('Test valid - +86 10.85.32.83.23'));
  20. $this->assertTrue(valid_phone_number('cn', '755-83998006'), t('Test valid - 755-83998006'));
  21. $this->assertTrue(valid_phone_number('cn', '+86-10-5851 6688'), t('Test valid - +86-10-5851 6688'));
  22. $this->assertTrue(valid_phone_number('cn', '10.85.32.83.23'), t('Test valid - 10.85.32.83.23'));
  23. $this->assertTrue(valid_phone_number('cn', '13900000000'), t('Test valid - 13900000000'));
  24. $this->assertTrue(valid_phone_number('cn', '10-5851 6688'), t('Test valid - 10-5851 6688'));
  25. }
  26. public function testPhoneCNInvalid() {
  27. //$this->assertFalse(valid_phone_number('cn', '021 3012 3456'), t('Test invalid - 021 3012 3456'));
  28. }
  29. public function testPhoneCNFormatting() {
  30. //$this->assertEqual(format_phone_number('cn', '+6421123456', null), '+64 21 123 456', t('Check international mobile format'));
  31. }
  32. }