@@ -27,59 +27,59 @@ |
||
| 27 | 27 | class indexing_test extends DokuWikiTest |
| 28 | 28 | { |
| 29 | 29 | |
| 30 | - protected $pluginsEnabled = array('geotag', 'geophp', 'spatialhelper'); |
|
| 30 | + protected $pluginsEnabled = array('geotag', 'geophp', 'spatialhelper'); |
|
| 31 | 31 | |
| 32 | - /** |
|
| 33 | - * copy data and add pages to the index. |
|
| 34 | - */ |
|
| 35 | - public static function setUpBeforeClass(): void |
|
| 36 | - { |
|
| 37 | - parent::setUpBeforeClass(); |
|
| 32 | + /** |
|
| 33 | + * copy data and add pages to the index. |
|
| 34 | + */ |
|
| 35 | + public static function setUpBeforeClass(): void |
|
| 36 | + { |
|
| 37 | + parent::setUpBeforeClass(); |
|
| 38 | 38 | |
| 39 | - print_r(TMP_DIR); |
|
| 40 | - TestUtils::rcopy(TMP_DIR, __DIR__ . '/data/'); |
|
| 41 | - } |
|
| 39 | + print_r(TMP_DIR); |
|
| 40 | + TestUtils::rcopy(TMP_DIR, __DIR__ . '/data/'); |
|
| 41 | + } |
|
| 42 | 42 | |
| 43 | - final public function setUp(): void |
|
| 44 | - { |
|
| 45 | - parent::setUp(); |
|
| 43 | + final public function setUp(): void |
|
| 44 | + { |
|
| 45 | + parent::setUp(); |
|
| 46 | 46 | |
| 47 | - global $conf; |
|
| 48 | - $conf['allowdebug'] = 1; |
|
| 49 | - $conf['dontlog'] = []; |
|
| 50 | - $conf['cachetime'] = -1; |
|
| 47 | + global $conf; |
|
| 48 | + $conf['allowdebug'] = 1; |
|
| 49 | + $conf['dontlog'] = []; |
|
| 50 | + $conf['cachetime'] = -1; |
|
| 51 | 51 | |
| 52 | - idx_addPage('geotag', true, true); |
|
| 53 | - } |
|
| 52 | + idx_addPage('geotag', true, true); |
|
| 53 | + } |
|
| 54 | 54 | |
| 55 | - /** |
|
| 56 | - * @throws Exception if anything goes wrong |
|
| 57 | - */ |
|
| 58 | - final public function testIndexed(): void |
|
| 59 | - { |
|
| 60 | - $indexer = plugin_load('helper', 'spatialhelper_index'); |
|
| 61 | - $this->assertInstanceOf('helper_plugin_spatialhelper_index', $indexer); |
|
| 62 | - $this->assertTrue($indexer->updateSpatialIndex('geotag')); |
|
| 55 | + /** |
|
| 56 | + * @throws Exception if anything goes wrong |
|
| 57 | + */ |
|
| 58 | + final public function testIndexed(): void |
|
| 59 | + { |
|
| 60 | + $indexer = plugin_load('helper', 'spatialhelper_index'); |
|
| 61 | + $this->assertInstanceOf('helper_plugin_spatialhelper_index', $indexer); |
|
| 62 | + $this->assertTrue($indexer->updateSpatialIndex('geotag')); |
|
| 63 | 63 | |
| 64 | - // render the page |
|
| 65 | - $request = new TestRequest(); |
|
| 66 | - $response = $request->get(array('id' => 'geotag'), '/doku.php'); |
|
| 64 | + // render the page |
|
| 65 | + $request = new TestRequest(); |
|
| 66 | + $response = $request->get(array('id' => 'geotag'), '/doku.php'); |
|
| 67 | 67 | |
| 68 | - // test metadata |
|
| 69 | - $this->assertEquals( |
|
| 70 | - '52.132633;5.291266;9', |
|
| 71 | - $response->queryHTML('meta[name="geo.position"]')->attr('content') |
|
| 72 | - ); |
|
| 73 | - $this->assertEquals( |
|
| 74 | - '52.132633, 5.291266', |
|
| 75 | - $response->queryHTML('meta[name="ICBM"]')->attr('content') |
|
| 76 | - ); |
|
| 68 | + // test metadata |
|
| 69 | + $this->assertEquals( |
|
| 70 | + '52.132633;5.291266;9', |
|
| 71 | + $response->queryHTML('meta[name="geo.position"]')->attr('content') |
|
| 72 | + ); |
|
| 73 | + $this->assertEquals( |
|
| 74 | + '52.132633, 5.291266', |
|
| 75 | + $response->queryHTML('meta[name="ICBM"]')->attr('content') |
|
| 76 | + ); |
|
| 77 | 77 | |
| 78 | - // TODO / WIP test the geohash and index values |
|
| 79 | - $this->assertStringStartsWith( |
|
| 80 | - // u17b86kyx7j |
|
| 81 | - 'u17b86k', |
|
| 82 | - $response->queryHTML('meta[name="geo.hash"]')->attr('content') |
|
| 83 | - ); |
|
| 84 | - } |
|
| 78 | + // TODO / WIP test the geohash and index values |
|
| 79 | + $this->assertStringStartsWith( |
|
| 80 | + // u17b86kyx7j |
|
| 81 | + 'u17b86k', |
|
| 82 | + $response->queryHTML('meta[name="geo.hash"]')->attr('content') |
|
| 83 | + ); |
|
| 84 | + } |
|
| 85 | 85 | } |
@@ -15,95 +15,95 @@ |
||
| 15 | 15 | class index_test extends DokuWikiTest |
| 16 | 16 | { |
| 17 | 17 | |
| 18 | - protected $pluginsEnabled = array('spatialhelper'); |
|
| 19 | - |
|
| 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 | - |
|
| 32 | - /** |
|
| 33 | - * Test data provider. |
|
| 34 | - * @see index_test::test_convertDMStoD |
|
| 35 | - * |
|
| 36 | - * @return array |
|
| 37 | - * @see index_test::test_convertDMStoD |
|
| 38 | - */ |
|
| 39 | - final public static function convertDMStoDTestdata(): array |
|
| 40 | - { |
|
| 41 | - return array( |
|
| 42 | - array( |
|
| 43 | - array(0 => '52/1', 1 => '31/1', 2 => '2/1', 3 => 'N',), |
|
| 44 | - 52.5172, |
|
| 45 | - 'Latitude in Europe' |
|
| 46 | - ), |
|
| 47 | - array( |
|
| 48 | - array(0 => '13/1', 1 => '30/1', 2 => '38/1', 3 => 'E',), |
|
| 49 | - 13.5105, |
|
| 50 | - 'Longitude in Europe' |
|
| 51 | - ), |
|
| 52 | - array( |
|
| 53 | - array(0 => '50/1', 1 => '34251480/1000000', 2 => '0/1', 3 => 'N',), |
|
| 54 | - 50.5708, |
|
| 55 | - 'Latitude in North America' |
|
| 56 | - ), |
|
| 57 | - array( |
|
| 58 | - array(0 => '109/1', 1 => '28041300/1000000', 2 => '0/1', 3 => 'W',), |
|
| 59 | - -109.4673, |
|
| 60 | - 'Longitude in North America' |
|
| 61 | - ), |
|
| 62 | - ); |
|
| 63 | - } |
|
| 64 | - |
|
| 65 | - final public function setUp(): void |
|
| 66 | - { |
|
| 67 | - parent::setUp(); |
|
| 68 | - |
|
| 69 | - global $conf; |
|
| 70 | - $conf['allowdebug'] = 1; |
|
| 71 | - $conf['cachetime'] = -1; |
|
| 72 | - } |
|
| 73 | - |
|
| 74 | - /** |
|
| 75 | - * @dataProvider convertDMStoDTestdata |
|
| 76 | - */ |
|
| 77 | - final public function test_convertDMStoD(array $input, float $expected_output, string $msg): void |
|
| 78 | - { |
|
| 79 | - $index = plugin_load('helper', 'spatialhelper_index'); |
|
| 80 | - assert($index instanceof helper_plugin_spatialhelper_index); |
|
| 81 | - |
|
| 82 | - $actual_output = $index->convertDMStoD($input); |
|
| 83 | - |
|
| 84 | - self::assertEqualsWithDelta($expected_output, $actual_output, 0.0001, $msg); |
|
| 85 | - } |
|
| 86 | - |
|
| 87 | - final public function test_ImageWithoutGeotag(): void |
|
| 88 | - { |
|
| 89 | - $index = plugin_load('helper', 'spatialhelper_index'); |
|
| 90 | - assert($index instanceof helper_plugin_spatialhelper_index); |
|
| 91 | - |
|
| 92 | - $actual_output = $index->getCoordsFromExif(':vesder_eupen_no_gps.jpg'); |
|
| 93 | - self::assertFalse($actual_output, 'Expected no geotag to be found'); |
|
| 94 | - } |
|
| 95 | - |
|
| 96 | - final public function test_ImageWithGeotag(): void |
|
| 97 | - { |
|
| 98 | - $index = plugin_load('helper', 'spatialhelper_index'); |
|
| 99 | - assert($index instanceof helper_plugin_spatialhelper_index); |
|
| 100 | - |
|
| 101 | - // lat/lon: 37°4'36.12",31°39'21.96" or x/y: 31.6561,37.0767 |
|
| 102 | - $actual_output = $index->getCoordsFromExif(':manavgat_restaurant_handost_with_gps.jpg'); |
|
| 103 | - |
|
| 104 | - self::assertNotNull($actual_output, 'Expected a geotag to be found'); |
|
| 105 | - self::assertNotFalse($actual_output, 'Expected a geotag to be found'); |
|
| 106 | - self::assertEqualsWithDelta(31.6561, $actual_output->x(), 0.0001); |
|
| 107 | - self::assertEqualsWithDelta(37.0767, $actual_output->y(), 0.0001); |
|
| 108 | - } |
|
| 18 | + protected $pluginsEnabled = array('spatialhelper'); |
|
| 19 | + |
|
| 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 | + |
|
| 32 | + /** |
|
| 33 | + * Test data provider. |
|
| 34 | + * @see index_test::test_convertDMStoD |
|
| 35 | + * |
|
| 36 | + * @return array |
|
| 37 | + * @see index_test::test_convertDMStoD |
|
| 38 | + */ |
|
| 39 | + final public static function convertDMStoDTestdata(): array |
|
| 40 | + { |
|
| 41 | + return array( |
|
| 42 | + array( |
|
| 43 | + array(0 => '52/1', 1 => '31/1', 2 => '2/1', 3 => 'N',), |
|
| 44 | + 52.5172, |
|
| 45 | + 'Latitude in Europe' |
|
| 46 | + ), |
|
| 47 | + array( |
|
| 48 | + array(0 => '13/1', 1 => '30/1', 2 => '38/1', 3 => 'E',), |
|
| 49 | + 13.5105, |
|
| 50 | + 'Longitude in Europe' |
|
| 51 | + ), |
|
| 52 | + array( |
|
| 53 | + array(0 => '50/1', 1 => '34251480/1000000', 2 => '0/1', 3 => 'N',), |
|
| 54 | + 50.5708, |
|
| 55 | + 'Latitude in North America' |
|
| 56 | + ), |
|
| 57 | + array( |
|
| 58 | + array(0 => '109/1', 1 => '28041300/1000000', 2 => '0/1', 3 => 'W',), |
|
| 59 | + -109.4673, |
|
| 60 | + 'Longitude in North America' |
|
| 61 | + ), |
|
| 62 | + ); |
|
| 63 | + } |
|
| 64 | + |
|
| 65 | + final public function setUp(): void |
|
| 66 | + { |
|
| 67 | + parent::setUp(); |
|
| 68 | + |
|
| 69 | + global $conf; |
|
| 70 | + $conf['allowdebug'] = 1; |
|
| 71 | + $conf['cachetime'] = -1; |
|
| 72 | + } |
|
| 73 | + |
|
| 74 | + /** |
|
| 75 | + * @dataProvider convertDMStoDTestdata |
|
| 76 | + */ |
|
| 77 | + final public function test_convertDMStoD(array $input, float $expected_output, string $msg): void |
|
| 78 | + { |
|
| 79 | + $index = plugin_load('helper', 'spatialhelper_index'); |
|
| 80 | + assert($index instanceof helper_plugin_spatialhelper_index); |
|
| 81 | + |
|
| 82 | + $actual_output = $index->convertDMStoD($input); |
|
| 83 | + |
|
| 84 | + self::assertEqualsWithDelta($expected_output, $actual_output, 0.0001, $msg); |
|
| 85 | + } |
|
| 86 | + |
|
| 87 | + final public function test_ImageWithoutGeotag(): void |
|
| 88 | + { |
|
| 89 | + $index = plugin_load('helper', 'spatialhelper_index'); |
|
| 90 | + assert($index instanceof helper_plugin_spatialhelper_index); |
|
| 91 | + |
|
| 92 | + $actual_output = $index->getCoordsFromExif(':vesder_eupen_no_gps.jpg'); |
|
| 93 | + self::assertFalse($actual_output, 'Expected no geotag to be found'); |
|
| 94 | + } |
|
| 95 | + |
|
| 96 | + final public function test_ImageWithGeotag(): void |
|
| 97 | + { |
|
| 98 | + $index = plugin_load('helper', 'spatialhelper_index'); |
|
| 99 | + assert($index instanceof helper_plugin_spatialhelper_index); |
|
| 100 | + |
|
| 101 | + // lat/lon: 37°4'36.12",31°39'21.96" or x/y: 31.6561,37.0767 |
|
| 102 | + $actual_output = $index->getCoordsFromExif(':manavgat_restaurant_handost_with_gps.jpg'); |
|
| 103 | + |
|
| 104 | + self::assertNotNull($actual_output, 'Expected a geotag to be found'); |
|
| 105 | + self::assertNotFalse($actual_output, 'Expected a geotag to be found'); |
|
| 106 | + self::assertEqualsWithDelta(31.6561, $actual_output->x(), 0.0001); |
|
| 107 | + self::assertEqualsWithDelta(37.0767, $actual_output->y(), 0.0001); |
|
| 108 | + } |
|
| 109 | 109 | } |