Addshore has uploaded a new change for review.
https://gerrit.wikimedia.org/r/232689
Change subject: Add tests for getentities with fallback and props
......................................................................
Add tests for getentities with fallback and props
Bug: T109603
Change-Id: Id6e7bc9dbbd0f89a6e1129b7b051b20d8c806950
---
M repo/tests/phpunit/includes/api/GetEntitiesTest.php
1 file changed, 53 insertions(+), 12 deletions(-)
git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Wikibase
refs/changes/89/232689/1
diff --git a/repo/tests/phpunit/includes/api/GetEntitiesTest.php
b/repo/tests/phpunit/includes/api/GetEntitiesTest.php
index c4b4dab..1c69fb7 100644
--- a/repo/tests/phpunit/includes/api/GetEntitiesTest.php
+++ b/repo/tests/phpunit/includes/api/GetEntitiesTest.php
@@ -435,7 +435,7 @@
public function provideLanguageFallback() {
return array(
- array(
+ 'Guangzhou Fallback' => array(
'Guangzhou',
array( 'de-formal', 'en', 'fr', 'yue', 'zh-cn',
'zh-hk' ),
array(
@@ -490,7 +490,7 @@
),
),
- array(
+ 'Oslo Fallback' => array(
'Oslo',
array( 'sli', 'de-formal', 'kn', 'nb' ),
array(
@@ -536,26 +536,67 @@
),
),
),
+ 'Oslo Fallback - Labels Only' => array(
+ 'Oslo',
+ array( 'sli', 'de-formal', 'kn', 'nb' ),
+ array(
+ 'sli' => array(
+ 'language' => 'de',
+ 'value' => 'Oslo',
+ 'for-language' => 'sli',
+ ),
+ 'de-formal' => array(
+ 'language' => 'de',
+ 'value' => 'Oslo',
+ 'for-language' => 'de-formal',
+ ),
+ 'kn' => array(
+ 'language' => 'en',
+ 'value' => 'Oslo',
+ 'for-language' => 'kn',
+ ),
+ 'nb' => array(
+ 'language' => 'nb',
+ 'value' => 'Oslo',
+ ),
+ ),
+ null,
+ array( 'labels' )
+ ),
);
}
/**
* @dataProvider provideLanguageFallback
*/
- public function testLanguageFallback( $handle, $languages,
$expectedLabels, $expectedDescriptions ) {
+ public function testLanguageFallback(
+ $handle,
+ $languages,
+ $expectedLabels = null,
+ $expectedDescriptions = null,
+ $props = array()
+ ) {
$id = EntityTestHelper::getId( $handle );
- list( $res,, ) = $this->doApiRequest(
- array(
- 'action' => 'wbgetentities',
- 'languages' => join( '|', $languages ),
- 'languagefallback' => '',
- 'ids' => $id,
- )
+ $params = array(
+ 'action' => 'wbgetentities',
+ 'languages' => join( '|', $languages ),
+ 'languagefallback' => '',
+ 'ids' => $id,
);
- $this->assertEquals( $expectedLabels,
$res['entities'][$id]['labels'] );
- $this->assertEquals( $expectedDescriptions,
$res['entities'][$id]['descriptions'] );
+ if ( !empty( $props ) ) {
+ $params['props'] = implode( '|', $props );
+ }
+
+ list( $res,, ) = $this->doApiRequest( $params );
+
+ if ( $expectedLabels !== null ) {
+ $this->assertEquals( $expectedLabels,
$res['entities'][$id]['labels'] );
+ }
+ if ( $expectedDescriptions !== null ) {
+ $this->assertEquals( $expectedDescriptions,
$res['entities'][$id]['descriptions'] );
+ }
}
public function testSiteLinkFilter() {
--
To view, visit https://gerrit.wikimedia.org/r/232689
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: Id6e7bc9dbbd0f89a6e1129b7b051b20d8c806950
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/Wikibase
Gerrit-Branch: master
Gerrit-Owner: Addshore <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits