jenkins-bot has submitted this change and it was merged.
Change subject: Add ViewEntityAction tests for diff and old revision
......................................................................
Add ViewEntityAction tests for diff and old revision
Smoke test that if requesting a diff or old revision,
that there are no edit links, and if a diff, it is
indeed showing a diff.
Change-Id: I5e5908fb29302e378c8dcc40110fdbb6152a9916
---
M repo/tests/phpunit/includes/actions/ViewEntityActionTest.php
1 file changed, 47 insertions(+), 5 deletions(-)
Approvals:
Daniel Kinzler: Looks good to me, approved
jenkins-bot: Verified
diff --git a/repo/tests/phpunit/includes/actions/ViewEntityActionTest.php
b/repo/tests/phpunit/includes/actions/ViewEntityActionTest.php
index 36282ab..4a0d4b6 100644
--- a/repo/tests/phpunit/includes/actions/ViewEntityActionTest.php
+++ b/repo/tests/phpunit/includes/actions/ViewEntityActionTest.php
@@ -62,19 +62,61 @@
*/
public function testShow( $handle, $regex ) {
$page = $this->getTestItemPage( $handle );
- $action = $this->createAction( "view", $page );
-
- $action->show();
- $html = $action->getOutput()->getHTML();
+ $html = $this->executeViewAction( $page, array() );
$this->assertRegExp( $regex, $html );
+ }
+
+ public function testShowDiff() {
+ $page = $this->getTestItemPage( 'Berlin' );
+
+ $latest = $page->getRevision();
+ $previous = $latest->getPrevious();
+
+ $params = array(
+ 'diff' => $latest->getId(),
+ 'oldid' => $previous->getId()
+ );
+
+ $html = $this->executeViewAction( $page, $params );
+
+ $this->assertRegExp( '/diff-currentversion-title/', $html, 'is
diff view' );
+ $this->assertNotRegExp( '/wikibase-edittoolbar-container/',
$html, 'no edit toolbar' );
+ }
+
+ public function testShowOldRevision_hasNoEditLinks() {
+ $page = $this->getTestItemPage( 'Berlin' );
+
+ $latest = $page->getRevision();
+ $previous = $latest->getPrevious();
+
+ $params = array(
+ 'oldid' => $previous->getId()
+ );
+
+ $html = $this->executeViewAction( $page, $params );
+
+ $this->assertNotRegExp( '/wikibase-edittoolbar-container/',
$html, 'no edit toolbar' );
+ }
+
+ /**
+ * @param WikiPage $page
+ * @param string[] $params
+ *
+ * @return string
+ */
+ private function executeViewAction( WikiPage $page, array $params ) {
+ $action = $this->createAction( 'view', $page, $params );
+ $action->show();
+
+ return $action->getOutput()->getHTML();
}
public function testShow404() {
$id = new ItemId( 'q1122334455' );
$title =
WikibaseRepo::getDefaultInstance()->getEntityContentFactory()->getTitleForId(
$id );
$page = new WikiPage( $title );
- $action = $this->createAction( "view", $page );
+ $action = $this->createAction( 'view', $page );
/* @var \FauxResponse $response */
$response = $action->getRequest()->response();
--
To view, visit https://gerrit.wikimedia.org/r/168827
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I5e5908fb29302e378c8dcc40110fdbb6152a9916
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/Wikibase
Gerrit-Branch: master
Gerrit-Owner: Aude <[email protected]>
Gerrit-Reviewer: Daniel Kinzler <[email protected]>
Gerrit-Reviewer: Thiemo Mättig (WMDE) <[email protected]>
Gerrit-Reviewer: jenkins-bot <>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits