Skip to content

Commit

Permalink
Covered extra paths for Exiftool mapper test
Browse files Browse the repository at this point in the history
Signed-off-by: Tom Van Herreweghe <[email protected]>
  • Loading branch information
Tom Van Herreweghe committed Apr 3, 2015
1 parent 401686c commit 1d4a96b
Show file tree
Hide file tree
Showing 2 changed files with 54 additions and 1 deletion.
4 changes: 4 additions & 0 deletions lib/PHPExif/Mapper/Exiftool.php
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,11 @@ public function mapRawData(array $data)
$key = $this->map[self::GPSLATITUDE];

$mappedData[$key] = $gpsLocation;
} else {
unset($mappedData[$this->map[self::GPSLATITUDE]]);
}
} else {
unset($mappedData[$this->map[self::GPSLATITUDE]]);
}

return $mappedData;
Expand Down
51 changes: 50 additions & 1 deletion tests/PHPExif/Mapper/ExiftoolMapperTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -186,5 +186,54 @@ public function testMapRawDataCorrectlyFormatsNumericGPSData()
$this->assertCount(1, $result);
$this->assertEquals($expected, reset($result));
}


/**
* @group mapper
* @covers \PHPExif\Mapper\Exiftool::mapRawData
*/
public function testMapRawDataCorrectlyIgnoresIncorrectGPSData()
{
$this->mapper->setNumeric(false);
$result = $this->mapper->mapRawData(
array(
'GPSLatitude' => '40.333452381',
'GPSLatitudeRef' => 'North',
'GPSLongitude' => '20.167314814',
'GPSLongitudeRef' => 'West',
)
);

$this->assertCount(0, $result);
}

/**
* @group mapper
* @covers \PHPExif\Mapper\Exiftool::mapRawData
*/
public function testMapRawDataCorrectlyIgnoresIncompleteGPSData()
{
$result = $this->mapper->mapRawData(
array(
'GPSLatitude' => '40.333452381',
'GPSLatitudeRef' => 'North',
)
);

$this->assertCount(0, $result);
}

/**
* @group mapper
* @covers \PHPExif\Mapper\Exiftool::setNumeric
*/
public function testSetNumericInProperty()
{
$reflProperty = new \ReflectionProperty(get_class($this->mapper), 'numeric');
$reflProperty->setAccessible(true);

$expected = true;
$this->mapper->setNumeric($expected);

$this->assertEquals($expected, $reflProperty->getValue($this->mapper));
}
}

0 comments on commit 1d4a96b

Please sign in to comment.