phone.it.test 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. <?php
  2. class ITPhoneNumberTestCase extends DrupalWebTestCase {
  3. /**
  4. * Implementation of getInfo()
  5. *
  6. */
  7. public static function getInfo() {
  8. return array(
  9. 'name' => t('Italia Phone number test'),
  10. 'description' => t('Tests various valid and invalid Italia phone numbers for validity'),
  11. 'group' => t('Phone')
  12. );
  13. }
  14. public function testPhoneITValid() {
  15. $this->assertTrue(valid_phone_number('it', '06/2034567'), t('Test valid - 06/2034567'));
  16. $this->assertTrue(valid_phone_number('it', '+39 02/123456'), t('Test valid - +39 02/123456'));
  17. $this->assertTrue(valid_phone_number('it', '02-343536'), t('Test valid - 02-343536'));
  18. $this->assertTrue(valid_phone_number('it', '02/343536'), t('Test valid - 02/343536'));
  19. $this->assertTrue(valid_phone_number('it', '02 343536'), t('Test valid - 02 343536'));
  20. $this->assertTrue(valid_phone_number('it', '+393381234567'), t('Test valid - +393381234567'));
  21. $this->assertTrue(valid_phone_number('it', '+39 3381234567'), t('Test valid - +39 3381234567'));
  22. $this->assertTrue(valid_phone_number('it', '+39 338 1234567'), t('Test valid - +39 338 1234567'));
  23. $this->assertTrue(valid_phone_number('it', '+39 338-1234567'), t('Test valid - +39 338-1234567'));
  24. $this->assertTrue(valid_phone_number('it', '3381234567'), t('Test valid - 3381234567'));
  25. $this->assertTrue(valid_phone_number('it', '3381234567'), t('Test valid - 3381234567'));
  26. $this->assertTrue(valid_phone_number('it', '338 1234567'), t('Test valid - 338 1234567'));
  27. $this->assertTrue(valid_phone_number('it', '338-1234567'), t('Test valid - 338-1234567'));
  28. }
  29. public function testPhoneITInvalid() {
  30. $this->assertFalse(valid_phone_number('it', '02a343536'), t('Test invalid - 02a343536'));
  31. $this->assertFalse(valid_phone_number('it', '02+343536'), t('Test invalid - 02+343536'));
  32. $this->assertFalse(valid_phone_number('it', '0039 338 1234567'), t('Test invalid - 0039 338 1234567'));
  33. $this->assertFalse(valid_phone_number('it', '(338)1234567'), t('Test invalid - (338)1234567'));
  34. }
  35. public function testPhoneITFormatting() {
  36. //$this->assertEqual(format_phone_number('it', '+6421123456', null), '+64 21 123 456', t('Check international mobile format'));
  37. }
  38. }