}
public function testCdb() {
- $w1 = new CdbWriter_PHP( 'php.cdb' );
- $w2 = new CdbWriter_DBA( 'dba.cdb' );
+ $dir = wfTempDir();
+ if ( !is_writable( $dir ) ) {
+ $this->markTestSkipped( "Temp dir isn't writable" );
+ }
+
+ $w1 = new CdbWriter_PHP( "$dir/php.cdb" );
+ $w2 = new CdbWriter_DBA( "$dir/dba.cdb" );
$data = array();
for ( $i = 0; $i < 1000; $i++ ) {
$w2->close();
$this->assertEquals(
- md5_file( 'dba.cdb' ),
- md5_file( 'php.cdb' ),
+ md5_file( "$dir/dba.cdb" ),
+ md5_file( "$dir/php.cdb" ),
'same hash'
);
- $r1 = new CdbReader_PHP( 'php.cdb' );
- $r2 = new CdbReader_DBA( 'dba.cdb' );
+ $r1 = new CdbReader_PHP( "$dir/php.cdb" );
+ $r2 = new CdbReader_DBA( "$dir/dba.cdb" );
foreach ( $data as $key => $value ) {
if ( $key === '' ) {
$this->cdbAssert( "DBA error", $key, $v2, $value );
}
- unlink( 'dba.cdb' );
- unlink( 'php.cdb' );
+ unlink( "$dir/dba.cdb" );
+ unlink( "$dir/php.cdb" );
}
private function randomString() {
}
function testQuickPermissions() {
+ global $wgContLang;
+ $prefix = $wgContLang->getNsText( NS_PROJECT );
+
$this->setUser( 'anon' );
$this->setTitle( NS_TALK );
$this->setUserPerm( "createtalk" );
$this->assertEquals( array( ), $res );
$this->setUser( 'anon' );
- $check = array( 'edit' => array( array( array( 'badaccess-groups', "*, [[Mw:Users|Users]]", 2 ) ),
+ $check = array( 'edit' => array( array( array( 'badaccess-groups', "*, [[$prefix:Users|Users]]", 2 ) ),
array( array( 'badaccess-group0' ) ),
array( ), true ),
- 'protect' => array( array( array( 'badaccess-groups', "[[Mw:Administrators|Administrators]]", 1 ), array( 'protect-cantedit' ) ),
+ 'protect' => array( array( array( 'badaccess-groups', "[[$prefix:Administrators|Administrators]]", 1 ), array( 'protect-cantedit' ) ),
array( array( 'badaccess-group0' ), array( 'protect-cantedit' ) ),
array( array( 'protect-cantedit' ) ), false ),
'' => array( array( ), array( ), array( ), true ) );
function testPermissionHooks() { }
function testSpecialsAndNSPermissions() {
$this->setUser( self::$userName );
- global $wgUser;
+ global $wgUser, $wgContLang;
$wgUser = self::$user;
+ $prefix = $wgContLang->getNsText( NS_PROJECT );
$this->setTitle( NS_SPECIAL );
$this->assertEquals( array( array( 'badaccess-group0' ), array( 'ns-specialprotected' ) ),
self::$title->getUserPermissionsErrors( 'bogus', self::$user ) );
- $this->assertEquals( array( array( 'badaccess-groups', '*, [[Mw:Administrators|Administrators]]', 2 ) ),
+ $this->assertEquals( array( array( 'badaccess-groups', "*, [[$prefix:Administrators|Administrators]]", 2 ) ),
self::$title->getUserPermissionsErrors( 'createaccount', self::$user ) );
$this->assertEquals( array( array( 'badaccess-group0' ) ),
self::$title->getUserPermissionsErrors( 'execute', self::$user ) );
}
function testPageRestrictions() {
- global $wgUser;
+ global $wgUser, $wgContLang;
+
+ $prefix = $wgContLang->getNsText( NS_PROJECT );
+
$wgUser = self::$user;
$this->setTitle( NS_MAIN );
self::$title->mRestrictionsLoaded = true;
array( 'protectedpagetext', 'protect' ) ),
self::$title->getUserPermissionsErrors( 'bogus',
self::$user ) );
- $this->assertEquals( array( array( 'badaccess-groups', '*, [[Mw:Users|Users]]', 2 ),
+ $this->assertEquals( array( array( 'badaccess-groups', "*, [[$prefix:Users|Users]]", 2 ),
array( 'protectedpagetext', 'bogus' ),
array( 'protectedpagetext', 'protect' ),
array( 'protectedpagetext', 'protect' ) ),