44
55use DokuWikiTest ;
66use helper_plugin_spatialhelper_index ;
7+ use TestUtils ;
78
89/**
910 * Tests for the class helper_plugin_spatialhelper_index of the spatialhelper plugin.
@@ -16,6 +17,18 @@ class index_test extends DokuWikiTest
1617
1718 protected $ pluginsEnabled = array ('spatialhelper ' );
1819
20+ /**
21+ * copy data and add pages to the index.
22+ */
23+ public static function setUpBeforeClass (): void
24+ {
25+ parent ::setUpBeforeClass ();
26+ global $ conf ;
27+ $ conf ['allowdebug ' ] = 1 ;
28+
29+ TestUtils::rcopy (TMP_DIR , __DIR__ . '/data/ ' );
30+ }
31+
1932 /**
2033 * Testdata for @return array
2134 * @see index_test::test_convertDMStoD
@@ -47,6 +60,15 @@ final public static function convertDMStoDTestdata(): array
4760 );
4861 }
4962
63+ final public function setUp (): void
64+ {
65+ parent ::setUp ();
66+
67+ global $ conf ;
68+ $ conf ['allowdebug ' ] = 1 ;
69+ $ conf ['cachetime ' ] = -1 ;
70+ }
71+
5072 /**
5173 * @dataProvider convertDMStoDTestdata
5274 */
@@ -59,4 +81,27 @@ final public function test_convertDMStoD(array $input, float $expected_output, s
5981
6082 self ::assertEqualsWithDelta ($ expected_output , $ actual_output , 0.0001 , $ msg );
6183 }
84+
85+ final public function test_ImageWithoutGeotag (): void
86+ {
87+ $ index = plugin_load ('helper ' , 'spatialhelper_index ' );
88+ assert ($ index instanceof helper_plugin_spatialhelper_index);
89+
90+ $ actual_output = $ index ->getCoordsFromExif (':vesder_eupen_no_gps.jpg ' );
91+ self ::assertFalse ($ actual_output , 'Expected no geotag to be found ' );
92+ }
93+
94+ final public function test_ImageWithGeotag (): void
95+ {
96+ $ index = plugin_load ('helper ' , 'spatialhelper_index ' );
97+ assert ($ index instanceof helper_plugin_spatialhelper_index);
98+
99+ // lat/lon: 37°4'36.12",31°39'21.96" or x/y: 31.6561,37.0767
100+ $ actual_output = $ index ->getCoordsFromExif (':manavgat_restaurant_handost_with_gps.jpg ' );
101+
102+ self ::assertNotNull ($ actual_output , 'Expected a geotag to be found ' );
103+ self ::assertNotFalse ($ actual_output , 'Expected a geotag to be found ' );
104+ self ::assertEqualsWithDelta (31.6561 , $ actual_output ->x (), 0.0001 );
105+ self ::assertEqualsWithDelta (37.0767 , $ actual_output ->y (), 0.0001 );
106+ }
62107}
0 commit comments