aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/regex/all_tests.php2
-rw-r--r--tests/regex/url.php34
2 files changed, 36 insertions, 0 deletions
diff --git a/tests/regex/all_tests.php b/tests/regex/all_tests.php
index f2a23a0f98..316a9d4a58 100644
--- a/tests/regex/all_tests.php
+++ b/tests/regex/all_tests.php
@@ -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;
}
diff --git a/tests/regex/url.php b/tests/regex/url.php
new file mode 100644
index 0000000000..678b7d108f
--- /dev/null
+++ b/tests/regex/url.php
@@ -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));
+ }
+}