1
0
mirror of https://github.com/phpbb/phpbb.git synced 2025-04-30 04:38:21 +02:00

[ticket/9626] Adding tests for the URL regular expression.

PHPBB3-9626
This commit is contained in:
Andreas Fischer 2010-05-19 16:56:45 +02:00
parent 646b16f5db
commit aaaa4f9abe
2 changed files with 36 additions and 0 deletions

View File

@ -18,6 +18,7 @@ require_once 'PHPUnit/TextUI/TestRunner.php';
require_once 'regex/email.php';
require_once 'regex/ipv4.php';
require_once 'regex/ipv6.php';
require_once 'regex/url.php';
class phpbb_regex_all_tests
{
@ -33,6 +34,7 @@ class phpbb_regex_all_tests
$suite->addTestSuite('phpbb_regex_email_test');
$suite->addTestSuite('phpbb_regex_ipv4_test');
$suite->addTestSuite('phpbb_regex_ipv6_test');
$suite->addTestSuite('phpbb_regex_url_test');
return $suite;
}

34
tests/regex/url.php Normal file
View File

@ -0,0 +1,34 @@
<?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_regex_url_test extends phpbb_test_case
{
public function url_test_data()
{
return array(
array('http://www.phpbb.com/community/', 1),
array('http://www.phpbb.com/path/file.ext#section', 1),
array('ftp://ftp.phpbb.com/', 1),
array('sip://bantu@phpbb.com', 1),
array('www.phpbb.com/community/', 0),
);
}
/**
* @dataProvider url_test_data
*/
public function test_url($url, $expected)
{
$this->assertEquals($expected, preg_match('#^' . get_preg_expression('url') . '$#i', $url));
}
}