WMDE-leszek has uploaded a new change for review. (
https://gerrit.wikimedia.org/r/347812 )
Change subject: DO NOT SUBMIT: for demonstration purpose only
......................................................................
DO NOT SUBMIT: for demonstration purpose only
This is just to demonstrate a possible way to have tests
in I53c8a1162fccc2b3f5b4179d9b1d5327decc5ff4 fixed.
Note: Test using custom ItemHandler must rely on the statement
using property other than other tests use. Somehow all
tests seem to be using the custom handler?
Change-Id: If686b79e70197b70c4a73545664eb7f0f0dd7a6c
---
M repo/tests/phpunit/includes/Content/ItemContentTest.php
1 file changed, 31 insertions(+), 13 deletions(-)
git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Wikibase
refs/changes/12/347812/1
diff --git a/repo/tests/phpunit/includes/Content/ItemContentTest.php
b/repo/tests/phpunit/includes/Content/ItemContentTest.php
index 90e98a4..9bb7d30 100644
--- a/repo/tests/phpunit/includes/Content/ItemContentTest.php
+++ b/repo/tests/phpunit/includes/Content/ItemContentTest.php
@@ -168,14 +168,17 @@
* @return EntityContent
*/
private function getItemContentWithIdentifierClaims() {
+ $itemContent = $this->newEmpty();
+ $item = $itemContent->getItem();
- $item = new Item( new ItemId( 'Q2' ) );
- $snak = new PropertyValueSnak( new PropertyId( 'P11' ), new
StringValue( 'Tehran' ) );
- $guid = $item->getId()->getSerialization() .
'$D8404CDA-25E4-4334-AG93-A3290BCD9C0P';
- $item->getStatements()->addNewStatement( $snak, null, null,
$guid );
+ $item->getStatements()->addNewStatement(
+ new PropertyNoValueSnak( new PropertyId( 'P111' ) ),
+ null,
+ null,
+ 'Whatever'
+ );
- $handler = $this->getItemHandler();
- return $handler->makeEntityContent( new EntityInstanceHolder(
$item ) );
+ return $itemContent;
}
/**
@@ -184,7 +187,7 @@
private function getPropertyDataTypeLookup() {
$dataTypeLookup = new InMemoryDataTypeLookup();
- $dataTypeLookup->setDataTypeForProperty( new PropertyId( 'P11'
), 'external-id' );
+ $dataTypeLookup->setDataTypeForProperty( new PropertyId( 'P111'
), 'external-id' );
return $dataTypeLookup;
}
@@ -262,16 +265,31 @@
)
);
- $cases['identifiers'] = [
- $this->getItemContentWithIdentifierClaims(),
+ return $cases;
+ }
+
+ public function testFoo() {
+ $itemHandler = $this->getItemHandler();
+ $this->setMwGlobals(
+ 'wgContentHandlers',
[
- 'wb-claims' => 1,
- 'wb-identifiers' => 1,
- 'wb-sitelinks' => 0,
+ 'wikibase-item' => function () use (
$itemHandler ) {
+ return $itemHandler;
+ }
]
+ );
+
+ $expectedPageProps = [
+ 'wb-claims' => 1,
+ 'wb-identifiers' => 1,
+ 'wb-sitelinks' => 0,
];
- return $cases;
+ $content = $this->getItemContentWithIdentifierClaims();
+
+ $pageProps = $content->getEntityPageProperties();
+
+ $this->assertEquals( $expectedPageProps, $pageProps );
}
public function diffProvider() {
--
To view, visit https://gerrit.wikimedia.org/r/347812
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: If686b79e70197b70c4a73545664eb7f0f0dd7a6c
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/Wikibase
Gerrit-Branch: master
Gerrit-Owner: WMDE-leszek <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits