Adrian Lang has uploaded a new change for review.
https://gerrit.wikimedia.org/r/140088
Change subject: Remove getEditUrl from SectionEditLinkGenerator interface
......................................................................
Remove getEditUrl from SectionEditLinkGenerator interface
This also changes the interface of SiteLinksView::getHtml to expect
a SiteLinks and a EntityId argument instead of an Item.
Change-Id: I2e7bd49b1ca1dfd303cffd8e4d07ac3a7b7da361
---
M repo/includes/EntityView.php
M repo/includes/ItemView.php
M repo/includes/View/SectionEditLinkGenerator.php
M repo/includes/View/SiteLinksView.php
M repo/includes/View/TermBoxView.php
M repo/tests/phpunit/includes/View/SectionEditLinkGeneratorTest.php
M repo/tests/phpunit/includes/View/SiteLinksViewTest.php
7 files changed, 151 insertions(+), 111 deletions(-)
git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Wikibase
refs/changes/88/140088/1
diff --git a/repo/includes/EntityView.php b/repo/includes/EntityView.php
index 2f075f9..34cea6a 100644
--- a/repo/includes/EntityView.php
+++ b/repo/includes/EntityView.php
@@ -404,10 +404,9 @@
public function getHtmlForLabel( Entity $entity, $editable = true ) {
wfProfileIn( __METHOD__ );
- $lang = $this->getLanguage();
+ $langCode = $this->getLanguage()->getCode();
- $label = $entity->getLabel( $lang->getCode() );
- $editUrl = $this->sectionEditLinkGenerator->getEditUrl(
'SetLabel', $entity, $lang );
+ $label = $entity->getLabel( $langCode );
$prefixedId = $this->getFormattedIdForEntity( $entity );
$html = wfTemplate( 'wb-label',
@@ -416,7 +415,7 @@
$label === false ? 'wb-value-empty' : '',
htmlspecialchars( $label === false ? wfMessage(
'wikibase-label-empty' )->text() : $label ),
wfTemplate( 'wb-property-value-supplement',
wfMessage( 'parentheses', $prefixedId ) )
- . $this->getHtmlForEditSection(
$editUrl )
+ . $this->getHtmlForEditSection(
'SetLabel', array( $prefixedId, $langCode ) )
)
);
@@ -436,15 +435,16 @@
public function getHtmlForDescription( Entity $entity, $editable = true
) {
wfProfileIn( __METHOD__ );
- $lang = $this->getLanguage();
- $description = $entity->getDescription( $lang->getCode() );
- $editUrl = $this->sectionEditLinkGenerator->getEditUrl(
'SetDescription', $entity, $lang );
+ $langCode = $this->getLanguage()->getCode();
+ $prefixedId = $this->getFormattedIdForEntity( $entity );
+
+ $description = $entity->getDescription( $langCode );
$html = wfTemplate( 'wb-description',
wfTemplate( 'wb-property',
$description === false ? 'wb-value-empty' : '',
htmlspecialchars( $description === false ?
wfMessage( 'wikibase-description-empty' )->text() : $description ),
- $this->getHtmlForEditSection( $editUrl )
+ $this->getHtmlForEditSection( 'SetDescription',
array( $prefixedId, $langCode ) )
)
);
@@ -464,17 +464,17 @@
public function getHtmlForAliases( Entity $entity, $editable = true ) {
wfProfileIn( __METHOD__ );
- $lang = $this->getLanguage();
+ $langCode = $this->getLanguage()->getCode();
+ $prefixedId = $this->getFormattedIdForEntity( $entity );
- $aliases = $entity->getAliases( $lang->getCode() );
- $editUrl = $this->sectionEditLinkGenerator->getEditUrl(
'SetAliases', $entity, $lang );
+ $aliases = $entity->getAliases( $langCode );
if ( empty( $aliases ) ) {
$html = wfTemplate( 'wb-aliases-wrapper',
'wb-aliases-empty',
'wb-value-empty',
wfMessage( 'wikibase-aliases-empty' )->text(),
- $this->getHtmlForEditSection( $editUrl, 'span',
'add' )
+ $this->getHtmlForEditSection( 'SetAliases',
array( $prefixedId, $langCode ), 'add' )
);
} else {
$aliasesHtml = '';
@@ -487,7 +487,7 @@
'',
'',
wfMessage( 'wikibase-aliases-label' )->text(),
- $aliasList . $this->getHtmlForEditSection(
$editUrl )
+ $aliasList . $this->getHtmlForEditSection(
'SetAliases', array( $prefixedId, $langCode ) )
);
}
@@ -562,7 +562,7 @@
htmlspecialchars( $propertyLabel )
);
- $htmlForEditSection = $this->getHtmlForEditSection( '',
'span' ); // TODO: add link to SpecialPage
+ $htmlForEditSection = $this->getHtmlForEditSection( '',
array() ); // TODO: add link to SpecialPage
foreach( $claims as $claim ) {
$propertyHtml .=
$this->claimHtmlGenerator->getHtmlForClaim(
@@ -575,7 +575,7 @@
$toolbarHtml = wfTemplate( 'wikibase-toolbar',
'wb-addtoolbar',
// TODO: add link to SpecialPage
- $this->getHtmlForEditSection( '', 'span', 'add'
)
+ $this->getHtmlForEditSection( '', array(),
'add' )
);
$claimsHtml .= wfTemplate( 'wb-claimlistview',
@@ -602,18 +602,18 @@
*
* @since 0.2
*
- * @param string $url specifies the URL for the button, default is an
empty string
- * @param string $tag allows to specify the type of the outer node
+ * @param string $specialPage specifies the special page
+ * @param string[] $specialPageParams specifies additional params for
the special page
* @param string $action by default 'edit', for aliases this could also
be 'add'
* @param bool $enabled can be set to false to display the button
disabled
*
* @return string
*/
- private function getHtmlForEditSection( $url, $tag = 'span', $action =
'edit', $enabled = true ) {
+ private function getHtmlForEditSection( $specialPage, array
$specialPageParams, $action = 'edit', $enabled = true ) {
$key = $action === 'add' ? 'wikibase-add' : 'wikibase-edit';
$msg = $this->getContext()->msg( $key );
- return $this->sectionEditLinkGenerator->getHtmlForEditSection(
$url, $msg, $tag, $enabled );
+ return $this->sectionEditLinkGenerator->getHtmlForEditSection(
$specialPage, $specialPageParams, $msg, $enabled );
}
/**
diff --git a/repo/includes/ItemView.php b/repo/includes/ItemView.php
index aa43457..e226d5a 100644
--- a/repo/includes/ItemView.php
+++ b/repo/includes/ItemView.php
@@ -83,7 +83,7 @@
$this->sectionEditLinkGenerator
);
- return $siteLinksView->getHtml( $item, $groups, $editable );
+ return $siteLinksView->getHtml( $item->getSiteLinks(),
$item->getId(), $groups, $editable );
}
}
diff --git a/repo/includes/View/SectionEditLinkGenerator.php
b/repo/includes/View/SectionEditLinkGenerator.php
index ae0172f..f25d638 100644
--- a/repo/includes/View/SectionEditLinkGenerator.php
+++ b/repo/includes/View/SectionEditLinkGenerator.php
@@ -26,29 +26,26 @@
*
* @since 0.2
*
- * @param string $url specifies the URL for the button, default is an
empty string
+ * @param string $specialPageName the special page for the button
+ * @param string[] $specialPageUrlParams Additional URL params for the
special page
* @param Message $message the message to show on the link
- * @param string $tag allows to specify the type of the outer node
* @param bool $enabled can be set to false to display the button
disabled
*
* @return string
*/
- public function getHtmlForEditSection( $url, Message $message, $tag =
'span', $enabled = true ) {
+ public function getHtmlForEditSection(
+ $specialPageName,
+ array $specialPageUrlParams,
+ Message $message,
+ $enabled = true
+ ) {
wfProfileIn( __METHOD__ );
- $buttonLabel = $message->text();
-
- $button = ( $enabled ) ?
- wfTemplate( 'wikibase-toolbarbutton',
- $buttonLabel,
- $url // todo: add link to special page for
non-JS editing
- ) :
- wfTemplate( 'wikibase-toolbarbutton-disabled',
- $buttonLabel
- );
+ $editUrl = $this->getEditUrl( $specialPageName,
$specialPageUrlParams );
+ $button = $this->getEditLink( $editUrl, $message, $enabled );
$html = wfTemplate( 'wb-editsection',
- $tag,
+ 'span',
wfTemplate( 'wikibase-toolbar',
'',
wfTemplate( 'wikibase-toolbareditgroup',
@@ -65,29 +62,39 @@
/**
* Get the Url to an edit special page
*
- * @since 0.5
- *
* @param string $specialPageName The special page to link to
- * @param Entity $entity The entity to edit
- * @param Language $language The desired language of the special page
+ * @param string[] $specialPageUrlParams Additional URL params for the
special page
*/
- public function getEditUrl( $specialPageName, Entity $entity, Language
$language = null ) {
+ private function getEditUrl( $specialPageName, array
$specialPageUrlParams ) {
$specialPage = SpecialPageFactory::getPage( $specialPageName );
if ( $specialPage === null ) {
return ''; //XXX: this should throw an exception?!
}
- if ( $entity->getId() ) {
- $subPage = $entity->getId()->getPrefixedId();
- } else {
- $subPage = ''; // can't skip this, that would confuse
the order of parameters!
- }
-
- if ( $language !== null ) {
- $subPage .= '/' . $language->getCode();
- }
+ $subPage = implode( '/', array_map( 'wfUrlencode',
$specialPageUrlParams ) );
return $specialPage->getPageTitle( $subPage )->getLocalURL();
}
+ /**
+ * @param string $editUrl The edit url
+ * @param Message $message the message to show on the link
+ * @param bool $enabled can be set to false to display the button
disabled
+ *
+ * @return string
+ */
+ private function getEditLink( $editUrl, Message $message, $enabled =
true ) {
+ $buttonLabel = $message->text();
+
+ $button = ( $enabled ) ?
+ wfTemplate( 'wikibase-toolbarbutton',
+ $buttonLabel,
+ $editUrl // todo: add link to special page for
non-JS editing
+ ) :
+ wfTemplate( 'wikibase-toolbarbutton-disabled',
+ $buttonLabel
+ );
+
+ return $button;
+ }
}
diff --git a/repo/includes/View/SiteLinksView.php
b/repo/includes/View/SiteLinksView.php
index c4bafa4..49950b8 100644
--- a/repo/includes/View/SiteLinksView.php
+++ b/repo/includes/View/SiteLinksView.php
@@ -5,7 +5,7 @@
use Message;
use SiteStore;
use Wikibase\DataModel\SiteLink;
-use Wikibase\Item;
+use Wikibase\DataModel\Entity\EntityId;
use Wikibase\Repo\WikibaseRepo;
use Wikibase\Utils;
@@ -24,17 +24,18 @@
*
* @since 0.5
*
- * @param Item $item the item to render
+ * @param SiteLinks $siteLinks the site links to render
+ * @param EntityId $entityId The id of the entity
* @param string[] $groups An array of site group IDs
* @param bool $editable whether editing is allowed (enabled edit links)
*
* @return string
*/
- public function getHtml( Item $item, array $groups, $editable ) {
+ public function getHtml( $siteLinks, EntityId $entityId, array $groups,
$editable ) {
$html = '';
foreach ( $groups as $group ) {
- $html .= $this->getHtmlForSiteLinkGroup( $item, $group,
$editable );
+ $html .= $this->getHtmlForSiteLinkGroup( $siteLinks,
$entityId, $group, $editable );
}
return $html;
@@ -43,12 +44,13 @@
/**
* Builds and returns the HTML representing a group of a
WikibaseEntity's site-links.
*
- * @param Item $item the entity to render
+ * @param SiteLinks $siteLinks the site links to render
+ * @param EntityId $entityId The id of the entity
* @param string $group a site group ID
* @param bool $editable whether editing is allowed (enabled edit links)
* @return string
*/
- private function getHtmlForSiteLinkGroup( Item $item, $group, $editable
= true ) {
+ private function getHtmlForSiteLinkGroup( $siteLinks, EntityId
$entityId, $group, $editable = true ) {
// FIXME: editable is completely unused
@@ -57,7 +59,7 @@
// @todo inject into constructor
$sites = $this->siteStore->getSites()->getGroup( $group );
- $siteLinksForTable = $this->getSiteLinksForTable( $sites,
$group, $item );
+ $siteLinksForTable = $this->getSiteLinksForTable( $sites,
$group, $siteLinks );
$html = $thead = $tbody = $tfoot = '';
@@ -68,12 +70,9 @@
// TODO: support entity-id as prefix for element IDs.
);
- // Link to SpecialPage
- $editLink = $this->sectionEditLinkGenerator->getEditUrl(
'SetSiteLink', $item, null );
-
if( !empty( $siteLinksForTable ) ) {
$thead = $this->getTableHeadHtml( $isSpecialGroup );
- $tbody = $this->getTableBodyHtml( $siteLinksForTable,
$editLink, $isSpecialGroup );
+ $tbody = $this->getTableBodyHtml( $siteLinksForTable,
$entityId, $isSpecialGroup );
}
// Build table footer with button to add site-links, consider
list could be complete!
@@ -81,7 +80,7 @@
// $siteLinksForTable only has an entry for links to existing
sites, this
// simple comparison works.
$isFull = count( $siteLinksForTable ) >= count( $sites );
- $tfoot = $this->getTableFootHtml( $isFull, $editLink );
+ $tfoot = $this->getTableFootHtml( $entityId, $isFull );
$groupName = $isSpecialGroup ? 'special' : $group;
@@ -97,13 +96,12 @@
/**
* @param SiteList $sites
* @param string $group
- * @param Item $item
+ * @param SiteLink[] $itemSiteLinks
*/
- private function getSiteLinksForTable( $sites, $group, $item ) {
- $allSiteLinks = $item->getSiteLinks();
+ private function getSiteLinksForTable( $sites, $group, $itemSiteLinks )
{
$siteLinksForTable = array(); // site links of the currently
handled site group
- foreach( $allSiteLinks as $siteLink ) {
+ foreach( $itemSiteLinks as $siteLink ) {
if ( !$sites->hasSite( $siteLink->getSiteId() ) ) {
// FIXME: Maybe show it instead
continue;
@@ -154,29 +152,29 @@
/**
* @param object[] $siteLinksForTable
- * @param string $editLink
+ * @param EntityId $entityId The id of the entity
* @param bool $isSpecialGroup
*/
- private function getTableBodyHtml( $siteLinksForTable, $editLink,
$isSpecialGroup ) {
+ private function getTableBodyHtml( $siteLinksForTable, $entityId,
$isSpecialGroup ) {
$i = 0;
$tbody = '';
foreach( $siteLinksForTable as $siteLinkForTable ) {
$alternatingClass = ( $i++ % 2 ) ? 'even' : 'uneven';
- $tbody .= $this->getHtmlForSiteLink( $siteLinkForTable,
$editLink, $isSpecialGroup, $alternatingClass );
+ $tbody .= $this->getHtmlForSiteLink( $siteLinkForTable,
$entityId, $isSpecialGroup, $alternatingClass );
}
return $tbody;
}
/**
+ * @param EntityId $entityId The id of the entity
* @param bool $isFull
- * @param string $editLink
*/
- private function getTableFootHtml( $isFull, $editLink ) {
+ private function getTableFootHtml( $entityId, $isFull ) {
$tfoot = wfTemplate( 'wb-sitelinks-tfoot',
$isFull ? wfMessage( 'wikibase-sitelinksedittool-full'
)->parse() : '',
- $this->getHtmlForEditSection( $editLink, 'td', 'add',
!$isFull )
+ '<td>' . $this->getHtmlForEditSection( $entityId, '',
'add', !$isFull ) . '</td>'
);
return $tfoot;
@@ -184,11 +182,11 @@
/**
* @param object $siteLinkForTable
- * @param string $editLink
+ * @param EntityId $entityId The id of the entity
* @param bool $isSpecialGroup
* @param string $alternatingClass
*/
- private function getHtmlForSiteLink( $siteLinkForTable, $editLink,
$isSpecialGroup, $alternatingClass ) {
+ private function getHtmlForSiteLink( $siteLinkForTable, $entityId,
$isSpecialGroup, $alternatingClass ) {
/* @var Site $site */
$site = $siteLinkForTable['site'];
@@ -196,7 +194,7 @@
$siteLink = $siteLinkForTable['siteLink'];
if ( $site->getDomain() === '' ) {
- return $this->getHtmlForUnknownSiteLink( $siteLink,
$editLink, $alternatingClass );
+ return $this->getHtmlForUnknownSiteLink( $siteLink,
$entityId, $alternatingClass );
}
$languageCode = $site->getLanguageCode();
@@ -225,17 +223,17 @@
$escapedSiteId, // displayed site ID
htmlspecialchars( $site->getPageUrl( $pageName ) ),
$escapedPageName,
- $this->getHtmlForEditSection( $editLink . '/' .
$escapedSiteId, 'td' ),
+ '<td>' . $this->getHtmlForEditSection( $entityId,
$escapedSiteId ) . '</td>',
$escapedSiteId // ID used in classes
);
}
/**
* @param SiteLink $siteLink
- * @param string $editLink
+ * @param EntityId $entityId The id of the entity
* @param string $alternatingClass
*/
- private function getHtmlForUnknownSiteLink( $siteLink, $editLink,
$alternatingClass ) {
+ private function getHtmlForUnknownSiteLink( $siteLink, $entityId,
$alternatingClass ) {
// the link is pointing to an unknown site.
// XXX: hide it? make it red? strike it out?
@@ -248,14 +246,26 @@
$alternatingClass,
$escapedSiteId,
$escapedPageName,
- $this->getHtmlForEditSection( $editLink, 'td' )
+ '<td>' . $this->getHtmlForEditSection( $entityId ) .
'</td>'
);
}
- private function getHtmlForEditSection( $url, $tag = 'span', $action =
'edit', $enabled = true ) {
+ private function getHtmlForEditSection( EntityId $entityId, $subPage =
'', $action = 'edit', $enabled = true ) {
$msg = new Message( 'wikibase-' . $action );
+ $specialPage = 'SetSiteLink';
+ $specialPageParams = array(
+ $entityId->getPrefixedId()
+ );
+ if( $subPage !== '' ) {
+ $specialPageParams[] = $subPage;
+ }
- return $this->sectionEditLinkGenerator->getHtmlForEditSection(
$url, $msg, $tag, $enabled );
+ return $this->sectionEditLinkGenerator->getHtmlForEditSection(
+ $specialPage,
+ $specialPageParams,
+ $msg,
+ $enabled
+ );
}
}
diff --git a/repo/includes/View/TermBoxView.php
b/repo/includes/View/TermBoxView.php
index 4eeb0d0..167029c 100644
--- a/repo/includes/View/TermBoxView.php
+++ b/repo/includes/View/TermBoxView.php
@@ -68,6 +68,7 @@
$labels = $entity->getLabels();
$descriptions = $entity->getDescriptions();
+ $entityId = $this->getFormattedIdForEntity( $entity );
$html .= wfTemplate( 'wb-terms-heading', $this->msg(
'wikibase-terms' ) );
@@ -77,14 +78,20 @@
$label = array_key_exists( $language, $labels ) ?
$labels[$language] : false;
$description = array_key_exists( $language,
$descriptions ) ? $descriptions[$language] : false;
+ $editLabelSection =
$this->sectionEditLinkGenerator->getHtmlForEditSection(
+ 'SetLabel',
+ array( $entityId, $language ),
+ $this->msg( 'wikibase-edit' ),
+ $editable
+ );
+ $editDescriptionSection =
$this->sectionEditLinkGenerator->getHtmlForEditSection(
+ 'SetDescription',
+ array( $entityId, $language ),
+ $this->msg( 'wikibase-edit' ),
+ $editable
+ );
+
$alternatingClass = ( $rowNumber++ % 2 ) ? 'even' :
'uneven';
-
- $entitySubPage = $this->getFormattedIdForEntity(
$entity ) . '/' . $language;
- $specialSetLabel = SpecialPage::getTitleFor(
"SetLabel", $entitySubPage );
- $specialSetDescription = SpecialPage::getTitleFor(
"SetDescription", $entitySubPage );
-
- $editLabelLink = $specialSetLabel->getLocalURL();
- $editDescriptionLink =
$specialSetDescription->getLocalURL();
$tbody .= wfTemplate( 'wb-term',
$language,
@@ -92,8 +99,8 @@
htmlspecialchars( Utils::fetchLanguageName(
$language ) ),
htmlspecialchars( $label !== false ? $label :
$this->msg( 'wikibase-label-empty' )->text() ),
htmlspecialchars( $description !== false ?
$description : $this->msg( 'wikibase-description-empty' )->text() ),
-
$this->sectionEditLinkGenerator->getHtmlForEditSection( $editLabelLink,
$this->msg( 'wikibase-edit' ), 'span', $editable ),
-
$this->sectionEditLinkGenerator->getHtmlForEditSection( $editDescriptionLink,
$this->msg( 'wikibase-edit' ), 'span', $editable ),
+ $editLabelSection,
+ $editDescriptionSection,
$label !== false ? '' : 'wb-value-empty',
$description !== false ? '' : 'wb-value-empty',
$title->getLocalURL( array( 'setlang' =>
$language ) )
diff --git a/repo/tests/phpunit/includes/View/SectionEditLinkGeneratorTest.php
b/repo/tests/phpunit/includes/View/SectionEditLinkGeneratorTest.php
index 1e28164..65942b0 100644
--- a/repo/tests/phpunit/includes/View/SectionEditLinkGeneratorTest.php
+++ b/repo/tests/phpunit/includes/View/SectionEditLinkGeneratorTest.php
@@ -25,15 +25,15 @@
/**
* @dataProvider getHtmlForEditSectionProvider
*/
- public function testGetHtmlForEditSection( $expected, $url, $tag,
$action, $enabled, $langCode ) {
+ public function testGetHtmlForEditSection( $expected, $pageName,
$action, $enabled, $langCode ) {
$generator = new SectionEditLinkGenerator();
$key = $action === 'add' ? 'wikibase-add' : 'wikibase-edit';
$msg = wfMessage( $key )->inLanguage( $langCode );
- $editSectionHtml = $generator->getHtmlForEditSection( $url,
$msg, $tag, $enabled );
+ $editSectionHtml = $generator->getHtmlForEditSection(
$pageName, array(), $msg, $enabled );
$matcher = array(
- 'tag' => $tag,
+ 'tag' => 'span',
'class' => 'wb-editsection'
);
@@ -45,16 +45,14 @@
return array(
array(
'/' . wfMessage( 'wikibase-edit' )->inLanguage(
'es' )->text() . '/',
- '',
- 'div',
+ 'Version',
'edit',
true,
'es'
),
array(
'/' . wfMessage( 'wikibase-add' )->inLanguage(
'de' )->text() . '/',
- '',
- 'span',
+ 'Version',
'add',
true,
'de'
@@ -63,29 +61,39 @@
}
/**
- * @dataProvider getEditUrlProvider
- * @covers SectionEditLinkGenerator::getEditUrl
+ * @dataProvider getHtmlForEditSection_editUrlProvider
+ * @covers SectionEditLinkGenerator::getHtmlForEditSection
*/
- public function testGetEditUrl( $expected, $specialpagename, Entity
$entity, $language = null ) {
+ public function testGetHtmlForEditSection_editUrl( $expected,
$specialPageName, $specialPageParams ) {
$generator = new SectionEditLinkGenerator();
- $editUrl = $generator->getEditUrl( $specialpagename, $entity,
$language );
+ $editSection = $generator->getHtmlForEditSection(
$specialPageName, $specialPageParams, wfMessage( 'wikibase-add' ) );
- $this->assertRegExp( $expected, $editUrl );
+ $this->assertTag( $expected, $editSection );
}
- public function getEditUrlProvider() {
+ public function getHtmlForEditSection_editUrlProvider() {
return array(
array(
- '+' . preg_quote(
SpecialPageFactory::getLocalNameFor( 'Version' ), '+' ) . '/Q1$+',
+ array(
+ 'tag' => 'a',
+ 'attributes' => array(
+ 'href' => 'regexp:+' .
preg_quote( SpecialPageFactory::getLocalNameFor( 'Version' ), '+' ) . '/Q1$+',
+ )
+ ),
'Version',
- new Item( array( 'entity' => 'Q1' ) )
+ array( 'Q1' )
),
array(
- '+' . preg_quote(
SpecialPageFactory::getLocalNameFor( 'Version' ), '+' ) . '/Q1/de$+',
+ array(
+ 'tag' => 'a',
+ 'attributes' => array(
+ 'href' => 'regexp:+' .
preg_quote( SpecialPageFactory::getLocalNameFor( 'Version' ), '+' ) .
'/Q1/de$+',
+ 'href' =>
'regexp:+Special:Version/Q1/de+'
+ )
+ ),
'Version',
- new Item( array( 'entity' => 'Q1' ) ),
- Language::factory( 'de' )
+ array( 'Q1', 'de' ),
)
);
}
diff --git a/repo/tests/phpunit/includes/View/SiteLinksViewTest.php
b/repo/tests/phpunit/includes/View/SiteLinksViewTest.php
index 7d0bb0a..eb9839e 100644
--- a/repo/tests/phpunit/includes/View/SiteLinksViewTest.php
+++ b/repo/tests/phpunit/includes/View/SiteLinksViewTest.php
@@ -5,6 +5,7 @@
use MediaWikiSite;
use SiteList;
use Wikibase\DataModel\Entity\Item;
+use Wikibase\DataModel\Entity\EntityId;
use Wikibase\DataModel\SiteLink;
use Wikibase\Repo\WikibaseRepo;
use Wikibase\Repo\View\SiteLinksView;
@@ -48,7 +49,7 @@
) {
$siteLinksView = new SiteLinksView( $siteStore,
$sectionEditLinkGenerator );
- $value = $siteLinksView->getHtml( $item, $groups, $editable );
+ $value = $siteLinksView->getHtml( $item->getSiteLinks(),
$item->getId(), $groups, $editable );
$this->assertInternalType( 'string', $value );
$this->assertTag( $expectedValue, $value, $value . ' did not
match ' . var_export( $expectedValue, true ) );
}
@@ -60,6 +61,7 @@
$testCases = array();
$item = Item::newEmpty();
+ $item->setId( EntityId::newFromPrefixedId( 'Q1' ) );
$item->addSiteLink( new SiteLink( 'enwiki', 'test' ) );
$testCases[] = array(
@@ -101,6 +103,7 @@
);
$item = Item::newEmpty();
+ $item->setId( EntityId::newFromPrefixedId( 'Q1' ) );
$item->addSiteLink( new SiteLink( 'specialwiki', 'test' ) );
$testCases[] = array(
@@ -124,6 +127,7 @@
);
$item = Item::newEmpty();
+ $item->setId( EntityId::newFromPrefixedId( 'Q1' ) );
$testCases[] = array(
$siteStore,
@@ -141,6 +145,7 @@
);
$item = Item::newEmpty();
+ $item->setId( EntityId::newFromPrefixedId( 'Q1' ) );
$item->addSiteLink( new SiteLink( 'dewiki', 'test' ) );
$item->addSiteLink( new SiteLink( 'enwiki', 'test2' ) );
@@ -162,6 +167,7 @@
);
$item = Item::newEmpty();
+ $item->setId( EntityId::newFromPrefixedId( 'Q1' ) );
$item->addSiteLink( new SiteLink( 'dewiki', 'test' ) );
$item->addSiteLink( new SiteLink( 'nonexistingwiki', 'test2' )
);
@@ -197,7 +203,7 @@
) {
$siteLinksView = new SiteLinksView( $siteStore,
$sectionEditLinkGenerator );
- $value = $siteLinksView->getHtml( $item, $groups, $editable );
+ $value = $siteLinksView->getHtml( $item->getSiteLinks(),
$item->getId(), $groups, $editable );
$this->assertInternalType( 'string', $value );
$this->assertEquals( '', $value );
}
@@ -206,12 +212,15 @@
$siteStore = $this->getSiteStoreMock();
$sectionEditLinkGenerator =
$this->getSectionEditLinkGeneratorMock();
+ $item = Item::newEmpty();
+ $item->setId( EntityId::newFromPrefixedId( 'Q1' ) );
+
$testCases = array();
$testCases[] = array(
$siteStore,
$sectionEditLinkGenerator,
- Item::newEmpty(),
+ $item,
array(),
true,
);
@@ -219,12 +228,11 @@
$testCases[] = array(
$siteStore,
$sectionEditLinkGenerator,
- Item::newEmpty(),
+ $item,
array(),
false,
);
- $item = Item::newEmpty();
$item->addSiteLink( new SiteLink( 'enwiki', 'test' ) );
$testCases[] = array(
--
To view, visit https://gerrit.wikimedia.org/r/140088
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I2e7bd49b1ca1dfd303cffd8e4d07ac3a7b7da361
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/Wikibase
Gerrit-Branch: master
Gerrit-Owner: Adrian Lang <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits