$this->setMwGlobals( 'wgActions', array(
'null' => null,
'disabled' => false,
+ 'view' => true,
'dummy' => true,
'string' => 'NamedDummyAction',
'declared' => 'NonExistingClassName',
) );
}
+ private function getPage() {
+ return WikiPage::factory( Title::makeTitle( 0, 'Title' ) );
+ }
+
private function getContext( $requestedAction = null ) {
$request = new FauxRequest( array( 'action' => $requestedAction ) );
- $page = WikiPage::factory( Title::makeTitle( 0, 'Title' ) );
-
$context = new DerivativeContext( RequestContext::getMain() );
$context->setRequest( $request );
- $context->setWikiPage( $page );
+ $context->setWikiPage( $this->getPage() );
return $context;
}
array( 'null', null ),
array( 'undeclared', null ),
array( '', null ),
- array( null, null ),
array( false, null ),
);
}
$this->assertType( $expected ?: 'null', $action );
}
+ public function testNull_doesNotExist() {
+ $exists = Action::exists( null );
+
+ $this->assertFalse( $exists );
+ }
+
+ public function testNull_defaultsToView() {
+ $context = $this->getContext( null );
+ $actionName = Action::getActionName( $context );
+
+ $this->assertEquals( 'view', $actionName );
+ }
+
+ public function testNull_canNotBeInstantiated() {
+ $page = $this->getPage();
+ $action = Action::factory( null, $page );
+
+ $this->assertNull( $action );
+ }
+
public function testDisabledAction_exists() {
$exists = Action::exists( 'disabled' );
}
public function testDisabledAction_factoryReturnsFalse() {
- $context = $this->getContext( 'disabled' );
- $action = Action::factory( 'disabled', $context->getWikiPage(), $context );
+ $page = $this->getPage();
+ $action = Action::factory( 'disabled', $page );
$this->assertFalse( $action );
}