<?php
/**
* File for the NumberHelperTest class, translated from Ruby on Rails.
*
* (PHP 5)
*
* @package PHPonTraxTest
* @license http://opensource.org/licenses/gpl-license.php GNU Public License
* @copyright (c) 2007 Mirek Rusin translated from Ruby on Rails
* @version $Id$
* @author Mirek Rusin <hide@address.com>
*/
echo "testing NumberHelper\n";
require_once 'testenv.php';
// Call NumberHelperTest::main() if this source file is executed directly.
if (!defined("PHPUnit2_MAIN_METHOD")) {
define("PHPUnit2_MAIN_METHOD", "NumberHelperTest::main");
}
require_once "PHPUnit2/Framework/TestCase.php";
require_once "PHPUnit2/Framework/TestSuite.php";
// You may remove the following line when all tests have been implemented.
require_once "PHPUnit2/Framework/IncompleteTestError.php";
require_once "action_view/helpers.php";
require_once "action_view/helpers/number_helper.php";
/**
* Test class for NumberHelper.
* Generated by PHPUnit2_Util_Skeleton
*/
class NumberHelperTest extends PHPUnit2_Framework_TestCase {
/**
* Runs the test methods of this class.
*
* @access public
* @static
*/
public static function main() {
require_once "PHPUnit2/TextUI/TestRunner.php";
$suite = new PHPUnit2_Framework_TestSuite("NumberHelperTest");
$result = PHPUnit2_TextUI_TestRunner::run($suite);
}
/**
* Sets up the fixture, for example, open a network connection.
* This method is called before a test is executed.
*
* @access protected
*/
protected function setUp() {
}
/**
* Tears down the fixture, for example, close a network connection.
* This method is called after a test is executed.
*
* @access protected
*/
protected function tearDown() {
}
/**
* 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));
}
}
// Call NumberHelperTest::main() if this source file is executed directly.
if (PHPUnit2_MAIN_METHOD == "NumberHelperTest::main") {
NumberHelperTest::main();
}
// -- set Emacs parameters --
// Local variables:
// tab-width: 4
// c-basic-offset: 4
// c-hanging-comment-ender-p: nil
// indent-tabs-mode: nil
// End:
?>