phone.br.test 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. <?php
  2. class BRPhoneNumberTestCase extends DrupalWebTestCase {
  3. /**
  4. * Implementation of getInfo()
  5. *
  6. */
  7. public static function getInfo() {
  8. return array(
  9. 'name' => t('Brazil Phone number test'),
  10. 'description' => t('Tests various valid and invalid Brazil phone numbers for validity'),
  11. 'group' => t('Phone')
  12. );
  13. }
  14. public function testPhoneBRValid() {
  15. $this->assertTrue(valid_phone_number('br', '(11) 1234-5678'), t('Test valid - (11) 1234-5678'));
  16. $this->assertTrue(valid_phone_number('br', '1234-5678 '), t('Test valid - 1234-5678'));
  17. $this->assertTrue(valid_phone_number('br', '12345678'), t('Test valid - 12345678'));
  18. $this->assertTrue(valid_phone_number('br', '+55 11 2222-3333'), t('Test valid - +55 11 2222-3333'));
  19. $this->assertTrue(valid_phone_number('br', '011 5555-1234'), t('Test valid - 011 5555-1234'));
  20. $this->assertTrue(valid_phone_number('br', '(011) 5555 1234'), t('Test valid - (011) 5555 1234'));
  21. $this->assertTrue(valid_phone_number('br', '(11) 5555.1234'), t('Test valid - (11) 5555.1234'));
  22. $this->assertTrue(valid_phone_number('br', '1155551234'), t('Test valid - 1155551234'));
  23. }
  24. public function testPhoneBRInvalid() {
  25. $this->assertFalse(valid_phone_number('br', '123-45678'), t('Test invalid - 123-45678'));
  26. $this->assertFalse(valid_phone_number('br', '(01) 5555 1234'), t('Test invalid - (01) 5555 1234'));
  27. $this->assertFalse(valid_phone_number('br', '(11) 0555.1234'), t('Test invalid - (11) 0555.1234'));
  28. $this->assertFalse(valid_phone_number('br', '(11) 5555 abcd'), t('Test invalid - (11) 5555 abcd'));
  29. }
  30. public function testPhoneBRFormatting() {
  31. $this->assertEqual(format_br_phone_number('+55 11 2222-3333', null), '+55 (11) 222-333', t('Brazil - +55 (11) 222-333'));
  32. }
  33. }