Thiemo Mättig (WMDE) has uploaded a new change for review.
https://gerrit.wikimedia.org/r/147054
Change subject: Add tests for NULL to ActionTest
......................................................................
Add tests for NULL to ActionTest
NULL should default to 'view'. But both the exists check and the
factory should fail when asked for a NULL action.
Change-Id: I5751489eed890bb44101f2a4ef73002bff68b207
---
M tests/phpunit/includes/actions/ActionTest.php
1 file changed, 28 insertions(+), 6 deletions(-)
git pull ssh://gerrit.wikimedia.org:29418/mediawiki/core
refs/changes/54/147054/1
diff --git a/tests/phpunit/includes/actions/ActionTest.php
b/tests/phpunit/includes/actions/ActionTest.php
index e81ec22..ba1cec0 100644
--- a/tests/phpunit/includes/actions/ActionTest.php
+++ b/tests/phpunit/includes/actions/ActionTest.php
@@ -21,6 +21,7 @@
$wgActions = array(
'null' => null,
'disabled' => false,
+ 'view' => true,
'dummy' => true,
'string' => 'NamedDummyAction',
'declared' => 'NonExistingClassName',
@@ -29,14 +30,16 @@
);
}
+ 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;
}
@@ -56,7 +59,6 @@
array( 'null', null ),
array( 'undeclared', null ),
array( '', null ),
- array( null, null ),
array( false, null ),
);
}
@@ -103,6 +105,26 @@
$this->assertType( isset( $expected ) ? $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' );
@@ -117,8 +139,8 @@
}
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 );
}
--
To view, visit https://gerrit.wikimedia.org/r/147054
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I5751489eed890bb44101f2a4ef73002bff68b207
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/core
Gerrit-Branch: master
Gerrit-Owner: Thiemo Mättig (WMDE) <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits