mirror of
https://github.com/phpbb/phpbb.git
synced 2025-06-07 20:08:53 +00:00
[ticket/9746] Adding unit tests for inet_ntop() and inet_pton().
PHPBB3-9746
This commit is contained in:
parent
6a32724400
commit
fdb5c2c990
2 changed files with 44 additions and 0 deletions
|
@ -16,6 +16,7 @@ require_once 'test_framework/framework.php';
|
|||
require_once 'PHPUnit/TextUI/TestRunner.php';
|
||||
|
||||
require_once 'network/checkdnsrr.php';
|
||||
require_once 'network/inet_ntop_pton.php';
|
||||
require_once 'network/ip_normalise.php';
|
||||
|
||||
class phpbb_network_all_tests
|
||||
|
@ -30,6 +31,7 @@ class phpbb_network_all_tests
|
|||
$suite = new PHPUnit_Framework_TestSuite('phpBB Network Functions');
|
||||
|
||||
$suite->addTestSuite('phpbb_network_checkdnsrr_test');
|
||||
$suite->addTestSuite('phpbb_network_inet_ntop_pton_test');
|
||||
$suite->addTestSuite('phpbb_network_ip_normalise_test');
|
||||
|
||||
return $suite;
|
||||
|
|
42
tests/network/inet_ntop_pton.php
Normal file
42
tests/network/inet_ntop_pton.php
Normal file
|
@ -0,0 +1,42 @@
|
|||
<?php
|
||||
/**
|
||||
*
|
||||
* @package testing
|
||||
* @copyright (c) 2010 phpBB Group
|
||||
* @license http://opensource.org/licenses/gpl-license.php GNU Public License
|
||||
*
|
||||
*/
|
||||
|
||||
require_once 'test_framework/framework.php';
|
||||
require_once '../phpBB/includes/functions.php';
|
||||
|
||||
class phpbb_network_inet_ntop_pton_test extends phpbb_test_case
|
||||
{
|
||||
public function data_provider()
|
||||
{
|
||||
return array(
|
||||
array('127.0.0.1', '7f000001'),
|
||||
array('192.232.131.223', 'c0e883df'),
|
||||
|
||||
array('::1', '00000000000000000000000000000001'),
|
||||
array('2001:280:0:10::5', '20010280000000100000000000000005'),
|
||||
array('fe80::200:4cff:fefe:172f', 'fe8000000000000002004cfffefe172f'),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider data_provider
|
||||
*/
|
||||
public function test_inet_ntop($address, $hex)
|
||||
{
|
||||
$this->assertEquals($address, phpbb_inet_ntop(pack('H*', $hex)));
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider data_provider
|
||||
*/
|
||||
public function test_inet_pton($address, $hex)
|
||||
{
|
||||
$this->assertEquals($hex, bin2hex(phpbb_inet_pton($address)));
|
||||
}
|
||||
}
|
Loading…
Add table
Reference in a new issue