diff options
Diffstat (limited to 'www/wiki/extensions/Maps/tests/Integration/MediaWiki/ParserHooks/GeodistanceTest.php')
-rw-r--r-- | www/wiki/extensions/Maps/tests/Integration/MediaWiki/ParserHooks/GeodistanceTest.php | 81 |
1 files changed, 81 insertions, 0 deletions
diff --git a/www/wiki/extensions/Maps/tests/Integration/MediaWiki/ParserHooks/GeodistanceTest.php b/www/wiki/extensions/Maps/tests/Integration/MediaWiki/ParserHooks/GeodistanceTest.php new file mode 100644 index 00000000..59489371 --- /dev/null +++ b/www/wiki/extensions/Maps/tests/Integration/MediaWiki/ParserHooks/GeodistanceTest.php @@ -0,0 +1,81 @@ +<?php + +namespace Maps\Tests\Integration\MediaWiki\ParserHooks; + +use DataValues\Geo\Values\LatLongValue; +use Maps\Elements\Location; +use Maps\MediaWiki\ParserHooks\GeoDistanceFunction; + +/** + * @covers GeoDistanceFunction + * + * @licence GNU GPL v2+ + * @author Jeroen De Dauw < jeroendedauw@gmail.com > + */ +class GeodistanceTest extends ParserHookTest { + + /** + * @see ParserHookTest::parametersProvider + */ + public function parametersProvider() { + $paramLists = []; + + $paramLists[] = [ + 'location1' => '4,2', + 'location2' => '42,0', + ]; + + $paramLists[] = [ + '4,2', + '42,0', + ]; + + return $this->arrayWrap( $paramLists ); + } + + /** + * @see ParserHookTest::processingProvider + * @since 3.0 + * @return array + */ + public function processingProvider() { + $argLists = []; + + $values = [ + 'location1' => '4,2', + 'location2' => '42,0', + ]; + + $expected = [ + 'location1' => new Location( new LatLongValue( 4, 2 ) ), + 'location2' => new Location( new LatLongValue( 42, 0 ) ), + ]; + + $argLists[] = [ $values, $expected ]; + + $values = [ + 'location1' => '4,2', + 'location2' => '42,0', + 'unit' => '~=[,,_,,]:3', + 'decimals' => '1', + ]; + + $expected = [ + 'location1' => new Location( new LatLongValue( 4, 2 ) ), + 'location2' => new Location( new LatLongValue( 42, 0 ) ), + 'decimals' => 1, + ]; + + $argLists[] = [ $values, $expected ]; + + return $argLists; + } + + /** + * @see ParserHookTest::getInstance + */ + protected function getInstance() { + return new \Maps\MediaWiki\ParserHooks\GeoDistanceFunction(); + } + +}
\ No newline at end of file |