function test_number_to_phone() { $this->assertEqual("555-1234", number_to_phone(5551234)); $this->assertEqual("555-1234", number_to_phone("5551234")); $this->assertEqual("123-555-1234", number_to_phone(1235551234)); $this->assertEqual("(123) 555-1234", number_to_phone(1235551234, array('area_code' => true))); $this->assertEqual("123 555 1234", number_to_phone(1235551234, array('delimiter' => " "))); $this->assertEqual("(123) 555-1234 x 555", number_to_phone(1235551234, array('area_code' => true, 'extension' => 555))); $this->assertEqual("+1-123-555-1234", number_to_phone(1235551234, array('country_code' => 1))); $this->assertEqual("123a456", number_to_phone("123a456")); $this->assertEqual("+1.123.555.1234 x 1343", number_to_phone(1235551234, array('country_code' => 1, 'extension' => 1343, 'delimiter' => "."))); }
/** * Empty test to prevent failure * @todo Write test for the FormTagHelper class */ public function testNumber_to_phone_function() { $this->assertEquals("800-555-1212", number_to_phone(8005551212)); $this->assertEquals("(800) 555-1212", number_to_phone(8005551212, array("area_code" => true))); $this->assertEquals("800 555 1212", number_to_phone(8005551212, array("delimiter" => " "))); $this->assertEquals("(800) 555-1212 x 123", number_to_phone(8005551212, array("area_code" => true, "extension" => 123))); $this->assertEquals("800-555-1212", number_to_phone(8005551212, array("extension" => " "))); $this->assertEquals("800-555-1212", number_to_phone("8005551212")); $this->assertEquals("+1-800-555-1212", number_to_phone(8005551212, array("country_code" => 1))); $this->assertEquals("+18005551212", number_to_phone(8005551212, array("country_code" => 1, "delimiter" => ''))); $this->assertEquals("22-555-1212", number_to_phone(225551212)); $this->assertEquals("+45-22-555-1212", number_to_phone(225551212, array("country_code" => 45))); $this->assertEquals("x", number_to_phone("x")); $this->assertNull(number_to_phone(null)); }