a3b5adb8588774e98ef80468eb310b13ed90c7f3
3 * Factory for handling the special page list and generating SpecialPage objects.
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License along
16 * with this program; if not, write to the Free Software Foundation, Inc.,
17 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
18 * http://www.gnu.org/copyleft/gpl.html
22 abstract class FormSpecialPageTestCase
extends SpecialPageTestBase
{
25 * @covers FormSpecialPage::checkExecutePermissions
27 public function testCheckExecutePermissionsSitewideBlock() {
28 $special = $this->newSpecialPage();
29 $checkExecutePermissions = $this->getMethod( $special, 'checkExecutePermissions' );
31 $user = clone $this->getTestUser()->getUser();
32 $user->mBlockedby
= $user->getName();
33 $user->mBlock
= new Block( [
34 'address' => '127.0.8.1',
35 'by' => $user->getId(),
36 'reason' => 'sitewide block',
37 'timestamp' => time(),
42 $this->expectException( UserBlockedError
::class );
43 $checkExecutePermissions( $user );
47 * @covers FormSpecialPage::checkExecutePermissions
49 public function testCheckExecutePermissionsPartialBlock() {
50 $special = $this->newSpecialPage();
51 $checkExecutePermissions = $this->getMethod( $special, 'checkExecutePermissions' );
53 $user = clone $this->getTestUser()->getUser();
54 $user->mBlockedby
= $user->getName();
55 $user->mBlock
= new Block( [
56 'address' => '127.0.8.1',
57 'by' => $user->getId(),
58 'reason' => 'partial block',
59 'timestamp' => time(),
64 $this->assertNull( $checkExecutePermissions( $user ) );
68 * Get a protected/private method.
74 protected function getMethod( $obj, $name ) {
75 $method = new ReflectionMethod( $obj, $name );
76 $method->setAccessible( true );
77 return $method->getClosure( $obj );