aboutsummaryrefslogtreecommitdiffstats
path: root/tests/regex
diff options
context:
space:
mode:
authorAndreas Fischer <bantu@phpbb.com>2010-05-19 16:56:45 +0200
committerAndreas Fischer <bantu@phpbb.com>2010-05-25 12:08:52 +0200
commitaaaa4f9abe8665946b79cc55bf3a4d7e0133b6c9 (patch)
treea3acd6a12d7e879326924faf531ecd1c3844ff32 /tests/regex
parent646b16f5db0ce68c69b520670b366dd61bfa03c1 (diff)
downloadforums-aaaa4f9abe8665946b79cc55bf3a4d7e0133b6c9.tar
forums-aaaa4f9abe8665946b79cc55bf3a4d7e0133b6c9.tar.gz
forums-aaaa4f9abe8665946b79cc55bf3a4d7e0133b6c9.tar.bz2
forums-aaaa4f9abe8665946b79cc55bf3a4d7e0133b6c9.tar.xz
forums-aaaa4f9abe8665946b79cc55bf3a4d7e0133b6c9.zip
[ticket/9626] Adding tests for the URL regular expression.
PHPBB3-9626
Diffstat (limited to 'tests/regex')
-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));
+ }
+}