/**
* @group Database
+ *
+ * @covers Title::getUserPermissionsErrors
+ * @covers Title::getUserPermissionsErrorsInternal
*/
class TitlePermissionTest extends MediaWikiLangTestCase {
date_default_timezone_set( $localZone );
$this->title = Title::makeTitle( NS_MAIN, "Main Page" );
- if ( !isset( $this->userUser ) || !( $this->userUser instanceOf User ) ) {
+ if ( !isset( $this->userUser ) || !( $this->userUser instanceof User ) ) {
$this->userUser = User::newFromName( $this->userName );
if ( !$this->userUser->getID() ) {
}
}
- function setUserPerm( $perm ) {
+ protected function setUserPerm( $perm ) {
// Setting member variables is evil!!!
if ( is_array( $perm ) ) {
}
}
- function setTitle( $ns, $title = "Main_Page" ) {
+ protected function setTitle( $ns, $title = "Main_Page" ) {
$this->title = Title::makeTitle( $ns, $title );
}
- function setUser( $userName = null ) {
+ protected function setUser( $userName = null ) {
if ( $userName === 'anon' ) {
$this->user = $this->anonUser;
} elseif ( $userName === null || $userName === $this->userName ) {
}
}
- function testQuickPermissions() {
+ /**
+ * @todo This test method should be split up into separate test methods and
+ * data providers
+ */
+ public function testQuickPermissions() {
global $wgContLang;
$prefix = $wgContLang->getFormattedNsText( NS_PROJECT );
$this->runGroupPermissions( 'move', array( array( 'movenotallowedfile' ) ) );
$this->setUserPerm( "" );
- $this->runGroupPermissions( 'move', array( array( 'movenotallowedfile' ), array( 'movenotallowed' ) ) );
+ $this->runGroupPermissions(
+ 'move',
+ array( array( 'movenotallowedfile' ), array( 'movenotallowed' ) )
+ );
$this->setUser( 'anon' );
$this->setUserPerm( "move" );
$this->runGroupPermissions( 'move', array( array( 'movenotallowedfile' ) ) );
$this->setUserPerm( "" );
- $this->runGroupPermissions( 'move', array( array( 'movenotallowedfile' ), array( 'movenotallowed' ) ),
- array( array( 'movenotallowedfile' ), array( 'movenologintext' ) ) );
+ $this->runGroupPermissions(
+ 'move',
+ array( array( 'movenotallowedfile' ), array( 'movenotallowed' ) ),
+ array( array( 'movenotallowedfile' ), array( 'movenologintext' ) )
+ );
if ( $this->isWikitextNS( NS_MAIN ) ) {
//NOTE: some content models don't allow moving
$this->assertEquals( array(), $res );
$this->setUser( 'anon' );
- $check = array( 'edit' => array( array( array( 'badaccess-groups', "*, [[$prefix:Users|Users]]", 2 ) ),
- array( array( 'badaccess-group0' ) ),
- array(), true ),
- 'protect' => array( array( array( 'badaccess-groups', "[[$prefix:Administrators|Administrators]]", 1 ), array( 'protect-cantedit' ) ),
+ $check = array(
+ 'edit' => array(
+ array( array( 'badaccess-groups', "*, [[$prefix:Users|Users]]", 2 ) ),
+ array( array( 'badaccess-group0' ) ),
+ array(),
+ true
+ ),
+ '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 ) );
+ array( array( 'protect-cantedit' ) ),
+ false
+ ),
+ '' => array( array(), array(), array(), true )
+ );
foreach ( array( "edit", "protect", "" ) as $action ) {
$this->setUserPerm( null );
}
}
- function runGroupPermissions( $action, $result, $result2 = null ) {
+ protected function runGroupPermissions( $action, $result, $result2 = null ) {
global $wgGroupPermissions;
if ( $result2 === null ) {
$this->assertEquals( $result2, $res );
}
- function testSpecialsAndNSPermissions() {
+ /**
+ * @todo This test method should be split up into separate test methods and
+ * data providers
+ */
+ public function testSpecialsAndNSPermissions() {
global $wgNamespaceProtection;
$this->setUser( $this->userName );
$this->title->userCan( 'bogus', $this->user ) );
}
- function testCssAndJavascriptPermissions() {
+ /**
+ * @todo This test method should be split up into separate test methods and
+ * data providers
+ */
+ public function testCssAndJavascriptPermissions() {
$this->setUser( $this->userName );
$this->setTitle( NS_USER, $this->userName . '/test.js' );
);
}
- function runCSSandJSPermissions( $result0, $result1, $result2, $result3, $result4 ) {
+ protected function runCSSandJSPermissions( $result0, $result1, $result2, $result3, $result4 ) {
$this->setUserPerm( '' );
$this->assertEquals( $result0,
$this->title->getUserPermissionsErrors( 'bogus',
$this->user ) );
}
- function testPageRestrictions() {
+ /**
+ * @todo This test method should be split up into separate test methods and
+ * data providers
+ */
+ public function testPageRestrictions() {
global $wgContLang;
$prefix = $wgContLang->getFormattedNsText( NS_PROJECT );
$this->user ) );
}
- function testCascadingSourcesRestrictions() {
+ public function testCascadingSourcesRestrictions() {
$this->setTitle( NS_MAIN, "test page" );
$this->setUserPerm( array( "edit", "bogus" ) );
- $this->title->mCascadeSources = array( Title::makeTitle( NS_MAIN, "Bogus" ), Title::makeTitle( NS_MAIN, "UnBogus" ) );
- $this->title->mCascadingRestrictions = array( "bogus" => array( 'bogus', "sysop", "protect", "" ) );
+ $this->title->mCascadeSources = array(
+ Title::makeTitle( NS_MAIN, "Bogus" ),
+ Title::makeTitle( NS_MAIN, "UnBogus" )
+ );
+ $this->title->mCascadingRestrictions = array(
+ "bogus" => array( 'bogus', "sysop", "protect", "" )
+ );
$this->assertEquals( false,
$this->title->userCan( 'bogus', $this->user ) );
$this->title->getUserPermissionsErrors( 'edit', $this->user ) );
}
- function testActionPermissions() {
+ /**
+ * @todo This test method should be split up into separate test methods and
+ * data providers
+ */
+ public function testActionPermissions() {
$this->setUserPerm( array( "createpage" ) );
$this->setTitle( NS_MAIN, "test page" );
$this->title->mTitleProtection['pt_create_perm'] = '';
$this->title->userCan( 'move-target', $this->user ) );
}
- function testUserBlock() {
+ public function testUserBlock() {
global $wgEmailConfirmToEdit, $wgEmailAuthentication;
$wgEmailConfirmToEdit = true;
$wgEmailAuthentication = true;