FINAL suepr merge step : added all modules to this super repos

This commit is contained in:
Bachir Soussi Chiadmi
2015-04-19 16:46:59 +02:00
7585 changed files with 1723356 additions and 18 deletions

View File

@@ -0,0 +1,45 @@
<?php
class AUPhoneNumberTestCase extends DrupalWebTestCase {
/**
* Implementation of getInfo()
*
*/
public static function getInfo() {
return array(
'name' => t('Australia Phone number test'),
'description' => t('Tests various valid and invalid Australia phone numbers for validity'),
'group' => t('Phone')
);
}
public function testPhoneAUValid() {
$this->assertTrue(valid_phone_number('au', '0200-0299'), t('ACT - 0200-0299'));
$this->assertTrue(valid_phone_number('au', '2600-2639'), t('ACT - 2600-2639'));
$this->assertTrue(valid_phone_number('au', '1000-1999'), t('NSW - 1000-1999'));
$this->assertTrue(valid_phone_number('au', '2000-2599'), t('NSW - 2000-2599'));
$this->assertTrue(valid_phone_number('au', '2640-2914'), t('NSW - 2640-2914'));
$this->assertTrue(valid_phone_number('au', '0900-0999'), t('NT - 0900-0999'));
$this->assertTrue(valid_phone_number('au', '0800-0899'), t('NT - 0800-0899'));
$this->assertTrue(valid_phone_number('au', '9000-9999'), t('QLD - 9000-9999'));
$this->assertTrue(valid_phone_number('au', '4000-4999'), t('QLD - 4000-4999'));
$this->assertTrue(valid_phone_number('au', '5000-5999'), t('SA - 5000-599'));
$this->assertTrue(valid_phone_number('au', '7800-7999'), t('TAS - 7800-7999'));
$this->assertTrue(valid_phone_number('au', '7000-7499'), t('TAS - 7000-7499'));
$this->assertTrue(valid_phone_number('au', '8000-8999'), t('VIC - 8000-8999'));
$this->assertTrue(valid_phone_number('au', '3000-3999'), t('VIC - 3000-3999'));
$this->assertTrue(valid_phone_number('au', '6800-6999'), t('WA - 6800-6999'));
$this->assertTrue(valid_phone_number('au', '6000-6799'), t('WA - 6000-6799'));
}
public function testPhoneAUInvalid() {
$this->assertFalse(valid_phone_number('au', '0300'), t('Test invalid - 0300'));
$this->assertFalse(valid_phone_number('au', '7612'), t('Test invalid - 7612'));
$this->assertFalse(valid_phone_number('au', '2915'), t('Test invalid - 2915'));
$this->assertFalse(valid_phone_number('au', '2415b'), t('Test invalid - 2415b'));
}
public function testPhoneAUFormatting() {
//$this->assertEqual(format_phone_number('au', '+6421123456', null), '+64 21 123 456', t('Check international mobile format'));
}
}

View File

@@ -0,0 +1,31 @@
<?php
class BEPhoneNumberTestCase extends DrupalWebTestCase {
/**
* Implementation of getInfo()
*
*/
public static function getInfo() {
return array(
'name' => t('Belgium Phone number test'),
'description' => t('Tests various valid and invalid Belgium phone numbers for validity'),
'group' => t('Phone')
);
}
public function testPhoneBEValid() {
$this->assertTrue(valid_phone_number('be', '023456789'), '"023456789" should be valid');
$this->assertTrue(valid_phone_number('be', '0478990011'), '"0478990011" should be valid');
$this->assertTrue(valid_phone_number('be', '01 234 56 78'), '"01 234 56 78" should be valid');
$this->assertTrue(valid_phone_number('be', '+32 12345678'), '"+32 12345678" should be valid');
}
public function testPhoneBEInvalid() {
$this->assertFalse(valid_phone_number('be', '+323456789'), t('Test invalid'));
$this->assertFalse(valid_phone_number('be', '02 345 67 89'), t('Test invalid'));
}
public function testPhoneBEFormatting() {
//$this->assertEqual(format_phone_number('be', '+6421123456', null), '+64 21 123 456', t('Check international mobile format'));
}
}

View File

@@ -0,0 +1,39 @@
<?php
class BRPhoneNumberTestCase extends DrupalWebTestCase {
/**
* Implementation of getInfo()
*
*/
public static function getInfo() {
return array(
'name' => t('Brazil Phone number test'),
'description' => t('Tests various valid and invalid Brazil phone numbers for validity'),
'group' => t('Phone')
);
}
public function testPhoneBRValid() {
$this->assertTrue(valid_phone_number('br', '(11) 1234-5678'), t('Test valid - (11) 1234-5678'));
$this->assertTrue(valid_phone_number('br', '1234-5678 '), t('Test valid - 1234-5678'));
$this->assertTrue(valid_phone_number('br', '12345678'), t('Test valid - 12345678'));
$this->assertTrue(valid_phone_number('br', '+55 11 2222-3333'), t('Test valid - +55 11 2222-3333'));
$this->assertTrue(valid_phone_number('br', '011 5555-1234'), t('Test valid - 011 5555-1234'));
$this->assertTrue(valid_phone_number('br', '(011) 5555 1234'), t('Test valid - (011) 5555 1234'));
$this->assertTrue(valid_phone_number('br', '(11) 5555.1234'), t('Test valid - (11) 5555.1234'));
$this->assertTrue(valid_phone_number('br', '1155551234'), t('Test valid - 1155551234'));
}
public function testPhoneBRInvalid() {
$this->assertFalse(valid_phone_number('br', '123-45678'), t('Test invalid - 123-45678'));
$this->assertFalse(valid_phone_number('br', '(01) 5555 1234'), t('Test invalid - (01) 5555 1234'));
$this->assertFalse(valid_phone_number('br', '(11) 0555.1234'), t('Test invalid - (11) 0555.1234'));
$this->assertFalse(valid_phone_number('br', '(11) 5555 abcd'), t('Test invalid - (11) 5555 abcd'));
}
public function testPhoneBRFormatting() {
$this->assertEqual(format_br_phone_number('+55 11 2222-3333', null), '+55 (11) 222-333', t('Brazil - +55 (11) 222-333'));
}
}

View File

@@ -0,0 +1,32 @@
<?php
class CAPhoneNumberTestCase extends DrupalWebTestCase {
/**
* Implementation of getInfo()
*
*/
public static function getInfo() {
return array(
'name' => t('Canada & US Phone number test'),
'description' => t('Tests various valid and invalid Canada & US phone numbers for validity'),
'group' => t('Phone')
);
}
public function testPhoneCAValid() {
$this->assertTrue(valid_phone_number('ca', '1-800-555-1212'), t('Test valid - 1-800-555-1212'));
$this->assertTrue(valid_phone_number('ca', '800-555-1212'), t('Test valid - 800-555-1212'));
$this->assertTrue(valid_phone_number('ca', '(201)223-4567'), t('Test valid - (201)223-4567'));
$this->assertTrue(valid_phone_number('ca', '604 543 9245'), t('Test valid - British Columbia 604 543 9245'));
}
public function testPhoneCAInvalid() {
//$this->assertFalse(valid_phone_number('ca', '021 3012 3456'), t('Test invalid '));
}
public function testPhoneCAFormatting() {
//$this->assertEqual(format_phone_number('ca', '+6421123456', null), '+64 21 123 456', t('Check international mobile format'));
}
}

View File

@@ -0,0 +1,30 @@
<?php
class CHPhoneNumberTestCase extends DrupalWebTestCase {
/**
* Implementation of getInfo()
*
*/
public static function getInfo() {
return array(
'name' => t('Swiss Phone number test'),
'description' => t('Tests various valid and invalid Swiss phone numbers for validity'),
'group' => t('Phone')
);
}
public function testPhoneCHValid() {
//$this->assertTrue(valid_phone_number('ch', '04 476 0000'), t('Test valid'));
}
public function testPhoneCHInvalid() {
//$this->assertFalse(valid_phone_number('ch', '021 3012 3456'), t('Test invalid'));
}
public function testPhoneCHFormatting() {
//$this->assertEqual(format_phone_number('ch', '+6421123456', null), '+64 21 123 456', t('Check international mobile format'));
}
}

View File

@@ -0,0 +1,29 @@
<?php
class CLPhoneNumberTestCase extends DrupalWebTestCase {
/**
* Implementation of getInfo()
*
*/
public static function getInfo() {
return array(
'name' => t('Chili Phone number test'),
'description' => t('Tests various valid and invalid Chili phone numbers for validity'),
'group' => t('Phone')
);
}
public function testPhoneCLValid() {
$this->assertTrue(valid_phone_number('cl', '(041)245-9848'), t('Test valid'));
$this->assertTrue(valid_phone_number('cl', '(063)421-232'), t('Test valid'));
}
public function testPhoneCLInvalid() {
$this->assertFalse(valid_phone_number('cl', '0412459848'), t('Test invalid '));
$this->assertFalse(valid_phone_number('cl', '063421232'), t('Test invalid '));
}
public function testPhoneCLFormatting() {
//$this->assertEqual(format_phone_number('cl', '+6421123456', null), '+64 21 123 456', t('Check international mobile format'));
}
}

View File

@@ -0,0 +1,36 @@
<?php
class CNPhoneNumberTestCase extends DrupalWebTestCase {
/**
* Implementation of getInfo()
*
*/
public static function getInfo() {
return array(
'name' => t('China People\'s Republic Phone number test'),
'description' => t('Tests various valid and invalid Chinese People\'s Republic phone numbers for validity'),
'group' => t('Phone')
);
}
public function testPhoneCNValid() {
$this->assertTrue(valid_phone_number('cn', '86-755-83998006'), t('Test valid - 86-755-83998006'));
$this->assertTrue(valid_phone_number('cn', '86-10-5851 6688'), t('Test valid - 86-10-5851 6688'));
$this->assertTrue(valid_phone_number('cn', '86-10-6512 4940'), t('Test valid - 86-10-6512 4940'));
$this->assertTrue(valid_phone_number('cn', '+86 21 6103 2200'), t('Test valid - +86 21 6103 2200'));
$this->assertTrue(valid_phone_number('cn', '+86 10.85.32.83.23'), t('Test valid - +86 10.85.32.83.23'));
$this->assertTrue(valid_phone_number('cn', '755-83998006'), t('Test valid - 755-83998006'));
$this->assertTrue(valid_phone_number('cn', '+86-10-5851 6688'), t('Test valid - +86-10-5851 6688'));
$this->assertTrue(valid_phone_number('cn', '10.85.32.83.23'), t('Test valid - 10.85.32.83.23'));
$this->assertTrue(valid_phone_number('cn', '13900000000'), t('Test valid - 13900000000'));
$this->assertTrue(valid_phone_number('cn', '10-5851 6688'), t('Test valid - 10-5851 6688'));
}
public function testPhoneCNInvalid() {
//$this->assertFalse(valid_phone_number('cn', '021 3012 3456'), t('Test invalid - 021 3012 3456'));
}
public function testPhoneCNFormatting() {
//$this->assertEqual(format_phone_number('cn', '+6421123456', null), '+64 21 123 456', t('Check international mobile format'));
}
}

View File

@@ -0,0 +1,27 @@
<?php
class CRPhoneNumberTestCase extends DrupalWebTestCase {
/**
* Implementation of getInfo()
*
*/
public static function getInfo() {
return array(
'name' => t('Costa Rica Phone number test'),
'description' => t('Tests various valid and invalid Costa Rica phone numbers for validity'),
'group' => t('Phone')
);
}
public function testPhoneCRValid() {
//$this->assertTrue(valid_phone_number('cr', '04 476 0000'), t('Test valid'));
}
public function testPhoneCRInvalid() {
//$this->assertFalse(valid_phone_number('cr', '021 3012 3456'), t('Test invalid '));
}
public function testPhoneCRFormatting() {
//$this->assertEqual(format_phone_number('cr', '+6421123456', null), '+64 21 123 456', t('Check international mobile format'));
}
}

View File

@@ -0,0 +1,27 @@
<?php
class CSPhoneNumberTestCase extends DrupalWebTestCase {
/**
* Implementation of getInfo()
*
*/
public static function getInfo() {
return array(
'name' => t('Czech Republic Phone number test'),
'description' => t('Tests various valid and invalid Czech Republic phone numbers for validity'),
'group' => t('Phone')
);
}
public function testPhoneCSValid() {
$this->assertTrue(valid_phone_number('cs', '+420 999 999 999'), t('Test valid - +420 999 999 999'));
}
public function testPhoneCSInvalid() {
//$this->assertFalse(valid_phone_number('cs', '021 3012 3456'), t('Test invalid - 021 3012 3456'));
}
public function testPhoneCSFormatting() {
//$this->assertEqual(format_phone_number('cs', '+6421123456', null), '+64 21 123 456', t('Check international mobile format'));
}
}

View File

@@ -0,0 +1,27 @@
<?php
class EGPhoneNumberTestCase extends DrupalWebTestCase {
/**
* Implementation of getInfo()
*
*/
public static function getInfo() {
return array(
'name' => t('Egypt Phone number test'),
'description' => t('Tests various valid and invalid Egypt phone numbers for validity'),
'group' => t('Phone')
);
}
public function testPhoneEGValid() {
//$this->assertTrue(valid_phone_number('eg', '04 476 0000'), t('Test valid'));
}
public function testPhoneEGInvalid() {
//$this->assertFalse(valid_phone_number('eg', '021 3012 3456'), t('Test invalid '));
}
public function testPhoneEGFormatting() {
//$this->assertEqual(format_phone_number('eg', '+6421123456', null), '+64 21 123 456', t('Check international mobile format'));
}
}

View File

@@ -0,0 +1,32 @@
<?php
class ESPhoneNumberTestCase extends DrupalWebTestCase {
/**
* Implementation of getInfo()
*
*/
public static function getInfo() {
return array(
'name' => t('Spain Phone number test'),
'description' => t('Tests various valid and invalid Spain phone numbers for validity'),
'group' => t('Phone')
);
}
public function testPhoneESValid() {
$this->assertTrue(valid_phone_number('es', '972367087'), t('Test valid - 972367087'));
$this->assertTrue(valid_phone_number('es', '97-3770866'), t('Test valid - 97-3770866'));
$this->assertTrue(valid_phone_number('es', '972-377086'), t('Test valid - 972-377086'));
}
public function testPhoneESInvalid() {
$this->assertFalse(valid_phone_number('es', '9988-989898'), t('Test invalid - 9988-989898'));
$this->assertFalse(valid_phone_number('es', '989898988989'), t('Test invalid - 989898988989'));
$this->assertFalse(valid_phone_number('es', '9 9898989898'), t('Test invalid - 9 9898989898'));
}
public function testPhoneESFormatting() {
//$this->assertEqual(format_phone_number('es', '+6421123456', null), '+64 21 123 456', t('Check international mobile format'));
}
}

View File

@@ -0,0 +1,115 @@
<?php
// Copyright 2009 Thierry GUEGAN http://www.arvoriad.com
/**
/**
* Unit tests for Phone module.
*/
class PhoneFrenchTest extends DrupalWebTestCase {
public static function getInfo() {
return array(
'name' => t('France Phone number test'),
'description' => t('Executes test suite for validating / formatting France phone number.'),
'group' => t('Phone')
);
}
function setUp() {
parent::setUp();
include_once('./'. drupal_get_path('module', 'phone') .'/phone.fr.inc');
}
public function testPhoneFRValid() {
// test cleaning phone number
$this->assertTrue(valid_phone_number('fr', ' +33 123 45 - (67) 89'), "' +33 123 45 - (67) 89' should be valid");
$this->assertTrue(valid_phone_number('fr', '+33123456789'), "'+33123456789' should be valid");
$this->assertTrue(valid_phone_number('fr', '0123456789'), "'0123456789' should be valid");
$this->assertTrue(valid_phone_number('fr', '+33223456789'), "'+33223456789' should be valid");
$this->assertTrue(valid_phone_number('fr', '0223456789'), "'0223456789' should be valid");
$this->assertTrue(valid_phone_number('fr', '+33323456789'), "'+33323456789' should be valid");
$this->assertTrue(valid_phone_number('fr', '0323456789'), "'0323456789' should be valid");
$this->assertTrue(valid_phone_number('fr', '+33423456789'), "'+33423456789' should be valid");
$this->assertTrue(valid_phone_number('fr', '0423456789'), "'0423456789' should be valid");
$this->assertTrue(valid_phone_number('fr', '+33523456789'), "'+33523456789' should be valid");
$this->assertTrue(valid_phone_number('fr', '0523456789'), "'0523456789' should be valid");
// 06... mobile
$this->assertTrue(valid_phone_number('fr', '+33623456789'), "'+33623456789' should be valid");
$this->assertTrue(valid_phone_number('fr', '0623456789'), "'0623456789' should be valid");
// 085... virtual private network
$this->assertTrue(valid_phone_number('fr', '+33853456789'), "'+33853456789' should be valid");
$this->assertTrue(valid_phone_number('fr', '0853456789'), "'0853456789' should be valid");
// 087...
// 870... 871... 872... 873... 874... 875... 877... 878... 879... assigned
foreach (array('870', '871', '872', '873', '874', '875', '877', '878', '879') as $za) {
$this->assertTrue(valid_phone_number('fr', '+33'. $za .'123456'), "'+33 $za 1234567' is be valid");
$this->assertTrue(valid_phone_number('fr', '0'. $za .'123456'), "'0 $za 1234567' is be valid");
}
}
public function testPhoneFRInvalid() {
$this->assertFalse(valid_phone_number('fr', '+33 123456789a'), "'+33 123456789a' should not be valid because wrong char");
$this->assertFalse(valid_phone_number('fr', '+33 1234567a89'), "'+33 1234567a89' should not be valid because wrong char");
$this->assertFalse(valid_phone_number('fr', '0 123456789a'), "'0 123456789a' should not be valid because wrong char");
$this->assertFalse(valid_phone_number('fr', '0 1234567a89'), "'0 1234567a89' should not be valid because wrong char");
$this->assertFalse(valid_phone_number('fr', '+33 1234567890'), "'+33 1234567890' should not be valid because too long");
$this->assertFalse(valid_phone_number('fr', '+33 12345678'), "'+33 12345678' should not be valid because too short");
$this->assertFalse(valid_phone_number('fr', '0 1234567890'), "'0 1234567890' should not be valid because too long");
$this->assertFalse(valid_phone_number('fr', '0 12345678'), "'0 12345678' should not be valid because too short");
// 07... not assigned
$this->assertFalse(valid_phone_number('fr', '+33723456789'), "'+33723456789' is unassigned so should not be valid");
$this->assertFalse(valid_phone_number('fr', '0723456789'), "'0723456789' is unassigned so should not be valid");
// except 0876... not assigned
$this->assertFalse(valid_phone_number('fr', '+33876456789'), "'+33873456789' is unassigned so should not be valid");
$this->assertFalse(valid_phone_number('fr', '0876456789'), "'0873456789' is unassigned so should not be valid");
// 80... 81... 82... 83... 84... 86... 88... 89... not assigned
foreach (array('80', '81', '82', '83', '84', '86', '88', '89') as $za) {
$this->assertFalse(valid_phone_number('fr', '+33'. $za .'1234567'), "'+33'. $za .'1234567' is unassigned so should not be valid");
$this->assertFalse(valid_phone_number('fr', '0'. $za .'1234567'), "'0'. $za .'1234567' is unassigned so should not be valid");
}
// 09... not assigned
$this->assertFalse(valid_phone_number('fr', '+33923456789'), "'+33923456789' is unassigned so should not be valid");
$this->assertFalse(valid_phone_number('fr', '0923456789'), "'0923456789' is unassigned so should not be valid");
// 00... not assigned
$this->assertFalse(valid_phone_number('fr', '+33023456789'), "'+33023456789' is unassigned so should not be valid");
$this->assertFalse(valid_phone_number('fr', '0023456789'), "'0023456789' is unassigned so should not be valid");
}
public function testPhoneFRFormatting() {
// test cleaning phone number
$this->assertEqual(format_fr_phone_number('+33 123456789a'), '+33 123456789a', "'+33 123456789a', not valid so just ouptut without formatting");
$this->assertEqual(format_fr_phone_number('01234567a8'), '01234567a8', "'01234567a8', not valid so just ouptut without formatting");
$this->assertEqual(format_fr_phone_number('+33 123456789'), '0123456789', "international --> national");
$this->assertEqual(format_fr_phone_number(' +33 123 45 - (67) 89'), '0123456789', "international --> national");
$add_country_code = array('phone_country_code'=> TRUE);
$this->assertEqual(format_fr_phone_number('+33 123456789', $add_country_code), '+33 123456789', "international --> international");
$this->assertEqual(format_fr_phone_number(' +33 123 45 - (67) 89', $add_country_code), '+33 123456789', "international --> international");
}
}

View File

@@ -0,0 +1,38 @@
<?php
class HUPhoneNumberTestCase extends DrupalWebTestCase {
/**
* Implementation of getInfo()
*
*/
public static function getInfo() {
return array(
'name' => t('Hungary Phone number test'),
'description' => t('Tests various valid and invalid Hungary phone numbers for validity'),
'group' => t('Phone')
);
}
public function testPhoneHUValid() {
$this->assertTrue(valid_phone_number('hu', '+3611234567'), t('Test valid'));
$this->assertTrue(valid_phone_number('hu', '+3676123456'), t('Test valid'));
$this->assertTrue(valid_phone_number('hu', '+36301234567'), t('Test valid'));
$this->assertTrue(valid_phone_number('hu', '+36 1 1234567'), t('Test valid'));
$this->assertTrue(valid_phone_number('hu', '+36 76 123456'), t('Test valid'));
$this->assertTrue(valid_phone_number('hu', '+36 30 1234567'), t('Test valid'));
$this->assertTrue(valid_phone_number('hu', '+36(1)1234567'), t('Test valid'));
$this->assertTrue(valid_phone_number('hu', '+36(76)123456'), t('Test valid'));
$this->assertTrue(valid_phone_number('hu', '+36(30)1234567'), t('Test valid'));
$this->assertTrue(valid_phone_number('hu', '1/123-4567'), t('Test valid'));
$this->assertTrue(valid_phone_number('hu', '76/123-456'), t('Test valid'));
$this->assertTrue(valid_phone_number('hu', '30/123-45-67'), t('Test valid'));
}
public function testPhoneHUInvalid() {
$this->assertFalse(valid_phone_number('hu', '+0011234567'), t('Test invalid'));
}
public function testPhoneHUFormatting() {
//$this->assertEqual(format_phone_number('hu', '+6421123456', null), '+64 21 123 456', t('Check international mobile format'));
}
}

View File

@@ -0,0 +1,27 @@
<?php
class ILPhoneNumberTestCase extends DrupalWebTestCase {
/**
* Implementation of getInfo()
*
*/
public static function getInfo() {
return array(
'name' => t('Israel Phone number test'),
'description' => t('Tests various valid and invalid Israel phone numbers for validity'),
'group' => t('Phone')
);
}
public function testPhoneILValid() {
$this->assertTrue(valid_phone_number('il', '1800 999 999'), '"1800 999 999" should be valid');
}
public function testPhoneILInvalid() {
//$this->assertFalse(valid_phone_number('il', '021 3012 3456'), t('Test invalid'));
}
public function testPhoneILFormatting() {
$this->assertEqual(format_phone_number('il', '1800 999 999', null), '1800 999 999', 'Formatting OK "1800 999 999" --> "1800 999 999"');
}
}

View File

@@ -0,0 +1,94 @@
<?php
//require_once drupal_get_path('module', 'phone') . 'includes/phone.int.inc';
class PhoneIntTest extends DrupalWebTestCase {
public static function getInfo() {
return array(
'name' => 'International phone number test',
'description' => 'Tests international phone number validation.',
'group' => 'Phone',
);
}
public function setUp() {
// Enable the phone module.
parent::setUp(array('phone'));
}
private function assertConversion($input, $expect = TRUE, $field = array(), $expect_error = FALSE) {
$error = FALSE;
if (!isset($field['phone_int_max_length'])) {
$field['phone_int_max_length'] = '15';
}
if (!isset($field['phone_default_country_code'])) {
$field['phone_default_country_code'] = '1';
}
if ($expect === FALSE) {
$this->assertFalse(valid_phone_number('int', $input, $field, $error));
$this->assertIdentical($error, $expect_error);
return;
}
elseif ($expect === TRUE) {
$expect = $input;
}
$this->assertTrue(valid_phone_number('int', $input, $field, $error));
$this->assertIdentical($error, FALSE);
$result = format_phone_number('int', $input, $field);
$this->assertIdentical($result, $expect);
}
public function testBasic() {
$this->assertConversion('+1 7329018493');
}
public function testBasicWithThreeCountryCode() {
$this->assertConversion('+672 565434');
}
public function testBasicWithFourCountryCode() {
$this->assertConversion('+6724 565434', FALSE, array(), array(
'Invalid international phone number: Country code "+%cc" is too long; valid country codes are three digits or less.',
array('%cc' => '6724')
));
}
public function testBasicWithSpaces() {
$this->assertConversion('+1 732 901 8493');
}
public function testBasicNormalizeOtherCharacters() {
$this->assertConversion('+1 (732) 901-8493', '+1 732 901 8493');
}
public function testRemoveNDD() {
$this->assertConversion('+54 0435344', '+54 435344');
}
public function testRemoveNonStandardNDD() {
$this->assertConversion('+374 (8) 435344', '+374 435344');
}
public function testAddCountryCode() {
$this->assertConversion('732 343 2333', '+1 732 343 2333', array('phone_default_country_code' => '1'));
}
public function testOverlongNumber() {
$this->assertConversion('+123 456 789 012 3456', FALSE, array(),
'Invalid international phone number: Phone number is too long; international phone numbers are limited to 15 digits.'
);
}
public function testOverlongNumberWithoutCountryCode() {
$this->assertConversion('456 789 012 3456', FALSE, array('phone_default_country_code' => '123'),
'Invalid international phone number: Phone number is too long; international phone numbers are limited to 15 digits.'
);
}
public function testLetters() {
$this->assertConversion('+1 343 CALL US', FALSE, array(),
'Invalid international phone number: Phone number contains invalid characters; only allowed characters are numbers and punctuation.'
);
}
}

View File

@@ -0,0 +1,43 @@
<?php
class ITPhoneNumberTestCase extends DrupalWebTestCase {
/**
* Implementation of getInfo()
*
*/
public static function getInfo() {
return array(
'name' => t('Italia Phone number test'),
'description' => t('Tests various valid and invalid Italia phone numbers for validity'),
'group' => t('Phone')
);
}
public function testPhoneITValid() {
$this->assertTrue(valid_phone_number('it', '06/2034567'), t('Test valid - 06/2034567'));
$this->assertTrue(valid_phone_number('it', '+39 02/123456'), t('Test valid - +39 02/123456'));
$this->assertTrue(valid_phone_number('it', '02-343536'), t('Test valid - 02-343536'));
$this->assertTrue(valid_phone_number('it', '02/343536'), t('Test valid - 02/343536'));
$this->assertTrue(valid_phone_number('it', '02 343536'), t('Test valid - 02 343536'));
$this->assertTrue(valid_phone_number('it', '+393381234567'), t('Test valid - +393381234567'));
$this->assertTrue(valid_phone_number('it', '+39 3381234567'), t('Test valid - +39 3381234567'));
$this->assertTrue(valid_phone_number('it', '+39 338 1234567'), t('Test valid - +39 338 1234567'));
$this->assertTrue(valid_phone_number('it', '+39 338-1234567'), t('Test valid - +39 338-1234567'));
$this->assertTrue(valid_phone_number('it', '3381234567'), t('Test valid - 3381234567'));
$this->assertTrue(valid_phone_number('it', '3381234567'), t('Test valid - 3381234567'));
$this->assertTrue(valid_phone_number('it', '338 1234567'), t('Test valid - 338 1234567'));
$this->assertTrue(valid_phone_number('it', '338-1234567'), t('Test valid - 338-1234567'));
}
public function testPhoneITInvalid() {
$this->assertFalse(valid_phone_number('it', '02a343536'), t('Test invalid - 02a343536'));
$this->assertFalse(valid_phone_number('it', '02+343536'), t('Test invalid - 02+343536'));
$this->assertFalse(valid_phone_number('it', '0039 338 1234567'), t('Test invalid - 0039 338 1234567'));
$this->assertFalse(valid_phone_number('it', '(338)1234567'), t('Test invalid - (338)1234567'));
}
public function testPhoneITFormatting() {
//$this->assertEqual(format_phone_number('it', '+6421123456', null), '+64 21 123 456', t('Check international mobile format'));
}
}

View File

@@ -0,0 +1,27 @@
<?php
class JOPhoneNumberTestCase extends DrupalWebTestCase {
/**
* Implementation of getInfo()
*
*/
public static function getInfo() {
return array(
'name' => t('Jordania Phone number test'),
'description' => t('Tests various valid and invalid Jordania phone numbers for validity'),
'group' => t('Phone')
);
}
public function testPhoneJOValid() {
//$this->assertTrue(valid_phone_number('jo', '04 476 0000'), t('Test valid'));
}
public function testPhoneJOInvalid() {
//$this->assertFalse(valid_phone_number('jo', '021 3012 3456'), t('Test invalid'));
}
public function testPhoneJOFormatting() {
//$this->assertEqual(format_phone_number('jo', '+6421123456', null), '+64 21 123 456', t('Check international mobile format'));
}
}

View File

@@ -0,0 +1,27 @@
<?php
class NLPhoneNumberTestCase extends DrupalWebTestCase {
/**
* Implementation of getInfo()
*
*/
public static function getInfo() {
return array(
'name' => t('Netherland Phone number test'),
'description' => t('Tests various valid and invalid Netherland phone numbers for validity'),
'group' => t('Phone')
);
}
public function testPhoneNLValid() {
//$this->assertTrue(valid_phone_number('nl', '04 476 0000'), t('Test valid'));
}
public function testPhoneNLInvalid() {
//$this->assertFalse(valid_phone_number('nl', '021 3012 3456'), t('Test invalid '));
}
public function testPhoneNLFormatting() {
//$this->assertEqual(format_phone_number('nl', '+6421123456', null), '+64 21 123 456', t('Check international mobile format'));
}
}

View File

@@ -0,0 +1,68 @@
<?php
class NZPhoneNumberTestCase extends DrupalWebTestCase {
/**
* Implementation of getInfo()
*
*/
public static function getInfo() {
return array(
'name' => t('New Zealand Phone number test'),
'description' => t('Tests various valid and invalid New Zealand phone numbers for validity'),
'group' => t('Phone')
);
}
public function testPhoneNZValid() {
$this->assertTrue(valid_phone_number('nz', '04 476 0000'), t('Test standard regional number 04 476 0000'));
$this->assertTrue(valid_phone_number('nz', '+64 4 476 0000'), t('Test international variation of regional +64 4 476 0000'));
$this->assertTrue(valid_phone_number('nz', '+6444760000'), t('Test international variation of regional +6444760000'));
$this->assertTrue(valid_phone_number('nz', '+649302 0000'), t('Test slightly weird variation of international +649302 0000'));
$this->assertTrue(valid_phone_number('nz', '(04) 476 0000'), t('Test bracketed regional (04) 476 0000'));
$this->assertTrue(valid_phone_number('nz', '(04) 476-0000'), t('Test hyphenated regional (04) 476-0000'));
$this->assertTrue(valid_phone_number('nz', '03 903-1234'), t('Test valid South Island regional 03 903-1234'));
$this->assertTrue(valid_phone_number('nz', '021 123 456'), t('Test valid 8-digit Vodafone number 021 739 733'));
$this->assertTrue(valid_phone_number('nz', '(021) 123 456'), t('Test bracketed 8-digit Vodafone number (021) 739 733'));
$this->assertTrue(valid_phone_number('nz', '+6421123456'), t('Test international Vodafone +6421123456'));
$this->assertTrue(valid_phone_number('nz', '021 0101 2345'), t('Test 10-digit valid Vodafone number 021 2102 2345'));
$this->assertTrue(valid_phone_number('nz', '+642101012345'), t('Test international version 10-digit Vodafone +642121012345'));
$this->assertTrue(valid_phone_number('nz', '027 680 1234'), t('Test valid 9-digit Telecom Mobile number'));
$this->assertTrue(valid_phone_number('nz', '+64 27 680 1234'), t('Test valid international version of Telecom 9-digit +64 27 680 1234'));
$this->assertTrue(valid_phone_number('nz', '0800 83 83 83'), t('Test valid 0800 83 83 83 Pizza Hut'));
$this->assertTrue(valid_phone_number('nz', '0900 87687'), t('Test valid 0900 TROTS'));
$this->assertTrue(valid_phone_number('nz', '026 123 4567'), t('Test valid Telecom pager 026 123 4567'));
$this->assertTrue(valid_phone_number('nz', '022 123 4567'), t('Test valid NZ Comms mobile 022 123 4567'));
$this->assertTrue(valid_phone_number('nz', '22 123 4567'), t('Test slightly naughty lack of STD NZ Comms 22 123 4567'));
$this->assertTrue(valid_phone_number('nz', '020 123 4567'), t('Test valid Telecom Mobile Radio 020 123 4567'));
$this->assertTrue(valid_phone_number('nz', '029 123 4567'), t('Test valid TelstraClear Mobile Radio 029 123 4567'));
$this->assertTrue(valid_phone_number('nz', '+64 24 123 456'), t('Test valid Scott Base +64 24 123 456'));
}
public function testPhoneNZInvalid() {
$this->assertFalse(valid_phone_number('nz', '021 3012 3456'), t('Test invalid 10-digit Vodafone number in wrong range 021 3012 3456'));
$this->assertFalse(valid_phone_number('nz', '04 701 1234'), t('Test invalid Wellington regional number 04 701 1234'));
$this->assertFalse(valid_phone_number('nz', '(06) 412 3456'), t('Test invalid Manawatu regional number (06) 412 3456'));
$this->assertFalse(valid_phone_number('nz', '04 123 456'), t('Test too short Wellington regional number 04 123 456'));
$this->assertFalse(valid_phone_number('nz', '[04] 123 4567'), t('Test invalid character Wellington regional [04] 123 4567'));
$this->assertFalse(valid_phone_number('nz', '09 701 2345'), t('Test invalid Auckland regional 09 701 2345'));
$this->assertFalse(valid_phone_number('nz', '028 123 4567'), t('Test invalid mobile range 028 123 4567'));
$this->assertFalse(valid_phone_number('nz', '027 1234 5678'), t('Test invalid Telecom mobile length 027 1234 5678'));
}
public function testPhoneNZFormatting() {
$this->assertEqual(format_phone_number('nz', '+6421123456', null), '+64 21 123 456', t('Check international mobile format'));
$this->assertEqual(format_phone_number('nz', '021123456', null), '(021) 123 456', t('Check 6-digit domestic mobile format'));
$this->assertEqual(format_phone_number('nz', '0211234567', null), '(021) 123 4567', t('Check 7-digit domestic mobile format'));
$this->assertEqual(format_phone_number('nz', '+64211234567', null), '+64 21 123 4567', t('Check 7-digit international mobile format'));
$this->assertEqual(format_phone_number('nz', '02101234567', null), '(021) 0123 4567', t('Check 8-digit domestic mobile format'));
$this->assertEqual(format_phone_number('nz', '+642101234567', null), '+64 21 0123 4567', t('Check 8-digit international mobile format'));
$this->assertEqual(format_phone_number('nz', '041234567', null), '(04) 123 4567', t('Check regional number format (domestic)'));
$this->assertEqual(format_phone_number('nz', '+6441234567', null), '+64 4 123 4567', t('Check regional number format (international)'));
$this->assertEqual(format_phone_number('nz', '041234567x1234', null), '(04) 123 4567 x1234', t('Check regional number format with extension (domestic)'));
$this->assertEqual(format_phone_number('nz', '+6441234567x1234', null), '+64 4 123 4567 x1234', t('Check regional number format with extension (international)'));
$this->assertEqual(format_phone_number('nz', '0800 83 83 83', null), '0800 838383', t('Check 0800 number formatting (6 digit)'));
$this->assertEqual(format_phone_number('nz', '0800 123 4567', null), '0800 123 4567', t('Check 0800 number formatting (7 digit)'));
$this->assertEqual(format_phone_number('nz', '0800 12345', null), '0800 12345', t('Check 0800 number formatting (5 digit)'));
}
}

View File

@@ -0,0 +1,63 @@
<?php
class PhonePanamanianTest extends DrupalWebTestCase {
public static function getInfo() {
return array(
'name' => t('Panamanian phone'),
'description' => t('Executes test suite for validating / formatting Panamanian phone number.'),
'group' => t('Phone'),
);
}
function testValidatingPanamenianPhoneNumber() {
$this->assertTrue(valid_phone_number('pa', '+507 260-4334'), '+507 260-4334 should be valid');
$this->assertTrue(valid_phone_number('pa', '+507 2604334'), '+507 2604334 should be valid');
$this->assertTrue(valid_phone_number('pa', '+507 260 4334'), '+507 260 4334 should be valid');
$this->assertTrue(valid_phone_number('pa', '00507 2603133'), '00507 2603133 should be valid');
$this->assertTrue(valid_phone_number('pa', '00507 260-3133'), '00507 260-3133 should be valid');
$this->assertTrue(valid_phone_number('pa', '00507 260 4334'), '00507 260 4334 should be valid');
$this->assertTrue(valid_phone_number('pa', '260 3133'), '260 3133 should be valid');
$this->assertTrue(valid_phone_number('pa', '260-3133'), '260-3133 should be valid');
$this->assertTrue(valid_phone_number('pa', '2603133'), '2603133 should be valid');
//Cellphones
$this->assertTrue(valid_phone_number('pa', '+507 6545-4345'), '+507 6545-4345 should be valid');
$this->assertTrue(valid_phone_number('pa', '+507 65454345'), '+507 65454345 should be valid');
$this->assertTrue(valid_phone_number('pa', '+507 6545 4345'), '+507 6545 4345 should be valid');
$this->assertTrue(valid_phone_number('pa', '00507 6545-4345'), '00507 6545-4345 should be valid');
$this->assertTrue(valid_phone_number('pa', '00507 6545 4345'), '00507 6545 4345 should be valid');
$this->assertTrue(valid_phone_number('pa', '00507 65454345'), '00507 65454345 should be valid');
$this->assertTrue(valid_phone_number('pa', '6545-4345'), '6545-4345 should be valid');
$this->assertTrue(valid_phone_number('pa', '6545 4345'), '6545 4345 should be valid');
$this->assertTrue(valid_phone_number('pa', '65454345'), '65454345 should be valid');
//Invalid
$this->assertFalse(valid_phone_number('pa', '35343'), '35343 should not be valid');
$this->assertFalse(valid_phone_number('pa', '320-43'), '320-43 should not be valid');
$this->assertTrue(valid_phone_number('pa', '(507) 435-3434'), '(507) 435-3434 should not be valid');
}
function testFormattingPanamenianPhoneNumber() {
$this->assertEqual(format_phone_number('pa', '+507 260-4334'), '+507 260-4334', '+507 260-4334 format');
$this->assertEqual(format_phone_number('pa', '+507 2604334'), '+507 260-4334', '+507 2604334 format');
$this->assertEqual(format_phone_number('pa', '+507 260 4334'), '+507 260-4334', '+507 260 4334 format');
$this->assertEqual(format_phone_number('pa', '00507 260-4334'), '+507 260-4334', '00507 260-4334 format');
$this->assertEqual(format_phone_number('pa', '00507 2604334'), '+507 260-4334', '00507 2604334 format');
$this->assertEqual(format_phone_number('pa', '00507 260 4334'), '+507 260-4334', '00507 260 4334 format');
$this->assertEqual(format_phone_number('pa', '260-4334'), '260-4334', '260-4334 format');
$this->assertEqual(format_phone_number('pa', '2604334'), '260-4334', '2604334 format');
$this->assertEqual(format_phone_number('pa', '260 4334'), '260-4334', '260 4334 format');
$this->assertEqual(format_phone_number('pa', '260 4334', array('phone_country_code' => 1)), '+507 260-4334', 'add +507 to 260 4334 format');
//Cellphones
$this->assertEqual(format_phone_number('pa', '00507 6464 4334'), '+507 6464-4334', '6464 4334 format');
$this->assertEqual(format_phone_number('pa', '00507 6464-4334'), '+507 6464-4334', '00507 6464-4334 format');
$this->assertEqual(format_phone_number('pa', '00507 64644334'), '+507 6464-4334', '00507 64644334 format');
$this->assertEqual(format_phone_number('pa', '+507 6464 4334'), '+507 6464-4334', '+507 6464 4334 format');
$this->assertEqual(format_phone_number('pa', '6464 4334'), '6464-4334', '6464 4334 format');
$this->assertEqual(format_phone_number('pa', '64644334'), '6464-4334', '6464-4334 format');
$this->assertEqual(format_phone_number('pa', '6464 4334', array('phone_country_code' => 1)), '+507 6464-4334', 'add +507 to 6464 4334 format');
}
}

View File

@@ -0,0 +1,27 @@
<?php
class PHPhoneNumberTestCase extends DrupalWebTestCase {
/**
* Implementation of getInfo()
*
*/
public static function getInfo() {
return array(
'name' => t('Philippine Phone number test'),
'description' => t('Tests various valid and invalid Philippine phone numbers for validity'),
'group' => t('Phone')
);
}
public function testPhonePHValid() {
//$this->assertTrue(valid_phone_number('ph', '04 476 0000'), t('Test standard regional number 04 476 0000'));
}
public function testPhonePHInvalid() {
//$this->assertFalse(valid_phone_number('ph', '021 3012 3456'), t('Test invalid 10-digit Vodafone number in wrong range 021 3012 3456'));
}
public function testPhonePHFormatting() {
//$this->assertEqual(format_phone_number('ph', '+6421123456', null), '+64 21 123 456', t('Check international mobile format'));
}
}

View File

@@ -0,0 +1,31 @@
<?php
class PKPhoneNumberTestCase extends DrupalWebTestCase {
/**
* Implementation of getInfo()
*
*/
public static function getInfo() {
return array(
'name' => t('Pakistan Phone number test'),
'description' => t('Tests various valid and invalid Pakistan phone numbers for validity'),
'group' => t('Phone')
);
}
public function testPhonePKValid() {
$this->assertTrue(valid_phone_number('pk', '+92 321 7469854'), t('Test valid'));
$this->assertTrue(valid_phone_number('pk', '923217469857'), t('Test valid'));
$this->assertTrue(valid_phone_number('pk', '041 2680226'), t('Test valid'));
}
public function testPhonePKInvalid() {
$this->assertFalse(valid_phone_number('pk', '00124566'), t('Test invalid'));
$this->assertFalse(valid_phone_number('pk', '01 922 745689'), t('Test invalid'));
$this->assertFalse(valid_phone_number('pk', '0000000000'), t('Test invalid'));
}
public function testPhonePKFormatting() {
//$this->assertEqual(format_phone_number('pk', '+6421123456', null), '+64 21 123 456', t('Check international mobile format'));
}
}

View File

@@ -0,0 +1,32 @@
<?php
class PLPhoneNumberTestCase extends DrupalWebTestCase {
/**
* Implementation of getInfo()
*
*/
public static function getInfo() {
return array(
'name' => t('Poland Phone number test'),
'description' => t('Tests various valid and invalid Poland phone numbers for validity'),
'group' => t('Phone')
);
}
public function testPhonePLValid() {
$this->assertTrue(valid_phone_number('pl', '+48 500-080-100'), t('Test valid'));
$this->assertTrue(valid_phone_number('pl', '500080100'), t('Test valid'));
$this->assertTrue(valid_phone_number('pl', '500 080 100'), t('Test valid'));
}
public function testPhonePLInvalid() {
$this->assertFalse(valid_phone_number('pl', '+47 100-100-100'), t('Test invalid '));
$this->assertFalse(valid_phone_number('pl', '1000-100-100'), t('Test invalid '));
$this->assertFalse(valid_phone_number('pl', '1000000000'), t('Test invalid '));
}
public function testPhonePLFormatting() {
//$this->assertEqual(format_phone_number('pl', '+6421123456', null), '+64 21 123 456', t('Check international mobile format'));
}
}

View File

@@ -0,0 +1,33 @@
<?php
class RUPhoneNumberTestCase extends DrupalWebTestCase {
/**
* Implementation of getInfo()
*
*/
public static function getInfo() {
return array(
'name' => t('Russia Phone number test'),
'description' => t('Tests various valid and invalid Russia phone numbers for validity'),
'group' => t('Phone')
);
}
public function testPhoneRUValid() {
$this->assertTrue(valid_phone_number('ru', '+7(916)9985670'), t('Test valid'));
$this->assertTrue(valid_phone_number('ru', '8-912-268-5440'), t('Test valid'));
$this->assertTrue(valid_phone_number('ru', '8905148-3339'), t('Test valid'));
$this->assertTrue(valid_phone_number('ru', '8(913)448-51-90'), t('Test valid'));
$this->assertTrue(valid_phone_number('ru', '903-345-34-34'), t('Test valid'));
$this->assertTrue(valid_phone_number('ru', '903-34-334-34'), t('Test valid'));
$this->assertTrue(valid_phone_number('ru', '903-34-33434'), t('Test valid '));
}
public function testPhoneRUInvalid() {
$this->assertFalse(valid_phone_number('ru', '+33903-34-33434'), t('Test invalid '));
}
public function testPhoneRUFormatting() {
//$this->assertEqual(format_phone_number('ru', '+6421123456', null), '+64 21 123 456', t('Check international mobile format'));
}
}

View File

@@ -0,0 +1,43 @@
<?php
class SEPhoneNumberTestCase extends DrupalWebTestCase {
/**
* Implementation of getInfo()
*
*/
public static function getInfo() {
return array(
'name' => t('Sweden Phone number test'),
'description' => t('Tests various valid and invalid Sweden phone numbers for validity'),
'group' => t('Phone')
);
}
public function testPhoneSEValid() {
$this->assertTrue(valid_phone_number('se', '+46 8 123 456 78'), t('Test valid'));
$this->assertTrue(valid_phone_number('se', '08-123 456 78'), t('Test valid'));
$this->assertTrue(valid_phone_number('se', '0123-456 78'), t('Test valid'));
$this->assertTrue(valid_phone_number('se', '031-3224562'), t('Test valid'));
$this->assertTrue(valid_phone_number('se', '0737234264'), t('Test valid'));
$this->assertTrue(valid_phone_number('se', '073-5647829'), t('Test valid'));
$this->assertTrue(valid_phone_number('se', '19740609-7845'), t('Test valid'));
$this->assertTrue(valid_phone_number('se', '19811116-7845'), t('Test valid'));
$this->assertTrue(valid_phone_number('se', '20010913-7598'), t('Test valid'));
}
public function testPhoneSEInvalid() {
$this->assertFalse(valid_phone_number('se', '46 08-123 456 78'), t('Test invalid'));
$this->assertFalse(valid_phone_number('se', '08 123 456 78'), t('Test invalid '));
$this->assertFalse(valid_phone_number('se', '0123 456 78'), t('Test invalid '));
$this->assertFalse(valid_phone_number('se', '34348abc'), t('Test invalid'));
$this->assertFalse(valid_phone_number('se', '452643242343432432435643623432'), t('Test invalid '));
$this->assertFalse(valid_phone_number('se', '532'), t('Test invalid '));
$this->assertFalse(valid_phone_number('se', '21003612-9999'), t('Test invalid '));
$this->assertFalse(valid_phone_number('se', '18790505-45458'), t('Test invalid '));
$this->assertFalse(valid_phone_number('se', '19740641-5559'), t('Test invalid '));
}
public function testPhoneSEFormatting() {
//$this->assertEqual(format_phone_number('se', '+6421123456', null), '+64 21 123 456', t('Check international mobile format'));
}
}

View File

@@ -0,0 +1,40 @@
<?php
class SGPhoneNumberTestCase extends DrupalWebTestCase {
/**
* Implementation of getInfo()
*
*/
public static function getInfo() {
return array(
'name' => t('Singapore Phone number test'),
'description' => t('Tests various valid and invalid Singapore phone numbers for validity'),
'group' => t('Phone')
);
}
public function testPhoneSGValid() {
$this->assertTrue(valid_phone_number('sg', '61234567'), "'61234567' should be valid");
$this->assertTrue(valid_phone_number('sg', '63829324'), "'63829324' should be valid");
$this->assertTrue(valid_phone_number('sg', '67654321'), "'67654321' should be valid");
$this->assertTrue(valid_phone_number('sg', '+6561234567'), "'+6561234567' should be valid");
$this->assertTrue(valid_phone_number('sg', '+6581234567'), "'+6581234567' should be valid");
$this->assertTrue(valid_phone_number('sg', '+6591234567'), "'+6591234567' should be valid");
$this->assertTrue(valid_phone_number('sg', '+65 61234567'), "'+65 61234567' should be valid");
$this->assertTrue(valid_phone_number('sg', '+65 81234567'), "'+65 81234567' should be valid");
$this->assertTrue(valid_phone_number('sg', '+65 91234567'), "'+65 91234567' should be valid");
$this->assertTrue(valid_phone_number('sg', '61234567'), "'61234567' should be valid");
$this->assertTrue(valid_phone_number('sg', '81234567'), "'81234567' should be valid");
$this->assertTrue(valid_phone_number('sg', '91234567'), "'91234567' should be valid");
}
public function testPhoneSGInvalid() {
$this->assertFalse(valid_phone_number('sg', '6123-4567'), t('Test invalid '));
$this->assertFalse(valid_phone_number('sg', '6-CALL-CPY'), t('Test invalid '));
$this->assertFalse(valid_phone_number('sg', '6123abcd'), t('Test invalid '));
}
public function testPhoneSGFormatting() {
//$this->assertEqual(format_phone_number('sg', '+6421123456', null), '+64 21 123 456', t('Check international mobile format'));
}
}

View File

@@ -0,0 +1,43 @@
<?php
class UAPhoneNumberTestCase extends DrupalWebTestCase {
/**
* Implementation of getInfo()
*
*/
public static function getInfo() {
return array(
'name' => t('Ukraine Phone number test'),
'description' => t('Tests various valid and invalid Ukraine phone numbers for validity'),
'group' => t('Phone')
);
}
function setUp() {
parent::setUp();
}
public function testPhoneUAValid() {
$this->assertTrue(valid_phone_number('ua', '+38-044-283-93-57'), t('Kyiv landline test'));
$this->assertTrue(valid_phone_number('ua', '(044)2839357'), t('Kyiv landline test'));
$this->assertTrue(valid_phone_number('ua', '+380442839357'), t('Kyiv landline test'));
$this->assertTrue(valid_phone_number('ua', '+38 (044)537-28-07'), t('Kyiv landline test'));
$this->assertTrue(valid_phone_number('ua', '044 537-28-07'), t('Kyiv landline test'));
$this->assertTrue(valid_phone_number('ua', '+38 032 2724042 '), t('Lviv landline test'));
$this->assertTrue(valid_phone_number('ua', '+380623621047'), t('Yasinovata landline test'));
}
public function testPhoneUAInvalid() {
$this->assertFalse(valid_phone_number('ua', '+380117777777'), t('Test with noexist citycode 011'));
$this->assertFalse(valid_phone_number('ua', '+380711234567'), t('Test with noexist citycode 071'));
$this->assertFalse(valid_phone_number('ua', '+38044123456'), t('Test with short phone'));
$this->assertFalse(valid_phone_number('ua', '044123456'), t('Test with short phone'));
$this->assertFalse(valid_phone_number('ua', '+3804412345678'), t('Test with long phone'));
$this->assertFalse(valid_phone_number('ua', '04412345678'), t('Test with long phone'));
$this->assertFalse(valid_phone_number('ua', '8044223-95-26'), t('Test with obsolete leading 8 notation'));
}
public function testPhoneUAFormatting() {
//$this->assertEqual(format_phone_number('ua', '+6421123456', null), '+64 21 123 456', t('Check international mobile format'));
}
}

View File

@@ -0,0 +1,41 @@
<?php
class UKPhoneNumberTestCase extends DrupalWebTestCase {
/**
* Implementation of getInfo()
*
*/
public static function getInfo() {
return array(
'name' => t('UK Phone number test'),
'description' => t('Tests various valid and invalid UK phone numbers for validity'),
'group' => t('Phone')
);
}
public function testPhoneUKValid() {
$this->assertTrue(valid_phone_number('uk', '01905 23819'), t('Test valid - 01905 23819'));
$this->assertTrue(valid_phone_number('uk', '01222 555 555'), t('Test valid - 01222 555 555'));
$this->assertTrue(valid_phone_number('uk', '(010) 55555555 #2222'), t('Test valid - (010) 55555555 #2222'));
$this->assertTrue(valid_phone_number('uk', '0122 555 5555#222'), t('Test valid - 0122 555 5555#222'));
$this->assertTrue(valid_phone_number('uk', '+441970123456'), t('Test valid - +441970123456'));
$this->assertTrue(valid_phone_number('uk', '+44(0)1970123456'), t('Test valid - +44(0)1970123456'));
$this->assertTrue(valid_phone_number('uk', '+44 1970 123 4562'), t('Test valid - +44 1970 123 456'));
$this->assertTrue(valid_phone_number('uk', '+44 (0)1970 123 456'), t('Test valid - +44 (0)1970 123 456'));
$this->assertTrue(valid_phone_number('uk', '(01970) 123456 #0001'), t('Test valid - (01970) 123456 #0001'));
}
public function testPhoneUKInvalid() {
$this->assertFalse(valid_phone_number('uk', '01222 555 5555'), t('Test invalid - 01222 555 5555'));
$this->assertFalse(valid_phone_number('uk', '(010) 55555555 #22'), t('Test invalid - (010) 55555555 #22'));
$this->assertFalse(valid_phone_number('uk', '0122 5555 5555#222'), t('Test invalid - 0122 5555 5555#222'));
$this->assertFalse(valid_phone_number('uk', '(+441970)123456'), t('Test invalid - (+441970)123456'));
$this->assertFalse(valid_phone_number('uk', '+44(1970)123456'), t('Test invalid - +44(1970)123456'));
$this->assertFalse(valid_phone_number('uk', '+44 01970 123 456'), t('Test invalid - +44 01970 123 456'));
$this->assertFalse(valid_phone_number('uk', '(0197) 0123456 #01'), t('Test invalid - (0197) 0123456 #01'));
}
public function testPhoneUKFormatting() {
//$this->assertEqual(format_phone_number('uk', '+6421123456', null), '+64 21 123 456', t('Check international mobile format'));
}
}

View File

@@ -0,0 +1,46 @@
<?php
class ZAPhoneNumberTestCase extends DrupalWebTestCase {
/**
* Implementation of getInfo()
*
*/
public static function getInfo() {
return array(
'name' => t('South Africa Phone number test'),
'description' => t('Tests various valid and invalid South African phone numbers for validity'),
'group' => t('Phone')
);
}
public function testPhoneZAValid() {
$this->assertTrue(valid_phone_number('za', '+27 11 888-8888'), t('Test valid - +27 11 888-8888'));
$this->assertTrue(valid_phone_number('za', '0333872119'), t('Test valid - 0333872119'));
$this->assertTrue(valid_phone_number('za', '074 101 2850'), t('Test valid - 074 101 2850'));
$this->assertTrue(valid_phone_number('za', '27723376484'), t('Test valid - 27723376484'));
$this->assertTrue(valid_phone_number('za', '0723376484'), t('Test valid - 0723376484'));
$this->assertTrue(valid_phone_number('za', '0111231234'), t('Test valid - 0111231234'));
$this->assertTrue(valid_phone_number('za', '011 123 1234'), t('Test valid - 011 123 1234'));
$this->assertTrue(valid_phone_number('za', '011-123-1234'), t('Test valid - 011-123-1234'));
$this->assertTrue(valid_phone_number('za', '0821231234'), t('Test valid - 0821231234'));
$this->assertTrue(valid_phone_number('za', '082 123 1234'), t('Test valid - 082 123 1234'));
$this->assertTrue(valid_phone_number('za', '+27821231234'), t('Test valid - +27821231234'));
$this->assertTrue(valid_phone_number('za', '+2782-123-1234'), t('Test valid - +2782-123-1234'));
$this->assertTrue(valid_phone_number('za', '+2782 123 1234'), t('Test valid - +2782 123 1234'));
$this->assertTrue(valid_phone_number('za', '27111231234'), t('Test valid - 27111231234'));
$this->assertTrue(valid_phone_number('za', '2711 123 1234'), t('Test valid - 2711 123 1234'));
$this->assertTrue(valid_phone_number('za', '082 123 1234'), t('Test valid - 082 123 1234'));
}
public function testPhoneZAInvalid() {
$this->assertFalse(valid_phone_number('za', '9723376484'), t('Test invalid - 9723376484'));
$this->assertFalse(valid_phone_number('za', '26723376484'), t('Test invalid - 26723376484'));
$this->assertFalse(valid_phone_number('za', '(011)1231234'), t('Test invalid - (011)1231234'));
$this->assertFalse(valid_phone_number('za', '(+2711) 123 1234'), t('Test invalid - (+2711) 123 1234'));
$this->assertFalse(valid_phone_number('za', '(011) 123-1234'), t('Test invalid - (011) 123-1234'));
}
public function testPhoneZAFormatting() {
$this->assertEqual(format_phone_number('za', '082 123 1234', null), '082 123 1234', 'Formatting OK "082 123 1234" --> "082 123 1234"');
}
}