22
33namespace Wikibase \Repo \Tests \Domains \Reuse \Infrastructure \GraphQL ;
44
5+ use DataValues \Geo \Values \GlobeCoordinateValue ;
6+ use DataValues \Geo \Values \LatLongValue ;
57use DataValues \StringValue ;
68use Generator ;
79use GraphQL \GraphQL ;
@@ -45,6 +47,7 @@ class GraphQLServiceTest extends MediaWikiIntegrationTestCase {
4547 private static Item $ qualifierValueItem ;
4648 private static Property $ stringTypeProperty ;
4749 private static Property $ itemTypeProperty ;
50+ private static Property $ globeCoordinateTypeProperty ;
4851 private static Property $ qualifierProperty ;
4952 private static MediaWikiSite $ sitelinkSite ;
5053 private const ALLOWED_SITELINK_SITES = [ 'examplewiki ' , 'otherwiki ' ];
@@ -78,6 +81,7 @@ public function testQuery( string $query, array $expectedResult ): void {
7881 $ dataTypeLookup ->setDataTypeForProperty ( self ::$ stringTypeProperty ->getId (), 'string ' );
7982 $ dataTypeLookup ->setDataTypeForProperty ( self ::$ qualifierProperty ->getId (), 'string ' );
8083 $ dataTypeLookup ->setDataTypeForProperty ( self ::$ itemTypeProperty ->getId (), 'wikibase-item ' );
84+ $ dataTypeLookup ->setDataTypeForProperty ( self ::$ globeCoordinateTypeProperty ->getId (), 'globe-coordinate ' );
8185
8286 $ this ->assertEquals (
8387 $ expectedResult ,
@@ -117,8 +121,9 @@ public function queryProvider(): Generator {
117121 $ statementWithNoValuePropertyId = 'P4 ' ;
118122 $ statementWithNoReferencesPropertyId = $ statementWithNoValuePropertyId ;
119123 $ statementWithSomeValuePropertyId = 'P5 ' ;
124+ $ statementWithGlobeCoordinateValuePropertyId = 'P6 ' ;
120125 $ statementWithItemValueQualifierPropertyId = $ statementWithItemValuePropertyId ; // also type wikibase-item so we can just reuse it.
121- $ statementReferencePropertyId = 'P6 ' ;
126+ $ statementReferencePropertyId = 'P11 ' ;
122127 $ unusedPropertyId = 'P9999 ' ;
123128 $ qualifierStringValue = 'qualifierStringValue ' ;
124129 $ statementStringValue = 'statementStringValue ' ;
@@ -135,6 +140,11 @@ public function queryProvider(): Generator {
135140 ->withValue ( new ItemId ( $ itemValueItemId ) )
136141 ->withQualifier ( $ statementWithItemValueQualifierPropertyId , self ::$ qualifierValueItem ->getId () )
137142 ->build ();
143+ $ globeCoordinateValue = new GlobeCoordinateValue ( new LatLongValue ( 52.516 , 13.383 ) );
144+ $ statementWithGlobeCoordinateValue = NewStatement::forProperty ( $ statementWithGlobeCoordinateValuePropertyId )
145+ ->withGuid ( "$ itemId \$a82559b1-da8f-4e02-9f72-e304b90a9bde " )
146+ ->withValue ( $ globeCoordinateValue )
147+ ->build ();
138148
139149 $ statementWithNoValue = NewStatement::noValueFor ( ( $ statementWithNoValuePropertyId ) )
140150 ->withGuid ( "$ itemId \$bed933b7-4207-d679-7571-3630cfb49d9f " )
@@ -154,6 +164,11 @@ public function queryProvider(): Generator {
154164 'string ' ,
155165 );
156166 self ::$ itemTypeProperty = new Property ( new NumericPropertyId ( $ statementWithItemValuePropertyId ), null , 'wikibase-item ' );
167+ self ::$ globeCoordinateTypeProperty = new Property (
168+ new NumericPropertyId ( $ statementWithGlobeCoordinateValuePropertyId ),
169+ null ,
170+ 'globe-coordinate ' ,
171+ );
157172 self ::$ qualifierProperty = new Property (
158173 new NumericPropertyId ( $ qualifierPropertyId ),
159174 new Fingerprint ( new TermList ( [ new Term ( 'en ' , 'qualifier prop ' ) ] ) ),
@@ -167,6 +182,7 @@ public function queryProvider(): Generator {
167182 ->andSiteLink ( $ sitelinkSiteId , $ sitelinkTitle )
168183 ->andStatement ( $ statementWithStringValue )
169184 ->andStatement ( $ statementWithItemValue )
185+ ->andStatement ( $ statementWithGlobeCoordinateValue )
170186 ->andStatement ( $ statementWithNoValue )
171187 ->andStatement ( $ statementWithSomeValue )
172188 ->build ();
@@ -355,6 +371,31 @@ public function queryProvider(): Generator {
355371 ],
356372 ],
357373 ];
374+ yield 'statement with globe-coordinate value ' => [
375+ "{ item(id: \"$ itemId \") {
376+ statements(propertyId: \"$ statementWithGlobeCoordinateValuePropertyId \") {
377+ value {
378+ ... on GlobeCoordinateValue { latitude longitude precision globe }
379+ }
380+ }
381+ } } " ,
382+ [
383+ 'data ' => [
384+ 'item ' => [
385+ 'statements ' => [
386+ [
387+ 'value ' => [
388+ 'latitude ' => $ globeCoordinateValue ->getLatitude (),
389+ 'longitude ' => $ globeCoordinateValue ->getLongitude (),
390+ 'precision ' => $ globeCoordinateValue ->getPrecision (),
391+ 'globe ' => $ globeCoordinateValue ->getGlobe (),
392+ ],
393+ ],
394+ ],
395+ ],
396+ ],
397+ ],
398+ ];
358399 yield 'statements with novalue and somevalue ' => [
359400 "{ item(id: \"$ itemId \") {
360401 $ statementWithSomeValuePropertyId: statements(propertyId: \"$ statementWithSomeValuePropertyId \") {
0 commit comments