phone.ua.test 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. <?php
  2. class UAPhoneNumberTestCase extends DrupalWebTestCase {
  3. /**
  4. * Implementation of getInfo()
  5. *
  6. */
  7. public static function getInfo() {
  8. return array(
  9. 'name' => t('Ukraine Phone number test'),
  10. 'description' => t('Tests various valid and invalid Ukraine phone numbers for validity'),
  11. 'group' => t('Phone')
  12. );
  13. }
  14. function setUp() {
  15. parent::setUp();
  16. }
  17. public function testPhoneUAValid() {
  18. $this->assertTrue(valid_phone_number('ua', '+38-044-283-93-57'), t('Kyiv landline test'));
  19. $this->assertTrue(valid_phone_number('ua', '(044)2839357'), t('Kyiv landline test'));
  20. $this->assertTrue(valid_phone_number('ua', '+380442839357'), t('Kyiv landline test'));
  21. $this->assertTrue(valid_phone_number('ua', '+38 (044)537-28-07'), t('Kyiv landline test'));
  22. $this->assertTrue(valid_phone_number('ua', '044 537-28-07'), t('Kyiv landline test'));
  23. $this->assertTrue(valid_phone_number('ua', '+38 032 2724042 '), t('Lviv landline test'));
  24. $this->assertTrue(valid_phone_number('ua', '+380623621047'), t('Yasinovata landline test'));
  25. }
  26. public function testPhoneUAInvalid() {
  27. $this->assertFalse(valid_phone_number('ua', '+380117777777'), t('Test with noexist citycode 011'));
  28. $this->assertFalse(valid_phone_number('ua', '+380711234567'), t('Test with noexist citycode 071'));
  29. $this->assertFalse(valid_phone_number('ua', '+38044123456'), t('Test with short phone'));
  30. $this->assertFalse(valid_phone_number('ua', '044123456'), t('Test with short phone'));
  31. $this->assertFalse(valid_phone_number('ua', '+3804412345678'), t('Test with long phone'));
  32. $this->assertFalse(valid_phone_number('ua', '04412345678'), t('Test with long phone'));
  33. $this->assertFalse(valid_phone_number('ua', '8044223-95-26'), t('Test with obsolete leading 8 notation'));
  34. }
  35. public function testPhoneUAFormatting() {
  36. //$this->assertEqual(format_phone_number('ua', '+6421123456', null), '+64 21 123 456', t('Check international mobile format'));
  37. }
  38. }