for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
namespace Maps\Tests\Integration\parserhooks;
use Maps\MediaWiki\ParserHooks\DistanceFunction;
/**
* @covers DistanceFunction
*
* @licence GNU GPL v2+
* @author Jeroen De Dauw < [email protected] >
*/
class DistanceTest extends ParserHookTest {
private $distances = [
'42' => 42,
'42m' => 42,
'42 m' => 42,
'42 km' => 42000,
'4.2 km' => 4200,
'4.2 m' => 4.2,
];
* @see ParserHookTest::parametersProvider
public function parametersProvider() {
$paramLists = [];
foreach ( array_keys( $this->distances ) as $distance ) {
$paramLists[] = [ 'distance' => (string)$distance ];
}
return $this->arrayWrap( $paramLists );
* @see ParserHookTest::processingProvider
public function processingProvider() {
$argLists = [];
foreach ( $this->distances as $input => $output ) {
$values = [
'distance' => (string)$input,
$expected = [
'distance' => $output,
$argLists[] = [ $values, $expected ];
'distance' => '42m',
'unit' => 'km',
'decimals' => '1',
'distance' => 42,
'decimals' => 1,
'unit' => '~=[,,_,,]:3',
'decimals' => 'foobar',
return $argLists;
* @see ParserHookTest::getInstance
protected function getInstance() {
return new \Maps\MediaWiki\ParserHooks\DistanceFunction();