function testCssAndJavascriptPermissions() {
$this->setUser( $this->userName );
+ $this->setTitle( NS_USER, $this->userName . '/test.js' );
+ $this->runCSSandJSPermissions(
+ array( array( 'badaccess-group0' ), array( 'mycustomjsprotected' ) ),
+ array( array( 'badaccess-group0' ), array( 'mycustomjsprotected' ) ),
+ array( array( 'badaccess-group0' ) ),
+ array( array( 'badaccess-group0' ), array( 'mycustomjsprotected' ) ),
+ array( array( 'badaccess-group0' ) )
+ );
+
+ $this->setTitle( NS_USER, $this->userName . '/test.css' );
+ $this->runCSSandJSPermissions(
+ array( array( 'badaccess-group0' ), array( 'mycustomcssprotected' ) ),
+ array( array( 'badaccess-group0' ) ),
+ array( array( 'badaccess-group0' ), array( 'mycustomcssprotected' ) ),
+ array( array( 'badaccess-group0' ) ),
+ array( array( 'badaccess-group0' ), array( 'mycustomcssprotected' ) )
+ );
+
$this->setTitle( NS_USER, $this->altUserName . '/test.js' );
$this->runCSSandJSPermissions(
array( array( 'badaccess-group0' ), array( 'customjsprotected' ) ),
array( array( 'badaccess-group0' ), array( 'customjsprotected' ) ),
- array( array( 'badaccess-group0' ) ) );
+ array( array( 'badaccess-group0' ), array( 'customjsprotected' ) ),
+ array( array( 'badaccess-group0' ), array( 'customjsprotected' ) ),
+ array( array( 'badaccess-group0' ) )
+ );
$this->setTitle( NS_USER, $this->altUserName . '/test.css' );
$this->runCSSandJSPermissions(
+ array( array( 'badaccess-group0' ), array( 'customcssprotected' ) ),
+ array( array( 'badaccess-group0' ), array( 'customcssprotected' ) ),
array( array( 'badaccess-group0' ), array( 'customcssprotected' ) ),
array( array( 'badaccess-group0' ) ),
- array( array( 'badaccess-group0' ), array( 'customcssprotected' ) ) );
+ array( array( 'badaccess-group0' ), array( 'customcssprotected' ) )
+ );
$this->setTitle( NS_USER, $this->altUserName . '/tempo' );
$this->runCSSandJSPermissions(
array( array( 'badaccess-group0' ) ),
array( array( 'badaccess-group0' ) ),
- array( array( 'badaccess-group0' ) ) );
+ array( array( 'badaccess-group0' ) ),
+ array( array( 'badaccess-group0' ) ),
+ array( array( 'badaccess-group0' ) )
+ );
}
- function runCSSandJSPermissions( $result0, $result1, $result2 ) {
+ function runCSSandJSPermissions( $result0, $result1, $result2, $result3, $result4 ) {
$this->setUserPerm( '' );
$this->assertEquals( $result0,
$this->title->getUserPermissionsErrors( 'bogus',
$this->user ) );
- $this->setUserPerm( 'editusercss' );
+ $this->setUserPerm( 'editmyusercss' );
$this->assertEquals( $result1,
$this->title->getUserPermissionsErrors( 'bogus',
$this->user ) );
- $this->setUserPerm( 'edituserjs' );
+ $this->setUserPerm( 'editmyuserjs' );
$this->assertEquals( $result2,
$this->title->getUserPermissionsErrors( 'bogus',
$this->user ) );
+ $this->setUserPerm( 'editusercss' );
+ $this->assertEquals( $result3,
+ $this->title->getUserPermissionsErrors( 'bogus',
+ $this->user ) );
+
+ $this->setUserPerm( 'edituserjs' );
+ $this->assertEquals( $result4,
+ $this->title->getUserPermissionsErrors( 'bogus',
+ $this->user ) );
+
$this->setUserPerm( 'editusercssjs' );
$this->assertEquals( array( array( 'badaccess-group0' ) ),
$this->title->getUserPermissionsErrors( 'bogus',
$this->assertEquals( array( array( 'badaccess-group0' ),
array( 'protectedpagetext', 'bogus' ),
- array( 'protectedpagetext', 'protect' ),
+ array( 'protectedpagetext', 'editprotected' ),
array( 'protectedpagetext', 'protect' ) ),
$this->title->getUserPermissionsErrors( 'bogus',
$this->user ) );
$this->assertEquals( array( array( 'protectedpagetext', 'bogus' ),
- array( 'protectedpagetext', 'protect' ),
+ array( 'protectedpagetext', 'editprotected' ),
array( 'protectedpagetext', 'protect' ) ),
$this->title->getUserPermissionsErrors( 'edit',
$this->user ) );
$this->setUserPerm( "" );
$this->assertEquals( array( array( 'badaccess-group0' ),
array( 'protectedpagetext', 'bogus' ),
- array( 'protectedpagetext', 'protect' ),
+ array( 'protectedpagetext', 'editprotected' ),
array( 'protectedpagetext', 'protect' ) ),
$this->title->getUserPermissionsErrors( 'bogus',
$this->user ) );
$this->assertEquals( array( array( 'badaccess-groups', "*, [[$prefix:Users|Users]]", 2 ),
array( 'protectedpagetext', 'bogus' ),
- array( 'protectedpagetext', 'protect' ),
+ array( 'protectedpagetext', 'editprotected' ),
array( 'protectedpagetext', 'protect' ) ),
$this->title->getUserPermissionsErrors( 'edit',
$this->user ) );
$this->setUserPerm( array( "edit", "editprotected" ) );
$this->assertEquals( array( array( 'badaccess-group0' ),
array( 'protectedpagetext', 'bogus' ),
- array( 'protectedpagetext', 'protect' ),
array( 'protectedpagetext', 'protect' ) ),
$this->title->getUserPermissionsErrors( 'bogus',
$this->user ) );
- $this->assertEquals( array(),
+ $this->assertEquals( array(
+ array( 'protectedpagetext', 'bogus' ),
+ array( 'protectedpagetext', 'protect' ) ),
$this->title->getUserPermissionsErrors( 'edit',
$this->user ) );
+
$this->title->mCascadeRestriction = true;
+ $this->setUserPerm( "edit" );
+ $this->assertEquals( false,
+ $this->title->quickUserCan( 'bogus', $this->user ) );
+ $this->assertEquals( false,
+ $this->title->quickUserCan( 'edit', $this->user ) );
+ $this->assertEquals( array( array( 'badaccess-group0' ),
+ array( 'protectedpagetext', 'bogus' ),
+ array( 'protectedpagetext', 'editprotected' ),
+ array( 'protectedpagetext', 'protect' ) ),
+ $this->title->getUserPermissionsErrors( 'bogus',
+ $this->user ) );
+ $this->assertEquals( array( array( 'protectedpagetext', 'bogus' ),
+ array( 'protectedpagetext', 'editprotected' ),
+ array( 'protectedpagetext', 'protect' ) ),
+ $this->title->getUserPermissionsErrors( 'edit',
+ $this->user ) );
+
+ $this->setUserPerm( array( "edit", "editprotected" ) );
$this->assertEquals( false,
$this->title->quickUserCan( 'bogus', $this->user ) );
$this->assertEquals( false,
$this->assertEquals( false,
$this->title->userCan( 'bogus', $this->user ) );
$this->assertEquals( array( array( "cascadeprotected", 2, "* [[:Bogus]]\n* [[:UnBogus]]\n" ),
+ array( "cascadeprotected", 2, "* [[:Bogus]]\n* [[:UnBogus]]\n" ),
array( "cascadeprotected", 2, "* [[:Bogus]]\n* [[:UnBogus]]\n" ) ),
$this->title->getUserPermissionsErrors( 'bogus', $this->user ) );
$this->title->mTitleProtection['pt_create_perm'] = 'sysop';
$this->setUserPerm( array( 'createpage', 'protect' ) );
+ $this->assertEquals( array( array( 'titleprotected', 'Useruser', 'test' ) ),
+ $this->title->getUserPermissionsErrors( 'create', $this->user ) );
+ $this->assertEquals( false,
+ $this->title->userCan( 'create', $this->user ) );
+
+ $this->setUserPerm( array( 'createpage', 'editprotected' ) );
$this->assertEquals( array(),
$this->title->getUserPermissionsErrors( 'create', $this->user ) );
$this->assertEquals( true,