jenkins-bot has submitted this change and it was merged.
Change subject: Basic EntityView PHPUnit test
......................................................................
Basic EntityView PHPUnit test
Change-Id: I33b2c32ae6a62062b37dc2bb8c0f8a3caf951068
---
M repo/Wikibase.hooks.php
A repo/tests/phpunit/includes/EntityViewTest.php
2 files changed, 94 insertions(+), 0 deletions(-)
Approvals:
Tobias Gritschacher: Looks good to me, approved
jenkins-bot: Verified
diff --git a/repo/Wikibase.hooks.php b/repo/Wikibase.hooks.php
index a30ba04..bd8c6ae 100755
--- a/repo/Wikibase.hooks.php
+++ b/repo/Wikibase.hooks.php
@@ -152,6 +152,7 @@
'Autocomment',
'ClaimSummaryBuilder',
'EditEntity',
+ 'EntityView',
'ItemMove',
'ItemContentDiffView',
'ItemMove',
diff --git a/repo/tests/phpunit/includes/EntityViewTest.php
b/repo/tests/phpunit/includes/EntityViewTest.php
new file mode 100644
index 0000000..2182c20
--- /dev/null
+++ b/repo/tests/phpunit/includes/EntityViewTest.php
@@ -0,0 +1,93 @@
+<?php
+
+namespace Wikibase\Test;
+use Wikibase\ItemContent;
+use \ValueFormatters\ValueFormatterFactory;
+
+/**
+ * @covers EntityView
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
USA
+ *
+ * @file
+ * @since 0.4
+ *
+ * @ingroup Wikibase
+ * @ingroup Test
+ *
+ * @group Wikibase
+ * @group WikibaseRepo
+ * @group EntityView
+ *
+ * @licence GNU GPL v2+
+ * @author H. Snater < [email protected] >
+ */
+class EntityViewTest extends \PHPUnit_Framework_TestCase {
+
+ /**
+ * @return array
+ */
+ public function getHtmlForClaimsProvider() {
+ $argLists = array();
+
+ $itemContent = ItemContent::newEmpty();
+ $itemContent->getEntity()->addClaim(
+ new \Wikibase\Claim(
+ new \Wikibase\PropertyNoValueSnak(
+ new \Wikibase\EntityId(
\Wikibase\Property::ENTITY_TYPE, 24 )
+ )
+ )
+ );
+
+ $argLists[] = array( $itemContent );
+
+ return $argLists;
+ }
+
+ /**
+ * @dataProvider getHtmlForClaimsProvider
+ *
+ * @param \Wikibase\EntityContent $entityContent
+ */
+ public function testGetHtmlForClaims( \Wikibase\EntityContent
$entityContent ) {
+
+ $entityView = \Wikibase\EntityView::newForEntityContent(
+ $entityContent,
+ new ValueFormatterFactory(
$GLOBALS['wgValueFormatters'] )
+ );
+
+ // Using a DOM document to parse HTML output:
+ $doc = new \DOMDocument();
+
+ // Disable default error handling in order to catch warnings
caused by malformed markup:
+ libxml_use_internal_errors( true );
+
+ // Try loading the HTML:
+ $this->assertTrue( $doc->loadHTML(
$entityView->getHtmlForClaims( $entityContent ) ) );
+
+ // Check if no warnings have been thrown:
+ $errorString = '';
+ foreach( libxml_get_errors() as $error ) {
+ $errorString .= "\r\n" . $error->message;
+ }
+
+ $this->assertEmpty( $errorString, 'Malformed markup:' .
$errorString );
+
+ // Clear error cache and re-enable default error handling:
+ libxml_clear_errors();
+ libxml_use_internal_errors();
+ }
+
+}
--
To view, visit https://gerrit.wikimedia.org/r/66957
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I33b2c32ae6a62062b37dc2bb8c0f8a3caf951068
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/Wikibase
Gerrit-Branch: master
Gerrit-Owner: Henning Snater <[email protected]>
Gerrit-Reviewer: Tobias Gritschacher <[email protected]>
Gerrit-Reviewer: jenkins-bot
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits