Gergő Tisza has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/169334

Change subject: Ignore book title
......................................................................

Ignore book title

Titles parsed from {{Book}} templates are usually irrelevant and should be
ignored (we don't want to show the title of some book containing the image
)instead of the name of the image).

Also add test for extracting the title.

Change-Id: I27879afbaefe40a879a34eccdf7515a6f9bbe3e2
Mingle: https://wikimedia.mingle.thoughtworks.com/projects/multimedia/cards/589
---
M tests/phpunit/ParserTestHelper.php
M tests/phpunit/TemplateParserTest.php
2 files changed, 16 insertions(+), 0 deletions(-)


  git pull 
ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/CommonsMetadata 
refs/changes/34/169334/1

diff --git a/tests/phpunit/ParserTestHelper.php 
b/tests/phpunit/ParserTestHelper.php
index e765b59..5a42736 100644
--- a/tests/phpunit/ParserTestHelper.php
+++ b/tests/phpunit/ParserTestHelper.php
@@ -34,6 +34,10 @@
                'manylang' => 
'File_Sikh_pilgrim_at_the_Golden_Temple_(Harmandir_Sahib)_in_Amritsar,_India.jpg',
                // an image with a relatively long description
                'big' => 'File_Askaris_im_Warschauer_Getto_-_1943.jpg',
+               // information-like template with a title field
+           'title' => 'File_Askaris_im_Warschauer_Getto_-_1943.jpg',
+           // Book + Photograph templates
+           'book' => 'File_Askaris_im_Warschauer_Getto_-_1943.jpg',
        );
 
        /**
diff --git a/tests/phpunit/TemplateParserTest.php 
b/tests/phpunit/TemplateParserTest.php
index e6c11fc..b14e0ae 100644
--- a/tests/phpunit/TemplateParserTest.php
+++ b/tests/phpunit/TemplateParserTest.php
@@ -2,6 +2,8 @@
 
 use CommonsMetadata\TemplateParser;
 
+require_once __DIR__ . "/ParserTestHelper.php";
+
 /**
  * @covers CommonsMetadata\TemplateParser
  * @group Extensions/CommonsMetadata
@@ -178,6 +180,16 @@
                        $data, TemplateParser::INFORMATION_FIELDS_KEY );
        }
 
+       /**
+        * Some templates (such as {{Photograph}}) have a title field
+        */
+       public function testTitle() {
+               $data = $this->parseTestHTML( 'title' );
+               $this->assertFieldEquals( 'ObjectName', '<span class="fn"><span 
style="font-size:0.9em">German: '
+                       . '<i>Askaris, die mit eingesetzt waren</i></span><span 
style="font-weight:bold"><br>'
+                       . '<i>Askaris used during the 
operation</i></span></span>', $data, TemplateParser::INFORMATION_FIELDS_KEY );
+       }
+
 
        // -------------------- license tests --------------------
 

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I27879afbaefe40a879a34eccdf7515a6f9bbe3e2
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/CommonsMetadata
Gerrit-Branch: master
Gerrit-Owner: GergÅ‘ Tisza <[email protected]>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to