phone.se.test 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. <?php
  2. class SEPhoneNumberTestCase extends DrupalWebTestCase {
  3. /**
  4. * Implementation of getInfo()
  5. *
  6. */
  7. public static function getInfo() {
  8. return array(
  9. 'name' => t('Sweden Phone number test'),
  10. 'description' => t('Tests various valid and invalid Sweden phone numbers for validity'),
  11. 'group' => t('Phone')
  12. );
  13. }
  14. public function testPhoneSEValid() {
  15. $this->assertTrue(valid_phone_number('se', '+46 8 123 456 78'), t('Test valid'));
  16. $this->assertTrue(valid_phone_number('se', '08-123 456 78'), t('Test valid'));
  17. $this->assertTrue(valid_phone_number('se', '0123-456 78'), t('Test valid'));
  18. $this->assertTrue(valid_phone_number('se', '031-3224562'), t('Test valid'));
  19. $this->assertTrue(valid_phone_number('se', '0737234264'), t('Test valid'));
  20. $this->assertTrue(valid_phone_number('se', '073-5647829'), t('Test valid'));
  21. $this->assertTrue(valid_phone_number('se', '19740609-7845'), t('Test valid'));
  22. $this->assertTrue(valid_phone_number('se', '19811116-7845'), t('Test valid'));
  23. $this->assertTrue(valid_phone_number('se', '20010913-7598'), t('Test valid'));
  24. }
  25. public function testPhoneSEInvalid() {
  26. $this->assertFalse(valid_phone_number('se', '46 08-123 456 78'), t('Test invalid'));
  27. $this->assertFalse(valid_phone_number('se', '08 123 456 78'), t('Test invalid '));
  28. $this->assertFalse(valid_phone_number('se', '0123 456 78'), t('Test invalid '));
  29. $this->assertFalse(valid_phone_number('se', '34348abc'), t('Test invalid'));
  30. $this->assertFalse(valid_phone_number('se', '452643242343432432435643623432'), t('Test invalid '));
  31. $this->assertFalse(valid_phone_number('se', '532'), t('Test invalid '));
  32. $this->assertFalse(valid_phone_number('se', '21003612-9999'), t('Test invalid '));
  33. $this->assertFalse(valid_phone_number('se', '18790505-45458'), t('Test invalid '));
  34. $this->assertFalse(valid_phone_number('se', '19740641-5559'), t('Test invalid '));
  35. }
  36. public function testPhoneSEFormatting() {
  37. //$this->assertEqual(format_phone_number('se', '+6421123456', null), '+64 21 123 456', t('Check international mobile format'));
  38. }
  39. }