Skip to content

Commit 1d4a96b

Browse files
author
Tom Van Herreweghe
committed
Covered extra paths for Exiftool mapper test
Signed-off-by: Tom Van Herreweghe <[email protected]>
1 parent 401686c commit 1d4a96b

File tree

2 files changed

+54
-1
lines changed

2 files changed

+54
-1
lines changed

lib/PHPExif/Mapper/Exiftool.php

+4
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,11 @@ public function mapRawData(array $data)
172172
$key = $this->map[self::GPSLATITUDE];
173173

174174
$mappedData[$key] = $gpsLocation;
175+
} else {
176+
unset($mappedData[$this->map[self::GPSLATITUDE]]);
175177
}
178+
} else {
179+
unset($mappedData[$this->map[self::GPSLATITUDE]]);
176180
}
177181

178182
return $mappedData;

tests/PHPExif/Mapper/ExiftoolMapperTest.php

+50-1
Original file line numberDiff line numberDiff line change
@@ -186,5 +186,54 @@ public function testMapRawDataCorrectlyFormatsNumericGPSData()
186186
$this->assertCount(1, $result);
187187
$this->assertEquals($expected, reset($result));
188188
}
189-
189+
190+
/**
191+
* @group mapper
192+
* @covers \PHPExif\Mapper\Exiftool::mapRawData
193+
*/
194+
public function testMapRawDataCorrectlyIgnoresIncorrectGPSData()
195+
{
196+
$this->mapper->setNumeric(false);
197+
$result = $this->mapper->mapRawData(
198+
array(
199+
'GPSLatitude' => '40.333452381',
200+
'GPSLatitudeRef' => 'North',
201+
'GPSLongitude' => '20.167314814',
202+
'GPSLongitudeRef' => 'West',
203+
)
204+
);
205+
206+
$this->assertCount(0, $result);
207+
}
208+
209+
/**
210+
* @group mapper
211+
* @covers \PHPExif\Mapper\Exiftool::mapRawData
212+
*/
213+
public function testMapRawDataCorrectlyIgnoresIncompleteGPSData()
214+
{
215+
$result = $this->mapper->mapRawData(
216+
array(
217+
'GPSLatitude' => '40.333452381',
218+
'GPSLatitudeRef' => 'North',
219+
)
220+
);
221+
222+
$this->assertCount(0, $result);
223+
}
224+
225+
/**
226+
* @group mapper
227+
* @covers \PHPExif\Mapper\Exiftool::setNumeric
228+
*/
229+
public function testSetNumericInProperty()
230+
{
231+
$reflProperty = new \ReflectionProperty(get_class($this->mapper), 'numeric');
232+
$reflProperty->setAccessible(true);
233+
234+
$expected = true;
235+
$this->mapper->setNumeric($expected);
236+
237+
$this->assertEquals($expected, $reflProperty->getValue($this->mapper));
238+
}
190239
}

0 commit comments

Comments
 (0)