diff options
Diffstat (limited to 'tests/regex')
-rw-r--r-- | tests/regex/all_tests.php | 46 | ||||
-rw-r--r-- | tests/regex/censor_test.php | 40 | ||||
-rw-r--r-- | tests/regex/email_test.php (renamed from tests/regex/email.php) | 3 | ||||
-rw-r--r-- | tests/regex/ipv4_test.php (renamed from tests/regex/ipv4.php) | 3 | ||||
-rw-r--r-- | tests/regex/ipv6_test.php (renamed from tests/regex/ipv6.php) | 3 | ||||
-rw-r--r-- | tests/regex/url_test.php (renamed from tests/regex/url.php) | 3 |
6 files changed, 44 insertions, 54 deletions
diff --git a/tests/regex/all_tests.php b/tests/regex/all_tests.php deleted file mode 100644 index 316a9d4a58..0000000000 --- a/tests/regex/all_tests.php +++ /dev/null @@ -1,46 +0,0 @@ -<?php -/** -* -* @package testing -* @copyright (c) 2010 phpBB Group -* @license http://opensource.org/licenses/gpl-license.php GNU Public License -* -*/ - -if (!defined('PHPUnit_MAIN_METHOD')) -{ - define('PHPUnit_MAIN_METHOD', 'phpbb_regex_all_tests::main'); -} - -require_once 'test_framework/framework.php'; -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 -{ - public static function main() - { - PHPUnit_TextUI_TestRunner::run(self::suite()); - } - - public static function suite() - { - $suite = new PHPUnit_Framework_TestSuite('phpBB Regular Expressions'); - - $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; - } -} - -if (PHPUnit_MAIN_METHOD == 'phpbb_regex_all_tests::main') -{ - phpbb_regex_all_tests::main(); -} diff --git a/tests/regex/censor_test.php b/tests/regex/censor_test.php new file mode 100644 index 0000000000..ae2d86e07e --- /dev/null +++ b/tests/regex/censor_test.php @@ -0,0 +1,40 @@ +<?php +/** +* +* @package testing +* @copyright (c) 2010 phpBB Group +* @license http://opensource.org/licenses/gpl-license.php GNU Public License +* +*/ + +require_once __DIR__ . '/../../phpBB/includes/functions.php'; + +class phpbb_regex_censor_test extends phpbb_test_case +{ + public function censor_test_data() + { + return array( + array('bad*word', 'bad word'), + array('bad***word', 'bad word'), + array('bad**word', 'bad word'), + array('*bad*word*', 'bad word'), + array('b*d', 'bad'), + array('*bad*', 'bad'), + array('*b*d*', 'bad'), + array('*b*d*', 'b d'), + array('b*d*word', 'bad word'), + array('**b**d**word**', 'bad word'), + array('**b**d**word**', 'the bad word catched'), + ); + } + + /** + * @dataProvider censor_test_data + */ + public function test_censor($pattern, $subject) + { + $regex = get_censor_preg_expression($pattern); + + $this->assertRegExp($regex, $subject); + } +}
\ No newline at end of file diff --git a/tests/regex/email.php b/tests/regex/email_test.php index 8658b8af36..5d6e207cbb 100644 --- a/tests/regex/email.php +++ b/tests/regex/email_test.php @@ -7,8 +7,7 @@ * */ -require_once 'test_framework/framework.php'; -require_once '../phpBB/includes/functions.php'; +require_once __DIR__ . '/../../phpBB/includes/functions.php'; class phpbb_regex_email_test extends phpbb_test_case { diff --git a/tests/regex/ipv4.php b/tests/regex/ipv4_test.php index 9d131ad0ca..735a2c4384 100644 --- a/tests/regex/ipv4.php +++ b/tests/regex/ipv4_test.php @@ -7,8 +7,7 @@ * */ -require_once 'test_framework/framework.php'; -require_once '../phpBB/includes/functions.php'; +require_once __DIR__ . '/../../phpBB/includes/functions.php'; class phpbb_regex_ipv4_test extends phpbb_test_case { diff --git a/tests/regex/ipv6.php b/tests/regex/ipv6_test.php index 3d7a72e492..187588f861 100644 --- a/tests/regex/ipv6.php +++ b/tests/regex/ipv6_test.php @@ -7,8 +7,7 @@ * */ -require_once 'test_framework/framework.php'; -require_once '../phpBB/includes/functions.php'; +require_once __DIR__ . '/../../phpBB/includes/functions.php'; class phpbb_regex_ipv6_test extends phpbb_test_case { diff --git a/tests/regex/url.php b/tests/regex/url_test.php index 678b7d108f..246cbf549c 100644 --- a/tests/regex/url.php +++ b/tests/regex/url_test.php @@ -7,8 +7,7 @@ * */ -require_once 'test_framework/framework.php'; -require_once '../phpBB/includes/functions.php'; +require_once __DIR__ . '/../../phpBB/includes/functions.php'; class phpbb_regex_url_test extends phpbb_test_case { |