jenkins-bot has submitted this change and it was merged. ( https://gerrit.wikimedia.org/r/386111 )
Change subject: Add missing Lua tests and clean up ...................................................................... Add missing Lua tests and clean up This adds Lua integration tests for: * mw.wikibase.getEntityUrl * mw.wikibase.getPropertyOrder * mw.wikibase.orderProperties Change-Id: I742f40ae892563debe7cd2ccbb0ccda55789274c --- M client/tests/phpunit/includes/DataAccess/Scribunto/LuaWikibaseLibraryTests.lua M client/tests/phpunit/includes/DataAccess/Scribunto/Scribunto_LuaWikibaseLibraryTest.php 2 files changed, 41 insertions(+), 2 deletions(-) Approvals: jenkins-bot: Verified Thiemo Mättig (WMDE): Looks good to me, approved diff --git a/client/tests/phpunit/includes/DataAccess/Scribunto/LuaWikibaseLibraryTests.lua b/client/tests/phpunit/includes/DataAccess/Scribunto/LuaWikibaseLibraryTests.lua index 73de15f..80292f8 100644 --- a/client/tests/phpunit/includes/DataAccess/Scribunto/LuaWikibaseLibraryTests.lua +++ b/client/tests/phpunit/includes/DataAccess/Scribunto/LuaWikibaseLibraryTests.lua @@ -87,6 +87,12 @@ return mw.wikibase.formatValues( snaks ) end +local function testGetEntityUrl( expectedItemId, itemId ) + local url = mw.wikibase.getEntityUrl( itemId ) + + return url:match( '//.*/' .. expectedItemId ) ~= nil +end + local tests = { -- Integration tests @@ -118,7 +124,7 @@ args = { 0, 'P12' }, expect = "bad argument #1 to 'getBestStatements' (string expected, got number)" }, - { name = 'mw.wikibase.getBestStatements (entityId must be string)', func = mw.wikibase.getBestStatements, type='ToString', + { name = 'mw.wikibase.getBestStatements (propertyId must be string)', func = mw.wikibase.getBestStatements, type='ToString', args = { 'Q2', 12 }, expect = "bad argument #2 to 'getBestStatements' (string expected, got number)" }, @@ -132,7 +138,7 @@ args = { 0, 'P12' }, expect = "bad argument #1 to 'getAllStatements' (string expected, got number)" }, - { name = 'mw.wikibase.getAllStatements (entityId must be string)', func = mw.wikibase.getAllStatements, type='ToString', + { name = 'mw.wikibase.getAllStatements (propertyId must be string)', func = mw.wikibase.getAllStatements, type='ToString', args = { 'Q2', 12 }, expect = "bad argument #2 to 'getAllStatements' (string expected, got number)" }, @@ -311,6 +317,33 @@ args = { 'foo' }, expect = { nil } }, + { name = 'mw.wikibase.getEntityUrl (by entity id)', func = testGetEntityUrl, + args = { 'Q42', 'Q42' }, + expect = { true } + }, + { name = 'mw.wikibase.getEntityUrl (connected page)', func = testGetEntityUrl, + args = { 'Q32487', nil }, + expect = { true } + }, + { name = 'mw.wikibase.getEntityUrl (must be string or nil)', func = mw.wikibase.getEntityUrl, + args = { -1 }, + expect = "bad argument #1 to 'getEntityUrl' (string or nil expected, got number)" + }, + { name = 'mw.wikibase.getEntityUrl (invalid entity id)', func = mw.wikibase.getEntityUrl, + args = { "BlahBlah" }, + expect = { nil } + }, + { name = 'mw.wikibase.getPropertyOrder', func = mw.wikibase.getPropertyOrder, + expect = { { ['P1'] = 0, ['P22'] = 1, ['P11'] = 2 } } + }, + { name = 'mw.wikibase.orderProperties', func = mw.wikibase.orderProperties, + args = { { 'P22', 'P1', 'P44', 'Llama' } }, + expect = { { 'P1', 'P22', 'P44', 'Llama' } } + }, + { name = 'mw.wikibase.orderProperties (must be table)', func = mw.wikibase.orderProperties, + args = { function() end }, + expect = "bad argument #1 to 'orderProperties' (table expected, got function)" + }, } return testframework.getTestProvider( tests ) diff --git a/client/tests/phpunit/includes/DataAccess/Scribunto/Scribunto_LuaWikibaseLibraryTest.php b/client/tests/phpunit/includes/DataAccess/Scribunto/Scribunto_LuaWikibaseLibraryTest.php index 423268d..16c70a2 100644 --- a/client/tests/phpunit/includes/DataAccess/Scribunto/Scribunto_LuaWikibaseLibraryTest.php +++ b/client/tests/phpunit/includes/DataAccess/Scribunto/Scribunto_LuaWikibaseLibraryTest.php @@ -20,6 +20,7 @@ * @group WikibaseIntegration * @group WikibaseClient * @group Wikibase + * @group Database * * @license GPL-2.0+ * @author Katie Filbert < aude.w...@gmail.com > @@ -55,6 +56,11 @@ $settings = WikibaseClient::getDefaultInstance()->getSettings(); $this->oldAllowDataAccessInUserLanguage = $settings->getSetting( 'allowDataAccessInUserLanguage' ); $this->setAllowDataAccessInUserLanguage( false ); + + $this->insertPage( + 'MediaWiki:Wikibase-SortedProperties', + "* P1\n* P22\n* P11" + ); } protected function tearDown() { -- To view, visit https://gerrit.wikimedia.org/r/386111 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: merged Gerrit-Change-Id: I742f40ae892563debe7cd2ccbb0ccda55789274c Gerrit-PatchSet: 2 Gerrit-Project: mediawiki/extensions/Wikibase Gerrit-Branch: master Gerrit-Owner: Hoo man <h...@online.de> Gerrit-Reviewer: Hoo man <h...@online.de> Gerrit-Reviewer: Jackmcbarn <jackmcb...@gmail.com> Gerrit-Reviewer: Ladsgroup <ladsgr...@gmail.com> Gerrit-Reviewer: Thiemo Mättig (WMDE) <thiemo.maet...@wikimedia.de> Gerrit-Reviewer: jenkins-bot <> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits