1<?php
2
3namespace dokuwiki\plugin\spatialhelper\test;
4
5use DokuWikiTest;
6use helper_plugin_spatialhelper_index;
7
8/**
9 * Tests for the class helper_plugin_spatialhelper_index of the spatialhelper plugin
10 *
11 * @group plugin_spatialhelper
12 * @group plugins
13 */
14class index_test extends DokuWikiTest {
15
16    protected $pluginsEnabled = array('spatialhelper');
17
18    /**
19     * Testdata for @return array
20     * @see index_test::test_convertDMStoD
21     *
22     */
23    public static function convertDMStoDTestdata(): array {
24        return array(
25            array(
26                array(0 => '52/1', 1 => '31/1', 2 => '2/1', 3 => 'N',),
27                52.5172,
28                'Latitude in Europe'
29            ),
30            array(
31                array(0 => '13/1', 1 => '30/1', 2 => '38/1', 3 => 'E',),
32                13.5105,
33                'Longitude in Europe'
34            ),
35            array(
36                array(0 => '50/1', 1 => '34251480/1000000', 2 => '0/1', 3 => 'N',),
37                50.5708,
38                'Latitude in North America'
39            ),
40            array(
41                array(0 => '109/1', 1 => '28041300/1000000', 2 => '0/1', 3 => 'W',),
42                -109.4673,
43                'Longitude in North America'
44            ),
45        );
46    }
47
48    /**
49     * @dataProvider convertDMStoDTestdata
50     */
51    public function test_convertDMStoD(array $input, float $expected_output, string $msg): void {
52        $index = plugin_load('helper', 'spatialhelper_index');
53        assert($index instanceof helper_plugin_spatialhelper_index);
54
55        $actual_output = $index->convertDMStoD($input);
56
57        self::assertEqualsWithDelta($expected_output, $actual_output, 0.0001, $msg);
58    }
59}
60