* (bug 5286) Fix regression in display of missing/bad revision IDs
[lhc/web/wiklou.git] / tests / CtypeTest.php
1 <?php
2 require_once 'PHPUnit.php';
3
4 class CtypeTest extends PHPUnit_TestCase {
5 var $functions;
6
7 function CtypeTest( $name ) {
8 $this->PHPUnit_TestCase( $name );
9 }
10
11 function setUp() {
12 $cont = file_get_contents( '../includes/compatability/ctype.php' );
13
14 preg_match_all( '~function (ctype_[a-z]+)~', $cont, $m );
15 $this->populateFunctions( $m[1] );
16
17 // Will get called before each test* function
18 if ( function_exists( '_ctype_alnum' ) )
19 return;
20 else {
21 $cont = preg_replace( '~^<\?php~', '', $cont );
22 $cont = preg_replace( '~\?>$~', '', $cont );
23
24 // Rename the custom functions so they don't conflict
25 $cont = preg_replace( '~(function )(ctype_)~', '\1_\2', $cont );
26
27 eval( $cont );
28 }
29 }
30
31 function populateFunctions( $functions ) {
32 $this->functions = array();
33 foreach ( $functions as $function )
34 $this->functions[$function] = "_$function";
35 }
36
37 function tearDown() {}
38
39 // function testInteger256_to_big() {}
40
41 function testInteger0_to_255() {
42 foreach ( $this->functions as $phpfunc => $mwfunc )
43 foreach ( range( 0, 255 ) as $i )
44 $this->assertEquals(
45 _ctype_alnum( $i ),
46 ctype_alnum( $i ),
47 "On $i ($phpfunc)"
48 );
49 }
50
51 function testChr0_to_255() {
52 foreach ( $this->functions as $phpfunc => $mwfunc )
53 foreach ( range( 0, 255 ) as $i ) {
54 $i = chr( $i );
55 $this->assertEquals(
56 _ctype_alnum( $i ),
57 ctype_alnum( $i ),
58 "On $i ($phpfunc)"
59 );
60 }
61 }
62
63 }
64 ?>