Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
13.33% covered (danger)
13.33%
2 / 15
50.00% covered (danger)
50.00%
1 / 2
CRAP
0.00% covered (danger)
0.00%
0 / 1
phpbb_regex_censor_test
13.33% covered (danger)
13.33%
2 / 15
50.00% covered (danger)
50.00%
1 / 2
4.60
0.00% covered (danger)
0.00%
0 / 1
 censor_test_data
0.00% covered (danger)
0.00%
0 / 13
0.00% covered (danger)
0.00%
0 / 1
2
 test_censor_unicode
100.00% covered (success)
100.00%
2 / 2
100.00% covered (success)
100.00%
1 / 1
1
1<?php
2/**
3*
4* This file is part of the phpBB Forum Software package.
5*
6* @copyright (c) phpBB Limited <https://www.phpbb.com>
7* @license GNU General Public License, version 2 (GPL-2.0)
8*
9* For full copyright and license information, please see
10* the docs/CREDITS.txt file.
11*
12*/
13
14class phpbb_regex_censor_test extends phpbb_test_case
15{
16    public static function censor_test_data()
17    {
18        return array(
19            array('bad*word', 'bad word'),
20            array('bad***word', 'bad word'),
21            array('bad**word', 'bad word'),
22            array('*bad*word*', 'bad word'),
23            array('b*d', 'bad'),
24            array('*bad*', 'bad'),
25            array('*b*d*', 'bad'),
26            array('*b*d*', 'b d'),
27            array('b*d*word', 'bad word'),
28            array('**b**d**word**', 'bad word'),
29            array('**b**d**word**', 'the bad word catched'),
30        );
31    }
32
33    /**
34    * @dataProvider censor_test_data
35    */
36    public function test_censor_unicode($pattern, $subject)
37    {
38        $regex = get_censor_preg_expression($pattern);
39
40        $this->assertMatchesRegularExpression($regex, $subject);
41    }
42}