Skip to content

Commit

Permalink
Merge pull request #14 from marjan88/hotfix-absolute-path
Browse files Browse the repository at this point in the history
[NOREF] - fix absolute path, slash added
  • Loading branch information
meinfernbus authored Dec 24, 2020
2 parents e6aed13 + 480bee1 commit 4f0e466
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/Maps/StaticMap.php
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,7 @@ public function render()

protected function getAbsolutePath($filename)
{
return $this->getUploadRootDir() . $filename . self::SUFFIX;
return $this->getUploadRootDir() . '/' . $filename . self::SUFFIX;
}

protected function getWebPath($filename): string
Expand Down
29 changes: 29 additions & 0 deletions tests/Maps/StaticMapTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -91,4 +91,33 @@ public function testSetGetZoom()
$this->map->setZoom($val);
$this->assertEquals($val, $this->map->getZoom());
}

public function testRender()
{
$mapsDir = __DIR__ . '/maps';
$marker = new Marker();
$marker->setMeta(['color' => 'green']);
$marker->setLatitude(52.476050612437);
$marker->setLongitude(13.364356141862);

$this->map->setMeta([
'key' => 'AIzaSyDdagXxC6br-y_Ih4nlxj3gxaiFKvObA_c',
'host' => 'https://api.flix-tech.test',
'size' => '640x350',
'zoom' => 15,
'maptype' => 'road',
]);
$this->map->setId('481');
$this->map->setMarkers([$marker]);
$this->map->setUploadDir($mapsDir);
$this->map->setPublicDir('/maps');

$out = '<img id="481" src="https://api.flix-tech.test/maps/size_640x350_zoom_15_maptype_road_sensor_false_markers_color_green_52_476050612437_13_364356141862.png" />';

$this->assertEquals($out, $this->map->render());
$this->assertEquals(__DIR__ . '/maps/size_640x350_zoom_15_maptype_road_sensor_false_markers_color_green_52_476050612437_13_364356141862.png', $this->map->getTargetPath());

unlink($this->map->getTargetPath());
rmdir($mapsDir);
}
}

0 comments on commit 4f0e466

Please sign in to comment.