$request = $this->context->getRequest();
$curid = $request->getInt( 'curid' );
$title = $request->getVal( 'title' );
- $action = $request->getVal( 'action', 'view' );
+ $action = $this->getAction();
if ( $request->getCheck( 'search' ) ) {
// Compatibility with old search URLs which didn't use Special:Search
throw new BadTitleError();
}
// Redirect loops, no title in URL, $wgUsePathInfo URLs, and URLs with a variant
- } elseif ( $request->getVal( 'action', 'view' ) == 'view' && !$request->wasPosted()
+ } elseif ( $this->getAction() === 'view' && !$request->wasPosted()
&& ( $request->getVal( 'title' ) === null
|| $title->getPrefixedDBkey() != $request->getVal( 'title' ) )
&& !count( $request->getValueNames( array( 'action', 'title' ) ) )
// Namespace might change when using redirects
// Check for redirects ...
- $action = $request->getVal( 'action', 'view' );
+ $action = $this->getAction();
$file = ( $title->getNamespace() == NS_FILE ) ? $article->getFile() : null;
if ( ( $action == 'view' || $action == 'render' ) // ... for actions that show content
&& !$request->getVal( 'oldid' ) // ... and are not old revisions
return;
}
- if ( wfRunHooks( 'UnknownAction', array( $request->getVal( 'action', 'view' ), $page ) ) ) {
+ if ( wfRunHooks( 'UnknownAction', array( $this->getAction(), $page ) ) ) {
$output->setStatusCode( 404 );
$output->showErrorPage( 'nosuchaction', 'nosuchactiontext' );
}
$request = $this->context->getRequest();
// Send Ajax requests to the Ajax dispatcher.
- if ( $this->config->get( 'UseAjax' ) && $request->getVal( 'action', 'view' ) == 'ajax' ) {
-
+ if ( $this->config->get( 'UseAjax' ) && $this->getAction() === 'ajax' ) {
// Set a dummy title, because $wgTitle == null might break things
$title = Title::makeTitle( NS_MAIN, 'AJAX' );
$this->context->setTitle( $title );
// Null and non-existing values
array( 'null', null ),
array( 'undeclared', null ),
- array( '', null ),
- array( false, null ),
);
}
$this->assertType( $expected ?: 'null', $action );
}
- public function testNull_doesNotExist() {
- $exists = Action::exists( null );
+ public function emptyActionProvider() {
+ return array(
+ array( null ),
+ array( false ),
+ array( '' ),
+ );
+ }
+
+ /**
+ * @dataProvider emptyActionProvider
+ */
+ public function testEmptyAction_doesNotExist( $requestedAction ) {
+ $exists = Action::exists( $requestedAction );
$this->assertFalse( $exists );
}
- public function testNull_defaultsToView() {
+ /**
+ * @dataProvider emptyActionProvider
+ */
+ public function testEmptyAction_defaultsToView() {
$context = $this->getContext( null );
$actionName = Action::getActionName( $context );
$this->assertEquals( 'view', $actionName );
}
- public function testNull_canNotBeInstantiated() {
+ /**
+ * @dataProvider emptyActionProvider
+ */
+ public function testEmptyAction_canNotBeInstantiated() {
$page = $this->getPage();
$action = Action::factory( null, $page );