Thiemo Mättig (WMDE) has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/340135 )

Change subject: Remove unused code from TermView components and tests
......................................................................

Remove unused code from TermView components and tests

Clean ups for all the comments in Icbee448.

Bug: T134735
Change-Id: Ie802ef9ba0ac90bbcc1421ef230d9c8b55e91eda
---
M repo/tests/phpunit/includes/ParserOutput/EntityViewPlaceholderExpanderTest.php
M view/src/SimpleEntityTermsView.php
M view/tests/phpunit/SimpleEntityTermsViewTest.php
3 files changed, 18 insertions(+), 36 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Wikibase 
refs/changes/35/340135/1

diff --git 
a/repo/tests/phpunit/includes/ParserOutput/EntityViewPlaceholderExpanderTest.php
 
b/repo/tests/phpunit/includes/ParserOutput/EntityViewPlaceholderExpanderTest.php
index e3d2ce7..6625c74 100644
--- 
a/repo/tests/phpunit/includes/ParserOutput/EntityViewPlaceholderExpanderTest.php
+++ 
b/repo/tests/phpunit/includes/ParserOutput/EntityViewPlaceholderExpanderTest.php
@@ -6,7 +6,6 @@
 use User;
 use Wikibase\DataModel\Entity\Item;
 use Wikibase\DataModel\Entity\ItemId;
-use Wikibase\DataModel\Term\AliasesProvider;
 use Wikibase\Lib\LanguageNameLookup;
 use Wikibase\Repo\ParserOutput\EntityViewPlaceholderExpander;
 use Wikibase\View\DummyLocalizedTextProvider;
@@ -31,12 +30,10 @@
        /**
         * @param User $user
         * @param Item $item
-        * @param ItemId $itemId
-        * @param AliasesProvider|null $aliasesProvider
         *
         * @return EntityViewPlaceholderExpander
         */
-       private function newExpander( User $user, Item $item, ItemId $itemId, 
AliasesProvider $aliasesProvider = null ) {
+       private function newExpander( User $user, Item $item ) {
                $templateFactory = TemplateFactory::getDefaultInstance();
 
                $termsLanguages = [ 'de', 'en', 'ru' ];
@@ -54,23 +51,14 @@
                );
        }
 
-       public function provideEntityAndAliases() {
+       public function provideEntity() {
                $item = new Item( new ItemId( 'Q23' ) );
-
                $item->setLabel( 'en', 'Moskow' );
                $item->setLabel( 'de', 'Moskau' );
-
                $item->setDescription( 'de', 'Hauptstadt Russlands' );
 
                return [
-                       [
-                               $item,
-                               $item
-                       ],
-                       [
-                               $item,
-                               null
-                       ]
+                       [ $item ],
                ];
        }
 
@@ -94,20 +82,20 @@
        }
 
        /**
-        * @dataProvider provideEntityAndAliases
+        * @dataProvider provideEntity
         */
-       public function testGetHtmlForPlaceholder( Item $item, AliasesProvider 
$aliasesProvider = null ) {
-               $expander = $this->newExpander( $this->newUser(), $item, 
$item->getId(), $aliasesProvider );
+       public function testGetHtmlForPlaceholder( Item $item ) {
+               $expander = $this->newExpander( $this->newUser(), $item );
 
                $html = $expander->getHtmlForPlaceholder( 'termbox' );
                $this->assertInternalType( 'string', $html );
        }
 
        /**
-        * @dataProvider provideEntityAndAliases
+        * @dataProvider provideEntity
         */
-       public function testRenderTermBox( Item $item, AliasesProvider 
$aliasesProvider = null ) {
-               $expander = $this->newExpander( $this->newUser(), $item, 
$item->getId(), $aliasesProvider );
+       public function testRenderTermBox( Item $item ) {
+               $expander = $this->newExpander( $this->newUser(), $item );
 
                // According to the mock objects, this should generate a term 
box for
                // 'de' and 'ru', since 'en' is already covered by the 
interface language.
diff --git a/view/src/SimpleEntityTermsView.php 
b/view/src/SimpleEntityTermsView.php
index e38a30f..4c759aa 100644
--- a/view/src/SimpleEntityTermsView.php
+++ b/view/src/SimpleEntityTermsView.php
@@ -99,7 +99,7 @@
                                        $mainLanguageCode,
                                        $labels,
                                        $descriptions,
-                                       $aliasGroups ?: new AliasGroupList()
+                                       $aliasGroups
                                )
                        ),
                        '',
@@ -150,7 +150,7 @@
         *  title and header section. Not necessarily identical to the 
interface language.
         * @param TermList $labels
         * @param TermList $descriptions
-        * @param AliasGroupList $aliasGroups
+        * @param AliasGroupList|null $aliasGroups
         *
         * @return string[]
         */
@@ -158,7 +158,7 @@
                $mainLanguageCode,
                TermList $labels,
                TermList $descriptions,
-               AliasGroupList $aliasGroups
+               AliasGroupList $aliasGroups = null
        ) {
                $allLanguages = [ $mainLanguageCode ];
 
@@ -168,8 +168,10 @@
                $descriptionLanguages = array_keys( 
$descriptions->toTextArray() );
                $allLanguages = array_merge( $allLanguages, 
$descriptionLanguages );
 
-               $aliasLanguages = array_keys( $aliasGroups->toTextArray() );
-               $allLanguages = array_merge( $allLanguages, $aliasLanguages );
+               if ( $aliasGroups ) {
+                       $aliasLanguages = array_keys( 
$aliasGroups->toTextArray() );
+                       $allLanguages = array_merge( $allLanguages, 
$aliasLanguages );
+               }
 
                $allLanguages = array_unique( $allLanguages );
                return $allLanguages;
diff --git a/view/tests/phpunit/SimpleEntityTermsViewTest.php 
b/view/tests/phpunit/SimpleEntityTermsViewTest.php
index 633e420..b3358a9 100644
--- a/view/tests/phpunit/SimpleEntityTermsViewTest.php
+++ b/view/tests/phpunit/SimpleEntityTermsViewTest.php
@@ -140,8 +140,8 @@
        }
 
        public function testGetHtml_isMarkedAsEmptyValue() {
-               $entityTermsView = $this->getEntityTermsView( 1 );
-               $html = $entityTermsView->getHtml( 'en', new TermList(), new 
TermList(), new AliasGroupList(), null );
+               $view = $this->getEntityTermsView( 1 );
+               $html = $view->getHtml( 'en', new TermList(), new TermList() );
 
                $this->assertContains( 'wb-empty', $html );
                $this->assertContains( '(wikibase-description-empty)', $html );
@@ -169,14 +169,6 @@
                $this->assertContains( 'wb-empty', $html );
                $this->assertContains( '(wikibase-description-empty)', $html );
                $this->assertContains( 'wikibase-entitytermsview-aliases', 
$html );
-       }
-
-       public function testGetHtml_containsEmptyAliasesList() {
-               $view = $this->getEntityTermsView( 1 );
-               $html = $view->getHtml( 'en', new TermList(), new TermList(), 
new AliasGroupList() );
-
-               $this->assertContains( 'wb-empty', $html );
-               $this->assertContains( '<div 
class="wikibase-entitytermsview-heading-aliases wb-empty"></div>', $html );
        }
 
        /**

-- 
To view, visit https://gerrit.wikimedia.org/r/340135
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: Ie802ef9ba0ac90bbcc1421ef230d9c8b55e91eda
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/Wikibase
Gerrit-Branch: master
Gerrit-Owner: Thiemo Mättig (WMDE) <thiemo.maet...@wikimedia.de>

_______________________________________________
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to