blob: b39f536fa9759615bf924eb717209fa544bfcfba (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
|
<?php
require_once('PHPUnit/Framework.php');
class unbbcodeTest extends PHPUnit_Framework_TestCase {
/**
* @dataProvider provider_bbcode_second_pass
*/
public function test_bbcode_second_pass($msg, $uid, $bitfield,
$expected, $ex) {
if ($ex) $this->setExpectedException($ex);
/**
* phpBB3 uses many globals; due to the way tests are run, we cannot
* easily get these globals into the right scope so that the methods
* called by our tests can see them. Therefore, we run tests externally
* and report back on the results.
*/
$prog = <<<EOF
try {
require_once("src/unbbcode.php");
\$msg = '$msg';
\$uid = '$uid';
\$bitfield = '$bitfield';
\$unbbcode = new unbbcode();
\$unbbcode->bbcode_second_pass(\$msg, \$uid, \$bitfield);
\$result = serialize(\$msg);
}
catch (Exception \$e) {
\$result = serialize(\$e);
}
print \$result;
EOF;
$result = unserialize(exec('php -r \'' . $prog . '\''));
if ($result instanceof Exception) {
throw $result;
}
$this->assertEquals($expected, $result);
}
public function provider_bbcode_second_pass() {
return array(
array('[b]Test[/b]', '', false, '<b>Test</b>', null)
);
}
}
?>
|