summaryrefslogtreecommitdiff
path: root/maintenance/tests/TitleTest.php
blob: 5b42c1c575e7837bca3ab9e41eeda039fab379a9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
<?php

class TitleTest extends PHPUnit_Framework_TestCase {

	function testLegalChars() {
		$titlechars = Title::legalChars();

		foreach ( range( 1, 255 ) as $num ) {
			$chr = chr( $num );
			if ( strpos( "#[]{}<>|", $chr ) !== false || preg_match( "/[\\x00-\\x1f\\x7f]/", $chr ) ) {
				$this->assertFalse( (bool)preg_match( "/[$titlechars]/", $chr ), "chr($num) = $chr is not a valid titlechar" );
			} else {
				$this->assertTrue( (bool)preg_match( "/[$titlechars]/", $chr ), "chr($num) = $chr is a valid titlechar" );
			}
		}
	}
}