Skip to content

Commit 88daee8

Browse files
author
Christoph Singer
committed
added test for equal result of both adapters
1 parent 2295875 commit 88daee8

File tree

1 file changed

+29
-0
lines changed

1 file changed

+29
-0
lines changed

tests/PHPExif/ExifTest.php

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -427,4 +427,33 @@ public function testGetOrientation()
427427
$this->exif->setRawData($data);
428428
$this->assertEquals($expected, $this->exif->getOrientation());
429429
}
430+
431+
/**
432+
* Test that the values returned by both adapters are equal
433+
*/
434+
public function testAdapterConsistency()
435+
{
436+
$reflClass = new \ReflectionClass('\PHPExif\Exif');
437+
$methods = $reflClass->getMethods(ReflectionMethod::IS_PUBLIC);
438+
$file = PHPEXIF_TEST_ROOT . '/files/morning_glory_pool_500.jpg';
439+
440+
$adapter_exiftool = new \PHPExif\Reader\Adapter\Exiftool();
441+
$adapter_native = new \PHPExif\Reader\Adapter\Native();
442+
443+
$result_exiftool = $adapter_exiftool->getExifFromFile($file);
444+
$result_native = $adapter_native->getExifFromFile($file);
445+
446+
// find all Getter methods on the results and compare its output
447+
foreach ($methods as $method) {
448+
$name = $method->getName();
449+
if (strpos($name, 'get') !== 0 || $name == 'getRawData') {
450+
continue;
451+
}
452+
$this->assertEquals(
453+
call_user_func(array($result_native, $name)),
454+
call_user_func(array($result_exiftool, $name)),
455+
'Adapter difference in method ' . $name
456+
);
457+
}
458+
}
430459
}

0 commit comments

Comments
 (0)