// Trying to get a WikiPage for NS_SPECIAL etc. will result
// in WikiPage::factory throwing "Invalid or virtual namespace -1 given."
// For SpecialPages et al, default to action=view.
- if ( !$context->canUseWikiPage() ) {
+ if ( $actionName === '' || !$context->canUseWikiPage() ) {
return 'view';
}
// Null and non-existing values
[ 'null', null ],
[ 'undeclared', null ],
- [ '', null ],
- [ false, null ],
];
}
$this->assertType( $expected ?: 'null', $action );
}
- public function testNull_doesNotExist() {
- $exists = Action::exists( null );
+ public function emptyActionProvider() {
+ return [
+ [ null ],
+ [ false ],
+ [ '' ],
+ ];
+ }
+
+ /**
+ * @dataProvider emptyActionProvider
+ */
+ public function testEmptyAction_doesNotExist( $requestedAction ) {
+ $exists = Action::exists( $requestedAction );
$this->assertFalse( $exists );
}
- public function testNull_defaultsToView() {
- $context = $this->getContext( null );
+ /**
+ * @dataProvider emptyActionProvider
+ */
+ public function testEmptyAction_defaultsToView( $requestedAction ) {
+ $context = $this->getContext( $requestedAction );
$actionName = Action::getActionName( $context );
$this->assertEquals( 'view', $actionName );
}
- public function testNull_canNotBeInstantiated() {
+ /**
+ * @dataProvider emptyActionProvider
+ */
+ public function testEmptyAction_canNotBeInstantiated( $requestedAction ) {
$page = $this->getPage();
- $action = Action::factory( null, $page );
+ $action = Action::factory( $requestedAction, $page );
$this->assertNull( $action );
}