protected function setUp() { parent::setUp(); $this->mUserMock = $this->getMockBuilder('User')->disableOriginalConstructor()->getMock(); // Set up groups and rights $this->mUserMock->expects($this->any())->method('getEffectiveGroups')->will($this->returnValue(array('*', 'user'))); $this->mUserMock->expects($this->any())->method('isAllowed')->will($this->returnValue(true)); // Set up callback for User::getOptionKinds $this->mUserMock->expects($this->any())->method('getOptionKinds')->will($this->returnCallback(array($this, 'getOptionKinds'))); // Create a new context $this->mContext = new DerivativeContext(new RequestContext()); $this->mContext->getContext()->setTitle(Title::newFromText('Test')); $this->mContext->setUser($this->mUserMock); $main = new ApiMain($this->mContext); // Empty session $this->mSession = array(); $this->mTested = new ApiOptions($main, 'options'); $this->mergeMwGlobalArrayValue('wgHooks', array('GetPreferences' => array(array($this, 'hookGetPreferences')))); }